📄 z80rules.1
字号:
call l_eq jp nc,%2 ld hl,%3= ld a,(hl) cp #(%1 % 256) jp nz,%2 ld hl,%3 ld e,(hl) ld d,0 ld hl,%1 ;const call l_eq jp c,%2 ld hl,%3= ld a,(hl) cp #(%1 % 256) jp z,%2 ld hl,%3 ld e,(hl) ld d,0 ld hl,%1 ;const call l_ne jp c,%2 ld hl,%3= ld a,(hl) cp #(%1 % 256) jp nz,%2 ld hl,%3 ld hl,(%1) ld h,0 ld a,h or l jp nz,%2 ld hl,%3= ld a,(%1) and a jp nz,%2 ld hl,%3 push hl ld hl,(%1) ld h,0 pop de= ex de,hl ld hl,(%1) ld h,0 pop hl push hl push hl pop bc pop hl push hl push bc= pop hl push hl push hl ld de,0 ;const ex de,hl call l_eq pop bc push hl ld a,h or l jp z,%1= pop bc push hl ld a,h or l jp nz,%1 push hl pop bc pop hl push hl push bc pop de= ex de,hl pop hl push hl push hl ld (%1),hl pop hl= ld (%1),hl ld l,(hl) ld h,0 ex de,hl ld hl,%1= ld e,(hl) ld d,0 ld hl,%1 ld hl,_%1 ex de,hl pop hl push hl call l_pint= pop hl ld (_%1),hl push hl push hl pop hl ret= ret push de push hl ld hl,0 ;const ld de,0 call l_long_eq jp c,%1= ld a,h or l or e or d jp z,%1 pop bc push hl ld a,h or l jp nz,%1 pop bc ret.%1= pop bc ld a,h or l ret z push hl.%1; Rules for optimizing the tail of if statements (valid for && and || ); These are only valid if we don't try to set a variable to the logical result, if; we do then it's a tad pointless and you'll suffer!!! <cackle?=; ld hl,0 ;const jr %1.%2 ld hl,1 ;const.%1 ld a,h or l jp z,%3= jp %3.%2 ld hl,1 ;const jr %1.%2 ld hl,0 ;const.%1 ld a,h or l jp z,%3= jr %1_%2.%2 jp %3.%1_%2 jp n%0,%1 jr %2.%1 jp %3.%2= jr %0,%2.%1 jp %3.%2 ld a,h or l jp nz,%1 ld hl,0 ;const jp %2.%1= ld a,h or l jp z,%2.%1 jp nc,%1 jp %2.%1= jp c,%2.%1 jp c,%1 jp %2.%1= jp nc,%2.%1 jr c,%1.%2 jp %3.%1 jp %4.%3 jp %5.%4= jr c,%4.%2.%3 jp %5.%1.%4 push de ld hl,%1 pop de= ld hl,%1 ld hl,%1 %2 (hl) ld a,(%1)= ld hl,%1 %2 (hl) ld a,(hl) push de pop hl push hl= push de ld l,e ld h,d pop bc pop hl push hl push bc ld de,%1 ;const ex de,hl= pop bc pop de push de push bc ld hl,%1 ;const push hl ld hl,%1 ;const add hl,sp call l_gint ;%9 pop de= ex de,hl ld hl,%1-2 ;const add hl,sp call l_gint ;%9 ld hl,%1 ex de,hl ld hl,%2= ld de,%1 ld hl,%2 push %1 pop %1 push %1= push %1 pop bc pop hl push hl push bc push hl pop bc pop hl push hl push bc push hl= pop de pop hl push hl push de push hl push de ld hl,4 ;const add hl,sp push hl ld hl,6 ;const add hl,sp= ld hl,4 ;const add hl,sp push hl ld hl,%1 ;const ld a,l ld l,h ld h,a= ld hl,#( (%1/256) + (%1 % 256 )*256 ) ld hl,0 ;const add hl,sp push hl call l_gint ;%9 ld bc,%1 add hl,bc pop de call l_pint= pop hl ld bc,%1 add hl,bc push hl push bc ld hl,%1 pop bc= ld hl,%1 call exit ret= jp exit ld l,(hl) ld h,0.%1 ld hl,%2=.%1 ld hl,%2 ld (hl),#(%1 % 256) ld l,(hl) ld h,0 pop de ld a,l ld (de),a ld hl,%2= ld a,#(%1 % 256) ld (hl),a pop de ld (de),a ld hl,%2 pop hl inc hl push hl dec hl ld (hl),#(%1 % 256)= pop hl ld (hl),#(%1 % 256) inc hl push hl dec hl push hl pop hl %1c hl push hl= %1c hl push hl ld hl,%1 exx ld hl,%2 add hl,sp ld sp,hl exx ret= ld hl,%2 add hl,sp ld sp,hl ld hl,%1 ret ld e,(hl) ld d,0 ld hl,%1 ;const call l_and= ld a,(hl) and #(%1 % 256) ld l,a ld h,0 ld l,a ld h,0 ld h,l ld l,0= ld h,a ld l,0 ld hl,0 ;const push hl ld hl,1 ;const= ld hl,0 ;const push hl inc hl ld hl,1 ;const push hl ld hl,0 ;const= ld hl,1 ;const push hl dec hl push hl ld a,h or l jp %1 pop hl push hl= push hl ld a,h or l jp %1 push hl ld hl,#%1 pop de= ex de,hl ld hl,#%1 push bc ld hl,%1 ;const add hl,sp call l_gint ;%9 pop bc push hl= ld hl,%1-2 ;const add hl,sp call l_gint ;%9 push hl exx ld hl,%1 ;const add hl,sp ld sp,hl exx ld hl,%2= ld hl,%1 ;const add hl,sp ld sp,hl ld hl,%2 push af ld hl,%1 pop af= ld hl,%1 ld l,(hl) ld h,0 ld a,l ld l,h ld h,a= ld h,(hl) ld l,0 pop bc push hl ld a,h or l jp nz,%1 pop bc ret= pop bc ld a,h or l ret z push hl jp %1 ld h,0 %1c l ld a,h or l jp %2= ld h,0 %1c l jp %2 ld a,h or l jp nz,%1 ld hl,0 ;const= ld a,h or l jp nz,%1 ld l,e ld h,d ld bc,%1 add hl,bc= ld hl,%1 add hl,de ld hl,(%1) ld h,0 ld a,l ld (de),a ld hl,%2= ld a,(%1) ld (de),a ld hl,%2 jp z,%1 jr %2.%1 jp %3.%2= jr nz,%2.%1 jp %3.%2 ld hl,%1 ;const add hl,sp call l_gint ;%9 ld a,(hl) cp %2 jp %3 ld hl,%1 ;const add hl,sp call l_gint ;%9 ld a,(hl) cp %4= ld hl,%1 ;const add hl,sp call l_gint ;%9 ld a,(hl) cp %2 jp %3 cp %4 jp nc,%1 ld hl,1 ;const jr %2.%1 ld hl,0 ;const.%2 ld a,h or l jp nz,%3 ld hl,%4= jp c,%3.%1 jr %1_%2.%2 ld a,h or l jp nz,%3.%1_%2 ld hl,%4 jp %1,%2.%3 jp %4.%2= jr %1,%2.%3 jp %4.%2; These next few rules deal with optimizing for testing a; signed int for being < 0, we end up with saving of 7 bytes=; ld hl,0 ;const call l_lt jp nc,%1 ld hl,%2= bit 7,d jp z,%1 ld hl,%2 ld hl,0 ;const call l_lt jp c,%1 ld hl,%2= bit 7,d jp nz,%1 ld hl,%2 ld e,(hl) inc hl ld d,(hl) bit 7,d= inc hl ld a,(hl) bit 7,a ld a,(hl) bit 7,a jp nz,%1= ld a,(hl) rlca jp c,%1 ld a,(hl) bit 7,a jp z,%1= ld a,(hl) rlca jp nc,%1 ld hl,%1 push hl pop bc pop hl push hl push bc add hl,hl pop de add hl,de= pop hl push hl add hl,hl ld de,%1 add hl,de ld hl,%1 push hl pop bc pop hl push hl push bc push hl= pop hl push hl ld de,%1 push de push hl ld hl,%1 ld de,%2 ex de,hl call l_eq= ld hl,%1 ld de,%2 call l_eq ld hl,%1 ld de,0 ;const call l_eq jp c,%4 ld hl,%3= ld hl,%1 ld a,h or l jp z,%4 ld hl,%3 ex de,hl ld de,%1 ex de,hl= ld hl,%1 ld hl,%1 ;const add hl,sp pop de add hl,de dec hl= ld hl,%1-1 ;const add hl,sp pop de add hl,de pop bc push hl %1c hl %1c hl pop bc push hl= %1c hl %1c hl pop bc push hl ld hl,%1 inc (hl) ld l,(hl) ld h,0 dec l ld a,(%1)= ld hl,%1 ld a,(hl) inc (hl) pop hl push hl pop bc pop bc ret= pop hl pop bc ret ld l,(hl) ld h,0 %1c hl ld hl,%2= ld hl,%2 ld hl,0 ;const add hl,sp add a,#(%1 % 256) ld (hl),a ld l,a ld h,0= pop hl ld a,l add a,#(%1 % 256) ld l,a push hl ld h,0 ld hl,%1 add hl,sp push hl ld hl,%2 call dload pop hl call dstore= ld hl,%2 call dload ld hl,%1 add hl,sp call dstore ld e,(hl) ld d,0 ld hl,(%1) ld h,0 call l_eq jp nc,%2= ld a,(%1) cp (hl) jp nz,%2 ld e,(hl) inc hl ld d,(hl) ld l,#(8 % 256) call l_asr_u= inc hl ld l,(hl) ld h,0 push hl ld hl,%1 ;const add hl,sp ld l,(hl) ld h,0 pop de= ex de,hl ld hl,%1-2 ;const add hl,sp ld l,(hl) ld h,0 jp nc,%1 call %2.%1= call c,%2.%1 jp c,%1 call %2.%1= call nc,%2.%1 ld e,(hl) ld d,0 ld hl,%1 ;const call l_eq ld hl,0 ;const rl l= ld a,(hl) cp #( %1 % 256) ld hl,0 jr nz,ASMPC+3 inc hl ld e,(hl) ld d,0 ld hl,%1 ;const call l_eq ld hl,%2 jp c,%3 ld hl,%4= ld a,(hl) cp #(%1 % 256) ld hl,%2 jp z,%3 ld hl,%4 jr z,ASMPC+3 scf call c,%2= call nz,%2 jr nz,ASMPC+3 scf call c,%2= call z,%2 call l_gchar push hl ld hl,%1 ;const add hl,sp call l_gchar pop de ld a,l sub e= ld e,(hl) ld hl,%1-2 ;const add hl,sp ld a,(hl) sub e ld e,(hl) ld d,0 ld hl,%1 ;const add hl,sp ld l,(hl) ld h,0 ld a,l sub e= ld e,(hl) ld hl,%1 ;const add hl,sp ld a,(hl) sub e ld e,(hl) ld d,0 ld hl,%1 ;const ld a,l sub e= ld a,#(%1 % 256) sub (hl) ld e,(hl) ld d,0 ld hl,%1 ;const ld a,e sub l= ld a,(hl) sub #(%1 % 256) call l_gchar ld de,%1 ;const ex de,hl ld a,e sub l= ld a,(hl) sub #(%1 % 256) xor a sub (hl) and a jr nz,ASMPC+3 scf jp nc,%1= ld a,(hl) and a jp nz,%1 ld l,a ld h,0 ld de,%1 ;const ex de,hl ld a,l sub e and a jr nz,ASMPC+3 scf jp nc,%2= cp #(%1 % 256) jp nz,%2 ld l,(hl) ld h,0 push hl ld hl,%1 ;const add hl,sp ld a,(hl) %2 #%3 ld l,a ld h,0 pop de ld a,e= ld e,(hl) ld hl,%1-2 ;const add hl,sp ld a,(hl) %2 #%3 ld l,a ld a,e and a jr nz,ASMPC+3 scf jp %2c,%1= jp %2z,%1 ld l,(hl) ld h,0 ld a,l and a jp %2z,%1= ld a,(hl) and a jp %2z,%1 ld hl,(%1) ld h,0 ld de,%2 ;const ex de,hl= ld a,(%1) ld e,a ld d,0 ld hl,%2 ;const ex de,hl ld a,h or l jp z,%1 ld hl,%2= ld a,d or e jp z,%1 ld hl,%2 ld hl,1 ;const add hl,sp ld l,(hl) ld h,0= pop hl push hl ld l,h ld h,0 ld l,a ld h,0 ld de,%1 ex de,hl= ld e,a ld d,0 ld hl,%1 ld l,(hl) ld h,0 %1c l ld hl,%2= ld hl,%2 jp %1.%1= pop hl push hl pop bc= pop hl
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -