;@ --------------------------- Defines ----------------------------\r
;@ Make sure that regs/pointers for z80pc to z80sp match up!\r
\r
+ eabi_align .req r2 @ pushed for EABI alignment all over the place\r
z80_icount .req r3\r
opcodes .req r4\r
cpucontext .req r5\r
\r
0:\r
@ z80_xmap_read8 will save r3 and r12 for us\r
- stmfd sp!,{r8,r9,lr}\r
+ stmfd sp!,{r2,r8,r9,lr}\r
mov r8,r0\r
bl z80_xmap_read8\r
mov r9,r0\r
add r0,r8,#1\r
bl z80_xmap_read8\r
orr r0,r9,r0,lsl #8\r
- ldmfd sp!,{r8,r9,pc}\r
+ ldmfd sp!,{r2,r8,r9,pc}\r
\r
z80_xmap_write16: @ data, addr\r
add r2,r1,#1\r
bx lr\r
\r
0:\r
- stmfd sp!,{r8,r9,lr}\r
+ stmfd sp!,{r2,r8,r9,lr}\r
mov r8,r0\r
mov r9,r1\r
bl z80_xmap_write8\r
mov r0,r8,lsr #8\r
add r1,r9,#1\r
bl z80_xmap_write8\r
- ldmfd sp!,{r8,r9,pc}\r
+ ldmfd sp!,{r2,r8,r9,pc}\r
\r
z80_xmap_rebase_pc:\r
ldr r1,[cpucontext,#z80_read8]\r
bxcc lr\r
\r
z80_bad_jump:\r
- stmfd sp!,{r3,r12,lr}\r
+ stmfd sp!,{r2,r3,r12,lr}\r
mov lr,pc\r
ldr pc,[cpucontext,#z80_rebasePC]\r
mov z80pc,r0\r
- ldmfd sp!,{r3,r12,pc}\r
+ ldmfd sp!,{r2,r3,r12,pc}\r
\r
.if FAST_Z80SP\r
z80_xmap_rebase_sp:\r
addcc z80sp,r1,r0\r
bxcc lr\r
\r
- stmfd sp!,{r3,r12,lr}\r
+ stmfd sp!,{r2,r3,r12,lr}\r
mov lr,pc\r
ldr pc,[cpucontext,#z80_rebaseSP]\r
mov z80sp,r0\r
- ldmfd sp!,{r3,r12,pc}\r
+ ldmfd sp!,{r2,r3,r12,pc}\r
.endif @ FAST_Z80SP\r
\r
.endif @ DRZ80_XMAP\r
;@---------------------------------------\r
\r
.macro opIN\r
- stmfd sp!,{r3,r12}\r
+ str z80_icount,[cpucontext,#cycles_pointer]\r
+ stmfd sp!,{r2,r12}\r
mov lr,pc\r
ldr pc,[cpucontext,#z80_in] ;@ r0=port - data returned in r0\r
- ldmfd sp!,{r3,r12}\r
+ ldr z80_icount,[cpucontext,#cycles_pointer]\r
+ ldmfd sp!,{r2,r12}\r
.endm\r
\r
.macro opIN_C\r
;@---------------------------------------\r
\r
.macro opOUT\r
- stmfd sp!,{r3,r12}\r
+ str z80_icount,[cpucontext,#cycles_pointer]\r
+ stmfd sp!,{r2,r12}\r
mov lr,pc\r
ldr pc,[cpucontext,#z80_out] ;@ r0=port r1=data\r
- ldmfd sp!,{r3,r12}\r
+ ldr z80_icount,[cpucontext,#cycles_pointer]\r
+ ldmfd sp!,{r2,r12}\r
.endm\r
\r
.macro opOUT_C\r
\r
.macro opRESmem bit\r
.if DRZ80_XMAP\r
- stmfd sp!,{r0} ;@ save addr as well\r
+ stmfd sp!,{r0,r2} ;@ save addr as well\r
bl z80_xmap_read8\r
bic r0,r0,#1<<\bit\r
- ldmfd sp!,{r1} ;@ restore addr into r1\r
+ ldmfd sp!,{r1,r2} ;@ restore addr into r1\r
bl z80_xmap_write8\r
.else\r
stmfd sp!,{r3,r12}\r
- stmfd sp!,{r0} ;@ save addr as well\r
+ stmfd sp!,{r0,r2} ;@ save addr as well\r
mov lr,pc\r
ldr pc,[cpucontext,#z80_read8] ;@ r0=addr - data returned in r0\r
bic r0,r0,#1<<\bit\r
- ldmfd sp!,{r1} ;@ restore addr into r1\r
+ ldmfd sp!,{r1,r2} ;@ restore addr into r1\r
mov lr,pc\r
ldr pc,[cpucontext,#z80_write8] ;@ r0=data r1=addr\r
ldmfd sp!,{r3,r12}\r
\r
.macro opSETmem bit\r
.if DRZ80_XMAP\r
- stmfd sp!,{r0} ;@ save addr as well\r
+ stmfd sp!,{r0,r2} ;@ save addr as well\r
bl z80_xmap_read8\r
orr r0,r0,#1<<\bit\r
- ldmfd sp!,{r1} ;@ restore addr into r1\r
+ ldmfd sp!,{r1,r2} ;@ restore addr into r1\r
bl z80_xmap_write8\r
.else\r
stmfd sp!,{r3,r12}\r
- stmfd sp!,{r0} ;@ save addr as well\r
+ stmfd sp!,{r0,r2} ;@ save addr as well\r
mov lr,pc\r
ldr pc,[cpucontext,#z80_read8] ;@ r0=addr - data returned in r0\r
orr r0,r0,#1<<\bit\r
- ldmfd sp!,{r1} ;@ restore addr into r1\r
+ ldmfd sp!,{r1,r2} ;@ restore addr into r1\r
mov lr,pc\r
ldr pc,[cpucontext,#z80_write8] ;@ r0=data r1=addr\r
ldmfd sp!,{r3,r12}\r
.else\r
\r
;@ r0 == z80if\r
- stmfd sp!,{lr}\r
+ stmfd sp!,{r2,lr}\r
\r
tst r0,#4 ;@ check halt\r
addne z80pc,z80pc,#1\r
mov lr,pc\r
mov pc,r0 ;@ call callback function\r
ldmfd sp!,{r3,r12}\r
- ldmfd sp!,{pc} ;@ return\r
+ ldmfd sp!,{r2,pc} ;@ return\r
.endif\r
\r
DoNMI:\r
- stmfd sp!,{lr}\r
+ stmfd sp!,{r2,lr}\r
\r
bic r0,r0,#((Z80_NMI|Z80_HALT|Z80_IF1)<<8)\r
strh r0,[cpucontext,#z80irq] @ 0x4C, irq and IFF bits\r
.endif\r
ldrh r0,[cpucontext,#z80irq] @ 0x4C, irq and IFF bits\r
eatcycles 11\r
- ldmfd sp!,{pc}\r
+ ldmfd sp!,{r2,pc}\r
\r
\r
.data\r
ldrb r0,[z80pc],#1\r
ldrb r1,[z80pc],#1\r
orr r0,r0,r1, lsl #8\r
- stmfd sp!,{z80xx}\r
+ stmfd sp!,{r2,z80xx}\r
readmem16\r
- ldmfd sp!,{z80xx}\r
+ ldmfd sp!,{r2,z80xx}\r
strh r0,[z80xx,#2]\r
fetch 20\r
;@DEC IX\r
ldr r1,[z80xx]\r
add r0,r1,r0, lsl #16\r
mov r0,r0,lsr #16\r
- stmfd sp!,{r0} ;@ save addr\r
+ stmfd sp!,{r0,r2} ;@ save addr\r
readmem8\r
opINC8b\r
- ldmfd sp!,{r1} ;@ restore addr into r1\r
+ ldmfd sp!,{r1,r2} ;@ restore addr into r1\r
writemem8\r
fetch 23\r
;@DEC (IX+N)\r
ldr r1,[z80xx]\r
add r0,r1,r0, lsl #16\r
mov r0,r0,lsr #16\r
- stmfd sp!,{r0} ;@ save addr\r
+ stmfd sp!,{r0,r2} ;@ save addr\r
readmem8\r
opDEC8b\r
- ldmfd sp!,{r1} ;@ restore addr into r1\r
+ ldmfd sp!,{r1,r2} ;@ restore addr into r1\r
writemem8\r
fetch 23\r
;@LD (IX+N),N\r
\r
;@RLC (IX+N) \r
opcode_DD_CB_06:\r
- stmfd sp!,{r0} ;@ save addr\r
+ stmfd sp!,{r0,r2} ;@ save addr\r
readmem8\r
opRLCb\r
- ldmfd sp!,{r1} ;@ restore addr into r1\r
+ ldmfd sp!,{r1,r2} ;@ restore addr into r1\r
writemem8\r
fetch 23\r
;@RRC (IX+N) \r
opcode_DD_CB_0E:\r
- stmfd sp!,{r0} ;@ save addr\r
+ stmfd sp!,{r0,r2} ;@ save addr\r
readmem8\r
opRRCb\r
- ldmfd sp!,{r1} ;@ restore addr into r1\r
+ ldmfd sp!,{r1,r2} ;@ restore addr into r1\r
writemem8\r
fetch 23\r
;@RL (IX+N) \r
opcode_DD_CB_16:\r
- stmfd sp!,{r0} ;@ save addr\r
+ stmfd sp!,{r0,r2} ;@ save addr\r
readmem8\r
opRLb\r
- ldmfd sp!,{r1} ;@ restore addr into r1\r
+ ldmfd sp!,{r1,r2} ;@ restore addr into r1\r
writemem8\r
fetch 23\r
;@RR (IX+N) \r
opcode_DD_CB_1E:\r
- stmfd sp!,{r0} ;@ save addr \r
+ stmfd sp!,{r0,r2} ;@ save addr \r
readmem8\r
opRRb\r
- ldmfd sp!,{r1} ;@ restore addr into r1\r
+ ldmfd sp!,{r1,r2} ;@ restore addr into r1\r
writemem8\r
fetch 23\r
\r
;@SLA (IX+N) \r
opcode_DD_CB_26:\r
- stmfd sp!,{r0} ;@ save addr \r
+ stmfd sp!,{r0,r2} ;@ save addr \r
readmem8\r
opSLAb\r
- ldmfd sp!,{r1} ;@ restore addr into r1\r
+ ldmfd sp!,{r1,r2} ;@ restore addr into r1\r
writemem8\r
fetch 23\r
;@SRA (IX+N) \r
opcode_DD_CB_2E:\r
- stmfd sp!,{r0} ;@ save addr \r
+ stmfd sp!,{r0,r2} ;@ save addr \r
readmem8\r
opSRAb\r
- ldmfd sp!,{r1} ;@ restore addr into r1\r
+ ldmfd sp!,{r1,r2} ;@ restore addr into r1\r
writemem8\r
fetch 23\r
;@SLL (IX+N) \r
opcode_DD_CB_36:\r
- stmfd sp!,{r0} ;@ save addr \r
+ stmfd sp!,{r0,r2} ;@ save addr \r
readmem8\r
opSLLb\r
- ldmfd sp!,{r1} ;@ restore addr into r1\r
+ ldmfd sp!,{r1,r2} ;@ restore addr into r1\r
writemem8\r
fetch 23\r
;@SRL (IX+N)\r
opcode_DD_CB_3E:\r
- stmfd sp!,{r0} ;@ save addr \r
+ stmfd sp!,{r0,r2} ;@ save addr \r
readmem8\r
opSRLb\r
- ldmfd sp!,{r1} ;@ restore addr into r1\r
+ ldmfd sp!,{r1,r2} ;@ restore addr into r1\r
writemem8\r
fetch 23\r
\r
opPOP\r
.else\r
mov r0,z80sp\r
- stmfd sp!,{z80xx}\r
+ stmfd sp!,{r2,z80xx}\r
readmem16\r
- ldmfd sp!,{z80xx}\r
+ ldmfd sp!,{r2,z80xx}\r
add z80sp,z80sp,#2\r
.endif\r
strh r0,[z80xx,#2]\r
strh r2,[z80xx,#2]\r
.else\r
mov r0,z80sp\r
- stmfd sp!,{z80xx}\r
+ stmfd sp!,{r2,z80xx}\r
readmem16\r
- ldmfd sp!,{z80xx}\r
+ ldmfd sp!,{r2,z80xx}\r
mov r2,r0\r
ldrh r0,[z80xx,#2]\r
strh r2,[z80xx,#2]\r