mirror of
https://github.com/Russell-S-Harper/COMMON.git
synced 2025-02-20 23:29:05 +00:00
Merge pull request #30 from Russell-S-Harper/development
Adding all branch instructions (except BRS).
This commit is contained in:
commit
b28e67eb4b
@ -248,9 +248,9 @@ _ADPI0X .( ; add value pointed by I0 to register indexed by X
|
||||
BEQ _1
|
||||
EOR #_MSK_O
|
||||
BNE _2 ; existing overflow, skip decrement operation
|
||||
_1 CLC ; adding RD
|
||||
LDY #0
|
||||
_1 LDY #0 ; adding RD
|
||||
LDA (_I0),Y
|
||||
CLC
|
||||
ADC _R0,X
|
||||
STA _R0,X
|
||||
INY
|
||||
@ -400,8 +400,8 @@ _ADD .( ; ADD r pq ar pq Rr <- Rp + Rq - addition
|
||||
TXA
|
||||
PHA ; save r register for later
|
||||
JSR _GETPQF
|
||||
CLC ; set I0 to Rp + Rq
|
||||
LDA _R0,X
|
||||
LDA _R0,X ; set I0 to Rp + Rq
|
||||
CLC
|
||||
ADC _R0,Y
|
||||
STA _I0
|
||||
LDA _R0+1,X
|
||||
@ -588,8 +588,8 @@ _3 LSR _I1+3 ; get lowest bit of operand
|
||||
ROR _I1+1
|
||||
ROR _I1
|
||||
BCC _4 ; skip adding in product if bit is zero
|
||||
CLC
|
||||
LDA _I3 ; add in p register
|
||||
CLC
|
||||
ADC _I0
|
||||
STA _I3
|
||||
LDA _I3+1
|
||||
@ -844,20 +844,38 @@ _BRS .( ; BRS xxyy 02 yy xx PC <- PC + xxyy - branch to subroutine
|
||||
.)
|
||||
|
||||
_BRA .( ; BRA xxyy 03 yy xx PC <- PC + xxyy - branch always
|
||||
LDY #1 ; save the offset
|
||||
LDA (_PC), Y
|
||||
PHA
|
||||
DEY
|
||||
LDA (_PC), Y
|
||||
PHA
|
||||
LDA #2 ; update PC by the length of the branch address
|
||||
CLC
|
||||
ADC _PCL
|
||||
STA _PCL
|
||||
BNE _1
|
||||
INC _PCH
|
||||
_1 PLA ; pull the low byte
|
||||
CLC
|
||||
ADC _PCL
|
||||
STA _PCL
|
||||
PLA ; pull the high byte
|
||||
ADC _PCH
|
||||
STA _PCH
|
||||
RTS
|
||||
.)
|
||||
|
||||
_BRX .( ; generic branch testing
|
||||
AND _F ; check the bit
|
||||
BNE _BRA ; if set, branch
|
||||
CLC ; not set, advance the program counter over the xxyy offset
|
||||
LDA #2
|
||||
LDA #2 ; not set, advance the program counter over the xxyy offset
|
||||
CLC
|
||||
ADC _PCL
|
||||
STA _PCL
|
||||
LDA #0
|
||||
ADC _PCH
|
||||
STA _PCH
|
||||
RTS
|
||||
BNE _1
|
||||
INC _PCH
|
||||
_1 RTS
|
||||
.)
|
||||
|
||||
_BRE .( ; BRE xxyy 04 yy xx PC <- PC + xxyy - branch if Rp = Rq (after CMP)
|
||||
|
@ -6,15 +6,12 @@
|
||||
|
||||
HDR(DEMO)
|
||||
CMN
|
||||
LDD(R0, PLS_1)
|
||||
LDD(R1, MNS_1)
|
||||
SVD(R1, SVD_T)
|
||||
LDD(R2, SVD_T)
|
||||
BRA(FACTORIAL)
|
||||
ESC
|
||||
BRK
|
||||
|
||||
BGN(FACTORIAL)
|
||||
SET(R1, 10.4456)
|
||||
SET(R1, 9.4662)
|
||||
SET(R2, 1)
|
||||
MOD(R3, R1, R2)
|
||||
SUB(R1, R1, R3)
|
||||
@ -23,8 +20,8 @@ _1 TST(R1)
|
||||
MUL(R2, R2, R1)
|
||||
DCR(R1)
|
||||
BRA(_1)
|
||||
_2 EXT(S0)
|
||||
RTN
|
||||
_2 ESC
|
||||
BRK
|
||||
END(FACTORIAL)
|
||||
|
||||
END(DEMO)
|
||||
|
Loading…
x
Reference in New Issue
Block a user