Merge pull request #26 from Russell-S-Harper/development

Replacing DEC and HEX with NEG and INV.
This commit is contained in:
Russell-S-Harper 2018-09-01 10:41:53 -04:00 committed by GitHub
commit 168c4bad12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 26 deletions

View File

@ -241,7 +241,15 @@ _DCR .( ; DCR r 6r Rr <- Rr - 1.0 - decrement register
BNE _ADDI0X 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 LDA _F
AND #_MSK_T ; clear TST bits AND #_MSK_T ; clear TST bits
STA _F STA _F
@ -261,14 +269,6 @@ _3 ORA _F
RTS 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 _GETPQ .( ; sets X as p register and Y as q register, advances PC
LDY #0 LDY #0
LDA (_PC),Y ; get source registers 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, 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 .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, FN_XR .WORD _SET-1, _POP-1, _PSH-1, _EXC-1, _INR-1, _DCR-1, _NEG-1,
.WORD _DEC-1, _HEX-1, _ADD-1, _SUB-1, _MUL-1, _DIV-1, _MOD-1 .WORD _INV-1, _TST-1, _ADD-1, _SUB-1, _MUL-1, _DIV-1, _MOD-1
_END_CMN_DT _END_CMN_DT

View File

@ -7,9 +7,10 @@
; calculation. ; calculation.
; Largest value: $3fffffff or +1048575.999(5) ; Largest value: $3fffffff or +1048575.999(5)
; Plus one: $00000400
; Zero: $00000000
; Minus one: $fffffc00
; Smallest value: $c0000000 or -1048576.000(0) ; 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
; Instructions ; Instructions
@ -19,9 +20,9 @@
; EXC r 4r Rr <-> RS - exchange Rr with stack ; EXC r 4r Rr <-> RS - exchange Rr with stack
; INR r 5r Rr <- Rr + 1.0 - increment register ; INR r 5r Rr <- Rr + 1.0 - increment register
; DCR r 6r Rr <- Rr - 1.0 - decrement register ; DCR r 6r Rr <- Rr - 1.0 - decrement register
; TST r 7r F <- Rr <=> 0.0 - test register ; NEG r 7r Rr <- -Rr - negate register
; DEC r 8r Rr <- dec(Rr) - convert Rr from hex aabbccdd to decimal ######.### ; INV r 8r Rr <- 1.0 / Rr - multiplicative inverse of register
; HEX r 9r Rr <- hex(Rr) - convert Rr from decimal ######.### to hex aabbccdd ; TST r 9r F <- Rr <=> 0.0 - test register
; ADD r pq ar pq Rr <- Rp + Rq - addition ; ADD r pq ar pq Rr <- Rp + Rq - addition
; SUB r pq br pq Rr <- Rp - Rq - subtraction ; SUB r pq br pq Rr <- Rp - Rq - subtraction
; MUL r pq cr pq Rr <- Rp * Rq - multiplication ; MUL r pq cr pq Rr <- Rp * Rq - multiplication
@ -124,9 +125,9 @@ _POP_C = $30
_EXC_C = $40 _EXC_C = $40
_INR_C = $50 _INR_C = $50
_DCR_C = $60 _DCR_C = $60
_TST_C = $70 _NEG_C = $70
_DEC_C = $80 _INV_C = $80
_HEX_C = $90 _TST_C = $90
_ADD_C = $a0 _ADD_C = $a0
_SUB_C = $b0 _SUB_C = $b0
_MUL_C = $c0 _MUL_C = $c0

View File

@ -62,9 +62,9 @@
#define EXC(r) .BYTE _EXC_C + r #define EXC(r) .BYTE _EXC_C + r
#define INR(r) .BYTE _INR_C + r #define INR(r) .BYTE _INR_C + r
#define DCR(r) .BYTE _DCR_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 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 ADD(r, p, q) .BYTE _ADD_C + r, p * 16 + q
#define SUB(r, p, q) .BYTE _SUB_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 #define MUL(r, p, q) .BYTE _MUL_C + r, p * 16 + q

View File

@ -14,15 +14,14 @@ HDR(DEMO)
BRK BRK
BGN(FACTORIAL) BGN(FACTORIAL)
SET(R1, $10.4456) SET(R1, 10.4456)
SET(R2, 1) SET(R2, 1)
HEX(R1)
MOD(R3, R1, R2) MOD(R3, R1, R2)
SUB(R1, R1, R3) SUB(R1, R1, R3)
_1 TST(R1) _1 TST(R1)
BRZ(_2) BRZ(_2)
MUL(R2, R2, R1) MUL(R2, R2, R1)
DEC(R1) DCR(R1)
BRA(_1) BRA(_1)
_2 EXT(S0) _2 EXT(S0)
RTN RTN