mirror of
https://github.com/Russell-S-Harper/COMMON.git
synced 2024-11-28 05:51:09 +00:00
Merge pull request #7 from Russell-S-Harper/development
Adding protection for PSH and POP.
This commit is contained in:
commit
866c9e820d
@ -116,27 +116,12 @@ _SET .( ; SET r aabbcc.dd 1r dd cc bb aa Rr <- aabbcc.dd - set register
|
|||||||
_1 RTS ; done
|
_1 RTS ; done
|
||||||
.)
|
.)
|
||||||
|
|
||||||
_POP .( ; POP r 2r Rr <- RS - pop from stack
|
_PSH .( ; PSH r 2r RS <- Rr - push onto stack
|
||||||
LDY _RSI ; get register stack index
|
LDY _RSI ; get register stack index
|
||||||
DEY ; transfer four bytes over
|
CPY #_RSS ; compare against limit
|
||||||
LDA _RS,Y
|
BCC _1 ; still room, all okay
|
||||||
STA _R0+3,X
|
BRK ; next push will cause a stack overflow, abort and call exception handler (TODO)
|
||||||
DEY
|
_1 LDA _R0,X ; transfer four bytes over
|
||||||
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
|
|
||||||
LDY _RSI ; get register stack index
|
|
||||||
LDA _R0,X ; transfer four bytes over
|
|
||||||
STA _RS,Y
|
STA _RS,Y
|
||||||
INY
|
INY
|
||||||
LDA _R0+1,X
|
LDA _R0+1,X
|
||||||
@ -152,6 +137,26 @@ _PSH .( ; PSH r 3r RS <- Rr - push onto stack
|
|||||||
RTS
|
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
|
_EXC .( ; EXC r 4r Rr <-> RS - exchange Rr with stack
|
||||||
LDY _RSI ; RS to RD
|
LDY _RSI ; RS to RD
|
||||||
LDA _RS-1,Y
|
LDA _RS-1,Y
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
; Instructions
|
; Instructions
|
||||||
|
|
||||||
; SET r aabbcc.dd 1r dd cc bb aa Rr <- aabbccdd - set register
|
; SET r aabbcc.dd 1r dd cc bb aa Rr <- aabbccdd - set register
|
||||||
; POP r 2r Rr <- RS - pop from stack
|
; PSH r 2r RS <- Rr - push onto stack
|
||||||
; PSH r 3r RS <- Rr - push onto stack
|
; POP r 3r Rr <- RS - pop from stack
|
||||||
; 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
|
||||||
@ -89,11 +89,12 @@ _IDX = _ACC + 1 ; saved index X to restore
|
|||||||
_IDY = _IDX + 1 ; saved index Y to restore
|
_IDY = _IDX + 1 ; saved index Y to restore
|
||||||
_PS = _IDY + 1 ; saved processor status to restore
|
_PS = _IDY + 1 ; saved processor status to restore
|
||||||
|
|
||||||
; 256 bytes of page two
|
; 224 bytes of page two
|
||||||
_RS = $200 ; register stack
|
_RS = $200 ; register stack
|
||||||
|
_RSS = (FN_FX - _RS) ; register stack size
|
||||||
|
|
||||||
; 64 bytes of page three
|
; last 32 bytes of page two
|
||||||
FN_FX = $300 ; list of system and user functions
|
FN_FX = $2E0 ; list of system and user functions
|
||||||
|
|
||||||
; function constants
|
; function constants
|
||||||
_ESC_C = $00
|
_ESC_C = $00
|
||||||
@ -114,8 +115,8 @@ _SVI_C = $0e
|
|||||||
_CMR_C = $0f
|
_CMR_C = $0f
|
||||||
|
|
||||||
_SET_C = $10
|
_SET_C = $10
|
||||||
_POP_C = $20
|
_PSH_C = $20
|
||||||
_PSH_C = $30
|
_POP_C = $30
|
||||||
_EXC_C = $40
|
_EXC_C = $40
|
||||||
_INR_C = $50
|
_INR_C = $50
|
||||||
_DCR_C = $60
|
_DCR_C = $60
|
||||||
|
@ -75,8 +75,8 @@
|
|||||||
#define SVI(p, q) .BYTE _SVI_C, p * 16 + q
|
#define SVI(p, q) .BYTE _SVI_C, p * 16 + q
|
||||||
#define CMR(p, q) .BYTE _CMR_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 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 PSH(r) .BYTE _PSH_C + r
|
||||||
|
#define POP(r) .BYTE _POP_C + r
|
||||||
#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
|
||||||
|
Loading…
Reference in New Issue
Block a user