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

Adding all branch instructions (except BRS).
This commit is contained in:
Russell-S-Harper 2018-09-11 20:41:17 -04:00 committed by GitHub
commit b28e67eb4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 21 deletions

View File

@ -43,7 +43,7 @@ _3 TAX ; save operand for later
ASL ; shift to get offset to register
ASL
TAX ; back to index
RTS ; "return" to routine
RTS ; "return" to routine
_4 TXA ; get operand
ASL ; shift to get offset to 0X instructions
TAY
@ -52,7 +52,7 @@ _4 TXA ; get operand
LDA FN_0X,Y ; push low address
PHA
TXA ; restore operand
RTS ; "return" to routine
RTS ; "return" to routine
_5 TXA ; get operand
AND #$F ; mask to get index
ASL ; shift to get offset to FX instructions
@ -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)

View File

@ -9,7 +9,7 @@
; Largest value: $3fffffff or +1048575.999(5)
; Plus one: $00000400
; Zero: $00000000
; Minus one: $fffffc00
; Minus one: $fffffc00
; Smallest value: $c0000000 or -1048576.000(0)
; Instructions

View File

@ -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)