-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathframes.asm
More file actions
98 lines (87 loc) · 3.1 KB
/
frames.asm
File metadata and controls
98 lines (87 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
; ************************************************************************************************
; ************************************************************************************************
;
; Name: frames.asm
; Purpose: Open/Close Frames on the BASIC stack
; Created: 1st October 2022
; Reviewed: 28th November 2022
; Author: Paul Robson ([email protected])
;
; ************************************************************************************************
; ************************************************************************************************
.section code
; ************************************************************************************************
;
; Open a frame. A contains the identifier in the upper nibl, and the bytes to claim is
; the lower nibble (includes frame marker) doubled
;
; ************************************************************************************************
StackOpen:
pha ; save frame byte
and #$0F ; the bytes to subtract.
asl a ; claim twice this for storage
;
eor #$FF ; 2's complement addition
sec ; so basically subtracting from
adc basicStack ; basicStack
sta basicStack
bcs _SONoBorrow
.debug
dec basicStack+1
lda basicStack+1 ; have we reached stack overflow
cmp #BasicStackBase >> 8
bcc _SOMemory
_SONoBorrow:
pla ; get marker back and write at TOS
sta (basicStack)
rts
_SOMemory:
.error_stack
; ************************************************************************************************
;
; Close a frame
;
; ************************************************************************************************
StackClose:
lda (basicStack) ; get TOS marker
and #$0F ; bytes to add back
asl a ; claim twice this.
adc basicStack ; add to the stack pointer.
sta basicStack
bcc _SCExit
inc basicStack+1
_SCExit:
rts
; ************************************************************************************************
;
; Pop all Locals, Check in Frame A, if not report Error X
;
; ************************************************************************************************
StackCheckFrame:
pha
_StackRemoveLocals:
lda (basicStack) ; check for local, keep popping them
cmp #STK_LOCALS+1 ; is the frame a local ? S or N are 1/0
bcs _SCNoLocal
jsr LocalPopValue ; restore the local value
bra _StackRemoveLocals ; gr round again
_SCNoLocal:
pla ; get the frame check.
eor (basicStack) ; xor with toS marker
and #$F0 ; check type bits
bne _SCFError ; different, we have structures mixed up
rts
_SCFError:
txa ; report error X
jmp ErrorHandler
.send code
; ************************************************************************************************
;
; Changes and Updates
;
; ************************************************************************************************
;
; Date Notes
; ==== =====
;
; ************************************************************************************************