* link/z80/aslink.h: Fixed path for PATH_MAX
[fw/sdcc] / doc / choices.txt
index 080b0cf24a948918414914c1b83e3e6974a78d43..9fa79244d309fd21e6a9d491a227ded83bbf179e 100644 (file)
@@ -35,4 +35,75 @@ On stack word push
         inc  hl
         ld   d,(hl)
    1 = d + 8 + 8 + 4
-   2 = d + 8 + 8 + 8
\ No newline at end of file
+   2 = d + 8 + 8 + 8
+
+Structure member get:
+   Normally fetch pair
+   Then add pair and constant with result in hl
+
+   ld  l,c     ; 4
+   ld  h,b     ; 4
+   inc  hl ..  ; 6     = 8 + 6n
+or
+   ld  l,c     ; 4
+   ld  h,b     ; 4
+   ld  a,#0x06 ; 7
+   add a,c     ; 4
+   ld  l,a     ; 4
+   ld  a,#0x00 ; 7
+   adc a,b     ; 4
+   ld  h,a     ; 4     = 38
+alt: (only when result=hl and left, rigth = pair, const)
+   ld     hl,#const    ; 10
+   add    hl,pair      ; 11    = 21
+
+So (1) is best for n <= 2, (2) is just bad, (3) is good n > 2
+
+How about:
+    pair = pair + constant:
+1:
+    ld a,#0x08 ; 7
+    add        a,c     ; 4
+    ld c,a     ; 4
+    ld a,#0x00 ; 7
+    adc        a,b     ; 4
+    ld b,a     ; 4     = 30
+2:
+       ld      hl,#const       ; 10
+       add     hl,pair         ; 11
+       ld      c,l             ; 4
+       ld      b,h             ; 4     = 29
+One cycle.  If I cache HL later it will throw away the advantage.  Choose 1.
+
+PlusIncr on pairs:
+1:
+        inc    pair            ; 6     = 6n
+2:
+       ld      a,#0x04         ; 7
+       add     a,c             ; 4
+       ld      c,a             ; 4
+       ld      a,#0x00         ; 7
+       adc     a,b             ; 4
+       ld      b,a             ; 4     = 30
+So n <= 5 (1) is better.
+
+Frame pointer:
+It's nice to use HL as the temp register, but what if I used it as the
+frame pointer instead of ix?
+
+Instead of:
+       ld      e,5(ix)         ; 19
+       ld      d,6(ix)         ; 19    = 38
+
+       ld      hl,#5           ; 10
+       add     hl,sp           ; 11
+       ld      e,(hl)          ; 7
+       inc     hl              ; 6
+       ld      d,(hl)          ; 7     = 41
+
+Things get better when you access the same set over, as you get rid
+of the setup.  But they get worse when both ops are on the stack/in
+direct space.  Easiest this way for now.  iy may benifit...
+
+