z80, minor fixes to drz80 + cz80 to bring them in sync
authorkub <derkub@gmail.com>
Mon, 3 Jul 2023 21:37:22 +0000 (23:37 +0200)
committerkub <derkub@gmail.com>
Mon, 3 Jul 2023 21:37:22 +0000 (23:37 +0200)
cpu/DrZ80/drz80.S
cpu/cz80/cz80_opXY.c

index 518bb72..edcebb8 100644 (file)
@@ -286,9 +286,9 @@ z80_xmap_rebase_sp:
        sub r2,z80pc,r1\r
        str r2,[cpucontext,#previouspc]\r
 .endif\r
-       ldrplb r0,[z80pc],#1\r
-       ldrpl pc,[opcodes,r0, lsl #2]\r
-       bmi z80_execute_end\r
+       ldrgtb r0,[z80pc],#1\r
+       ldrgt pc,[opcodes,r0, lsl #2]\r
+       ble z80_execute_end\r
 .endm\r
 \r
 .macro eatcycles cycs\r
@@ -1442,8 +1442,8 @@ DrZ80Run:
        PIC_LDR(opcodes, r0, MAIN_opcodes)\r
 \r
        cmp z80_icount,#0     ;@ irq might have used all cycles\r
-       ldrplb r0,[z80pc],#1\r
-       ldrpl pc,[opcodes,r0, lsl #2]\r
+       ldrgtb r0,[z80pc],#1\r
+       ldrgt pc,[opcodes,r0, lsl #2]\r
 \r
 \r
 z80_execute_end:\r
index a73c3fc..fb53c07 100644 (file)
@@ -70,7 +70,7 @@ switch (Opcode)
        OPXY(0x5c): // LD   E,HX\r
        OPXY(0x7c): // LD   A,HX\r
                zR8((Opcode >> 3) & 7) = data->B.H;\r
-               RET(5)\r
+               RET(4)\r
 \r
        OPXY(0x45): // LD   B,LX\r
        OPXY(0x4d): // LD   C,LX\r
@@ -78,7 +78,7 @@ switch (Opcode)
        OPXY(0x5d): // LD   E,LX\r
        OPXY(0x7d): // LD   A,LX\r
                zR8((Opcode >> 3) & 7) = data->B.L;\r
-               RET(5)\r
+               RET(4)\r
 \r
        OPXY(0x60): // LD   HX,B\r
        OPXY(0x61): // LD   HX,C\r
@@ -86,7 +86,7 @@ switch (Opcode)
        OPXY(0x63): // LD   HX,E\r
        OPXY(0x67): // LD   HX,A\r
                data->B.H = zR8(Opcode & 7);\r
-               RET(5)\r
+               RET(4)\r
 \r
        OPXY(0x68): // LD   LX,B\r
        OPXY(0x69): // LD   LX,C\r
@@ -94,15 +94,15 @@ switch (Opcode)
        OPXY(0x6b): // LD   LX,E\r
        OPXY(0x6f): // LD   LX,A\r
                data->B.L = zR8(Opcode & 7);\r
-               RET(5)\r
+               RET(4)\r
 \r
        OPXY(0x65): // LD   HX,LX\r
                data->B.H = data->B.L;\r
-               RET(5)\r
+               RET(4)\r
 \r
        OPXY(0x6c): // LD   LX,HX\r
                data->B.L = data->B.H;\r
-               RET(5)\r
+               RET(4)\r
 \r
        OPXY(0x06): // LD   B,#imm\r
        OPXY(0x0e): // LD   C,#imm\r
@@ -113,11 +113,11 @@ switch (Opcode)
 \r
        OPXY(0x26): // LD   HX,#imm\r
                data->B.H = READ_ARG();\r
-               RET(5)\r
+               RET(4)\r
 \r
        OPXY(0x2e): // LD   LX,#imm\r
                data->B.L = READ_ARG();\r
-               RET(5)\r
+               RET(4)\r
 \r
        OPXY(0x0a): // LD   A,(BC)\r
                goto OP_LOAD_A_mBC;\r
@@ -244,12 +244,12 @@ switch (Opcode)
        OPXY(0x24): // INC  HX\r
                data->B.H++;\r
                zF = (zF & CF) | SZHV_inc[data->B.H];\r
-               RET(5)\r
+               RET(4)\r
 \r
        OPXY(0x2c): // INC  LX\r
                data->B.L++;\r
                zF = (zF & CF) | SZHV_inc[data->B.L];\r
-               RET(5)\r
+               RET(4)\r
 \r
        OPXY(0x34): // INC  (IX+o)\r
                adr = data->W + (INT8)READ_ARG();\r
@@ -270,12 +270,12 @@ switch (Opcode)
        OPXY(0x25): // DEC  HX\r
                data->B.H--;\r
                zF = (zF & CF) | SZHV_dec[data->B.H];\r
-               RET(5)\r
+               RET(4)\r
 \r
        OPXY(0x2d): // DEC  LX\r
                data->B.L--;\r
                zF = (zF & CF) | SZHV_dec[data->B.L];\r
-               RET(5)\r
+               RET(4)\r
 \r
        OPXY(0x35): // DEC  (IX+o)\r
                adr = data->W + (INT8)READ_ARG();\r
@@ -298,12 +298,10 @@ switch (Opcode)
 \r
        OPXY(0x84): // ADD  A,HX\r
                val = data->B.H;\r
-               USE_CYCLES(1)\r
                goto OP_ADD;\r
 \r
        OPXY(0x85): // ADD  A,LX\r
                val = data->B.L;\r
-               USE_CYCLES(1)\r
                goto OP_ADD;\r
 \r
        OPXY(0x86): // ADD  A,(IX+o)\r
@@ -328,12 +326,10 @@ switch (Opcode)
 \r
        OPXY(0x8c): // ADC  A,HX\r
                val = data->B.H;\r
-               USE_CYCLES(1)\r
                goto OP_ADC;\r
 \r
        OPXY(0x8d): // ADC  A,LX\r
                val = data->B.L;\r
-               USE_CYCLES(1)\r
                goto OP_ADC;\r
 \r
        OPXY(0x8e): // ADC  A,(IX+o)\r
@@ -358,12 +354,10 @@ switch (Opcode)
 \r
        OPXY(0x94): // SUB  HX\r
                val = data->B.H;\r
-               USE_CYCLES(1)\r
                goto OP_SUB;\r
 \r
        OPXY(0x95): // SUB  LX\r
                val = data->B.L;\r
-               USE_CYCLES(1)\r
                goto OP_SUB;\r
 \r
        OPXY(0x96): // SUB  (IX+o)\r
@@ -388,12 +382,10 @@ switch (Opcode)
 \r
        OPXY(0x9c): // SBC  A,HX\r
                val = data->B.H;\r
-               USE_CYCLES(1)\r
                goto OP_SBC;\r
 \r
        OPXY(0x9d): // SBC  A,LX\r
                val = data->B.L;\r
-               USE_CYCLES(1)\r
                goto OP_SBC;\r
 \r
        OPXY(0x9e): // SBC  A,(IX+o)\r
@@ -418,12 +410,10 @@ switch (Opcode)
 \r
        OPXY(0xbc): // CP   HX\r
                val = data->B.H;\r
-               USE_CYCLES(1)\r
                goto OP_CP;\r
 \r
        OPXY(0xbd): // CP   LX\r
                val = data->B.L;\r
-               USE_CYCLES(1)\r
                goto OP_CP;\r
 \r
        OPXY(0xbe): // CP   (IX+o)\r
@@ -448,12 +438,10 @@ switch (Opcode)
 \r
        OPXY(0xa4): // AND  HX\r
                val = data->B.H;\r
-               USE_CYCLES(1)\r
                goto OP_AND;\r
 \r
        OPXY(0xa5): // AND  LX\r
                val = data->B.L;\r
-               USE_CYCLES(1)\r
                goto OP_AND;\r
 \r
        OPXY(0xa6): // AND  (IX+o)\r
@@ -478,12 +466,10 @@ switch (Opcode)
 \r
        OPXY(0xac): // XOR  HX\r
                val = data->B.H;\r
-               USE_CYCLES(1)\r
                goto OP_XOR;\r
 \r
        OPXY(0xad): // XOR  LX\r
                val = data->B.L;\r
-               USE_CYCLES(1)\r
                goto OP_XOR;\r
 \r
        OPXY(0xae): // XOR  (IX+o)\r
@@ -508,12 +494,10 @@ switch (Opcode)
 \r
        OPXY(0xb4): // OR   HX\r
                val = data->B.H;\r
-               USE_CYCLES(1)\r
                goto OP_OR;\r
 \r
        OPXY(0xb5): // OR   LX\r
                val = data->B.L;\r
-               USE_CYCLES(1)\r
                goto OP_OR;\r
 \r
        OPXY(0xb6): // OR   (IX+o)\r