Skip to content

Commit ceb026e

Browse files
committed
Small improvements.
1 parent c0f70bc commit ceb026e

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

sources/Z80.c

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -793,30 +793,31 @@ static Z_INLINE zuint8 m(Z80 *self, zuint8 offset, zuint8 value)
793793
return 16
794794

795795

796-
#define ADD_RR_NN(RR, NN) \
797-
zuint16 nn = NN; \
798-
zuint16 t = RR + nn; \
796+
#define ADD_16(lhs, rhs) \
797+
zuint16 n = rhs; \
798+
zuint16 t = lhs + n; \
799799
\
800800
FLAGS = F_SZP | /* SF, ZF, PF unchanged */ \
801801
((t >> 8) & YXF) | /* YF = high-Y; XF = high-X */ \
802-
(((zuint16)(RR ^ nn ^ t) >> 8) & HF) | /* HF = high-half-carry */ \
803-
((zuint32)RR + nn > 65535); /* CF = carry */ \
802+
(((zuint16)(lhs ^ n ^ t) >> 8) & HF) | /* HF = high-half-carry */ \
803+
((zuint32)lhs + n > 65535); /* CF = carry */ \
804804
/* NF = 0 */ \
805-
MEMPTR = RR + 1; \
806-
RR = t
805+
MEMPTR = lhs + 1; \
806+
lhs = t
807807

808808

809-
#define ADC_SBC_HL_SS(operator, pf_test_rhs, cf_test, set_nf) \
809+
#define ADC_SBC_HL_SS(operator, pf_overflow_rhs, cf_test, set_nf) \
810810
zuint8 fc = F_C; \
811811
zuint16 ss = SS1; \
812812
zuint16 t = HL operator ss operator fc; \
813813
\
814814
FLAGS = (zuint8)( \
815815
((t >> 8) & SYXF) /* SF = sign; YF = high-Y; XF = high-X */ \
816816
| ZF_ZERO(t) /* ZF = zero */ \
817-
/* HF = high-half-carry (adc), high-half-borrow (sbc) */ \
817+
/* HF = high-half-carry (adc), high-half-borrow (sbc) */ \
818818
| (((zuint16)(HL ^ ss ^ t) >> 8) & HF) \
819-
| PF_OVERFLOW(16, t, HL, pf_test_rhs) /* PF = overflow */ \
819+
/* PF = overflow */ \
820+
| PF_OVERFLOW(16, t, HL, pf_overflow_rhs) \
820821
| ((zuint32)cf_test) /* CF = carry (adc), borrow (sbc) */ \
821822
set_nf); /* NF = 0 (adc), 1 (sbc) */ \
822823
\
@@ -907,23 +908,23 @@ static Z_INLINE zuint8 m(Z80 *self, zuint8 offset, zuint8 value)
907908

908909

909910
#define INX(hl_operator, memptr_operator) \
910-
zuint8 in = IN(BC); \
911-
zuint t = (zuint)in + (zuint8)(C memptr_operator 1); \
911+
zuint8 io = IN(BC); \
912+
zuint t = (zuint)io + (zuint8)(C memptr_operator 1); \
912913
\
913-
WRITE(HL hl_operator, in); \
914+
WRITE(HL hl_operator, io); \
914915
MEMPTR = BC memptr_operator 1; \
915916
B--; \
916-
INX_OUTX(in)
917+
INX_OUTX(io)
917918

918919

919920
#define OUTX(hl_operator, memptr_operator) \
920-
zuint8 out = READ(HL hl_operator); \
921-
zuint t = (zuint)out + L; \
921+
zuint8 io = READ(HL hl_operator); \
922+
zuint t = (zuint)io + L; \
922923
\
923924
B--; \
924925
MEMPTR = BC memptr_operator 1; \
925-
OUT(BC, out); \
926-
INX_OUTX(out)
926+
OUT(BC, io); \
927+
INX_OUTX(io)
927928

928929

929930
/*-----------------------------------------------------------------------------.
@@ -1460,10 +1461,10 @@ INSN(ei)
14601461
| dec XY <--XY--><--2B--> ........ 10:46 |
14611462
'==================================================*/
14621463

1463-
INSN(add_hl_SS) {ADD_RR_NN(HL, SS0); PC++; return 11;}
1464+
INSN(add_hl_SS) {ADD_16(HL, SS0); PC++; return 11;}
14641465
INSN(adc_hl_SS) {ADC_SBC_HL_SS(+, ~ss, ss + fc + HL > 65535, Z_EMPTY);}
14651466
INSN(sbc_hl_SS) {ADC_SBC_HL_SS(-, ss, ss + fc > HL, | NF );}
1466-
INSN(add_XY_WW) {ADD_RR_NN(XY, WW); PC += 2; return 11;}
1467+
INSN(add_XY_WW) {ADD_16(XY, WW); PC += 2; return 11;}
14671468
INSN(inc_SS ) {Q_0 (SS0)++; PC++; return 6;}
14681469
INSN(inc_XY ) {Q_0 XY++; PC += 2; return 6;}
14691470
INSN(dec_SS ) {Q_0 (SS0)--; PC++; return 6;}

0 commit comments

Comments
 (0)