diff --git a/common/common.asm b/common/common.asm index 45219b9..08b986a 100644 --- a/common/common.asm +++ b/common/common.asm @@ -242,6 +242,22 @@ _DCR .( ; DCR r 6r Rr <- Rr - 1.0 - decrement register .) _TST .( ; TST r 7r F <- Rr <=> 0.0 - test register + LDA _F + AND #_MSK_T ; clear TST bits + STA _F + LDA _R0+3,X ; check highest byte + BMI _1 ; is negative + ORA _R0+2,X ; could be positive or zero, OR with all other bytes + ORA _R0+1,X + ORA _R0,X + BNE _2 ; is positive + LDA #_F_Z ; set zero flag + BNE _3 +_1 LDA #_F_N ; set negative flag + BNE _3 +_2 LDA #_F_P ; set positive flag +_3 ORA _F + STA _F RTS .) diff --git a/common/common.h b/common/common.h index 432002c..08e464e 100644 --- a/common/common.h +++ b/common/common.h @@ -138,4 +138,7 @@ _MNS_1 = %11111100 ; i.e. the $FC part of $FFFFFC00 _MSK_O = %11000000 ; mask for overflow +; mask for TST +_MSK_T = (_F_Z + _F_P + _F_N)^$FF + #endif /* __COMMON_H */ diff --git a/common/page6.src b/common/page6.src index 721a850..cb6cdbb 100644 --- a/common/page6.src +++ b/common/page6.src @@ -15,6 +15,9 @@ HDR(DEMO) DCR(R3) INR(R0) DCR(R1) + TST(R4) + TST(R2) + TST(R3) ESC BRK