From 794550eee5dad3a2f7ee1b271b773f91500fd5d7 Mon Sep 17 00:00:00 2001 From: Russell-S-Harper Date: Sat, 1 Sep 2018 10:40:57 -0400 Subject: [PATCH] Replacing DEC and HEX with NEG and INV. --- common/common.asm | 22 +++++++++++----------- common/common.h | 21 +++++++++++---------- common/macros.h | 4 ++-- common/page6.src | 5 ++--- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/common/common.asm b/common/common.asm index 1600911..8bd4165 100644 --- a/common/common.asm +++ b/common/common.asm @@ -241,7 +241,15 @@ _DCR .( ; DCR r 6r Rr <- Rr - 1.0 - decrement register BNE _ADDI0X .) -_TST .( ; TST r 7r F <- Rr <=> 0.0 - test register +_NEG .( ; NEG r 7r Rr <- -Rr - negate register + RTS +.) + +_INV .( ; INV r 8r Rr <- 1.0 / Rr - multiplicative inverse of register + RTS +.) + +_TST .( ; TST r 9r F <- Rr <=> 0.0 - test register LDA _F AND #_MSK_T ; clear TST bits STA _F @@ -261,14 +269,6 @@ _3 ORA _F RTS .) -_DEC .( ; DEC r 8r Rr <- dec(Rr) - convert Rr from hex aabbccdd to decimal ######.### - RTS -.) - -_HEX .( ; HEX r 9r Rr <- hex(Rr) - convert Rr from decimal ######.### to hex aabbccdd - RTS -.) - _GETPQ .( ; sets X as p register and Y as q register, advances PC LDY #0 LDA (_PC),Y ; get source registers @@ -936,8 +936,8 @@ _END_CMN_CD FN_0X .WORD _ESC-1, _RTN-1, _BRS-1, _BRA-1, _BRE-1, _BRG-1, _BRL-1, _BRZ-1, .WORD _BRP-1, _BRN-1, _BRO-1, _BRU-1, _CPR-1, _LDI-1, _SVI-1, _CMR-1 -FN_XR .WORD _SET-1, _POP-1, _PSH-1, _EXC-1, _INR-1, _DCR-1, _TST-1, - .WORD _DEC-1, _HEX-1, _ADD-1, _SUB-1, _MUL-1, _DIV-1, _MOD-1 +FN_XR .WORD _SET-1, _POP-1, _PSH-1, _EXC-1, _INR-1, _DCR-1, _NEG-1, + .WORD _INV-1, _TST-1, _ADD-1, _SUB-1, _MUL-1, _DIV-1, _MOD-1 _END_CMN_DT diff --git a/common/common.h b/common/common.h index 9330ebd..0db4f6e 100644 --- a/common/common.h +++ b/common/common.h @@ -6,10 +6,11 @@ ; to be able to recognize an overflow/underflow situation, rescale the arguments, and repeat the ; calculation. -; Largest value: $3fffffff or +1048575.999(5) -; Smallest value: $c0000000 or -1048576.000(0) -; Largest value for DEC/HEX: $3d08ffff or +999999.999 -; Smallest value for DEC/HEX: $c2f70001 or -999999.999 +; Largest value: $3fffffff or +1048575.999(5) +; Plus one: $00000400 +; Zero: $00000000 +; Minus one: $fffffc00 +; Smallest value: $c0000000 or -1048576.000(0) ; Instructions @@ -19,9 +20,9 @@ ; EXC r 4r Rr <-> RS - exchange Rr with stack ; INR r 5r Rr <- Rr + 1.0 - increment register ; DCR r 6r Rr <- Rr - 1.0 - decrement register -; TST r 7r F <- Rr <=> 0.0 - test register -; DEC r 8r Rr <- dec(Rr) - convert Rr from hex aabbccdd to decimal ######.### -; HEX r 9r Rr <- hex(Rr) - convert Rr from decimal ######.### to hex aabbccdd +; NEG r 7r Rr <- -Rr - negate register +; INV r 8r Rr <- 1.0 / Rr - multiplicative inverse of register +; TST r 9r F <- Rr <=> 0.0 - test register ; ADD r pq ar pq Rr <- Rp + Rq - addition ; SUB r pq br pq Rr <- Rp - Rq - subtraction ; MUL r pq cr pq Rr <- Rp * Rq - multiplication @@ -124,9 +125,9 @@ _POP_C = $30 _EXC_C = $40 _INR_C = $50 _DCR_C = $60 -_TST_C = $70 -_DEC_C = $80 -_HEX_C = $90 +_NEG_C = $70 +_INV_C = $80 +_TST_C = $90 _ADD_C = $a0 _SUB_C = $b0 _MUL_C = $c0 diff --git a/common/macros.h b/common/macros.h index aef0d60..0dd1a30 100644 --- a/common/macros.h +++ b/common/macros.h @@ -62,9 +62,9 @@ #define EXC(r) .BYTE _EXC_C + r #define INR(r) .BYTE _INR_C + r #define DCR(r) .BYTE _DCR_C + r +#define NEG(r) .BYTE _NEG_C + r +#define INV(r) .BYTE _INV_C + r #define TST(r) .BYTE _TST_C + r -#define DEC(r) .BYTE _DEC_C + r -#define HEX(r) .BYTE _HEX_C + r #define ADD(r, p, q) .BYTE _ADD_C + r, p * 16 + q #define SUB(r, p, q) .BYTE _SUB_C + r, p * 16 + q #define MUL(r, p, q) .BYTE _MUL_C + r, p * 16 + q diff --git a/common/page6.src b/common/page6.src index 9b2a338..e767536 100644 --- a/common/page6.src +++ b/common/page6.src @@ -14,15 +14,14 @@ HDR(DEMO) BRK BGN(FACTORIAL) - SET(R1, $10.4456) + SET(R1, 10.4456) SET(R2, 1) - HEX(R1) MOD(R3, R1, R2) SUB(R1, R1, R3) _1 TST(R1) BRZ(_2) MUL(R2, R2, R1) - DEC(R1) + DCR(R1) BRA(_1) _2 EXT(S0) RTN