From b73e1a5f7a0061b6165cf6b32bcbc1bbdfc9fc57 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Wed, 15 Apr 2020 12:20:09 -0400 Subject: [PATCH] z80a: invert the meaning of IFZ, IFNZ, IFC, IFNC, It is much less confusing when "IFZ," means "If Z is set, continue into IF, else, jump to THEN,". --- forth/boot.fs | 2 +- forth/z80a.fs | 8 ++++---- forth/z80c.fs | 17 +++++++++-------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/forth/boot.fs b/forth/boot.fs index 0ecd88d..d5d99f3 100644 --- a/forth/boot.fs +++ b/forth/boot.fs @@ -201,7 +201,7 @@ L4 FSET L3 FSET ( loopend ) ( HL is prev field's addr. Is offset zero? ) A D LDrr, E ORr, - IFZ, ( noprev ) + IFNZ, ( noprev ) ( get absolute addr from offset ) ( carry cleared from "or e" ) DE SBCHLss, diff --git a/forth/z80a.fs b/forth/z80a.fs index 0318d26..e095fc2 100644 --- a/forth/z80a.fs +++ b/forth/z80a.fs @@ -372,10 +372,10 @@ : BWR @ AGAIN, ; ( same as BSET, but we need to write a placeholder ) : FJR, PC 0 A, ; -: IFZ, JRZ, FJR, ; -: IFNZ, JRNZ, FJR, ; -: IFC, JRC, FJR, ; -: IFNC, JRNC, FJR, ; +: IFZ, JRNZ, FJR, ; +: IFNZ, JRZ, FJR, ; +: IFC, JRNC, FJR, ; +: IFNC, JRC, FJR, ; : THEN, DUP PC ( l l pc ) -^ 1 - ( l off ) diff --git a/forth/z80c.fs b/forth/z80c.fs index 7322307..200698c 100644 --- a/forth/z80c.fs +++ b/forth/z80c.fs @@ -149,10 +149,10 @@ CODE NOT A L LDrr, H ORr, HL 0 LDddnn, - IFNZ, ( skip ) + IFZ, ( false, make 1 ) HL INCss, - THEN, ( skip ) + THEN, HL PUSHqq, ;CODE @@ -209,10 +209,10 @@ CODE /MOD RLA, HL ADCHLss, DE SBCHLss, - IFNC, ( skip ) + IFC, DE ADDHLss, C DECr, - THEN, ( skip ) + THEN, DJNZ, AGAIN, ( loop ) B A LDrr, HL PUSHqq, @@ -340,10 +340,10 @@ CODE CMP chkPS, DE SUBHLss, BC 0 LDddnn, - IFZ, + IFNZ, ( not equal ) BC INCss, - IFC, + IFNC, ( < ) BC DECss, BC DECss, @@ -359,13 +359,14 @@ CODE _find chkPS, ( 3 == find ) 3 CALLnn, - IFZ, ( found ) + IFNZ, ( not found ) HL PUSHqq, DE 0 LDddnn, DE PUSHqq, JPNEXT, - THEN, ( found ) + THEN, + ( found ) DE PUSHqq, DE 1 LDddnn, DE PUSHqq,