Assigning PSH before POP.

This commit is contained in:
Russell-S-Harper 2018-08-07 20:19:52 -04:00
parent fe7bfb12e6
commit bb3b6cd683
3 changed files with 26 additions and 26 deletions

View File

@ -116,27 +116,7 @@ _SET .( ; SET r aabbcc.dd 1r dd cc bb aa Rr <- aabbcc.dd - set register
_1 RTS ; done
.)
_POP .( ; POP r 2r Rr <- RS - pop from stack
LDY _RSI ; get register stack index
BNE _1 ; all good, something can be popped off the stack
BRK ; next pop will cause a stack underflow, abort and call exception handler (TODO)
_1 DEY ; transfer four bytes over
LDA _RS,Y
STA _R0+3,X
DEY
LDA _RS,Y
STA _R0+2,X
DEY
LDA _RS,Y
STA _R0+1,X
DEY
LDA _RS,Y
STA _R0,X
STY _RSI ; update register stack index
RTS
.)
_PSH .( ; PSH r 3r RS <- Rr - push onto stack
_PSH .( ; PSH r 2r RS <- Rr - push onto stack
LDY _RSI ; get register stack index
CPY #_RSS ; compare against limit
BCC _1 ; still room, all okay
@ -157,6 +137,26 @@ _1 LDA _R0,X ; transfer four bytes over
RTS
.)
_POP .( ; POP r 3r Rr <- RS - pop from stack
LDY _RSI ; get register stack index
BNE _1 ; all good, something can be popped off the stack
BRK ; next pop will cause a stack underflow, abort and call exception handler (TODO)
_1 DEY ; transfer four bytes over
LDA _RS,Y
STA _R0+3,X
DEY
LDA _RS,Y
STA _R0+2,X
DEY
LDA _RS,Y
STA _R0+1,X
DEY
LDA _RS,Y
STA _R0,X
STY _RSI ; update register stack index
RTS
.)
_EXC .( ; EXC r 4r Rr <-> RS - exchange Rr with stack
LDY _RSI ; RS to RD
LDA _RS-1,Y

View File

@ -14,8 +14,8 @@
; Instructions
; SET r aabbcc.dd 1r dd cc bb aa Rr <- aabbccdd - set register
; POP r 2r Rr <- RS - pop from stack
; PSH r 3r RS <- Rr - push onto stack
; PSH r 2r RS <- Rr - push onto stack
; POP r 3r Rr <- RS - pop from stack
; 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
@ -115,8 +115,8 @@ _SVI_C = $0e
_CMR_C = $0f
_SET_C = $10
_POP_C = $20
_PSH_C = $30
_PSH_C = $20
_POP_C = $30
_EXC_C = $40
_INR_C = $50
_DCR_C = $60

View File

@ -75,8 +75,8 @@
#define SVI(p, q) .BYTE _SVI_C, p * 16 + q
#define CMR(p, q) .BYTE _CMR_C, p * 16 + q
#define SET(r, v) .BYTE _SET_C + r, _SET_V(#v)
#define POP(r) .BYTE _POP_C + r
#define PSH(r) .BYTE _PSH_C + r
#define POP(r) .BYTE _POP_C + r
#define EXC(r) .BYTE _EXC_C + r
#define INR(r) .BYTE _INR_C + r
#define DCR(r) .BYTE _DCR_C + r