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
.EQU status_reg=252
.EQU in_dev=253
.EQU out_dev=255
.EQU zero_bit=0
.EQU carry_bit=1
COPYLR stack_offset head_ptr
start_program:
COPYLR f_add f_custom_ins
CALL f_binary_unary
HALT
f_pop:
COPYRA head_ptr
CBR carry_bit status_reg
SUBLA stack
BCRSC zero_bit status_reg
JUMP f_stack_error
DECR head_ptr
COPYIR head_ptr head_val
RETURN

f_add:
COPYRA head_val_1
CBR carry_bit status_reg
ADDRA head_val
COPYAR head_val
RETURN
f_custom_ins:
.DB 0
head_val:
.DB 0
head_val_1:
.DB 0
RETURN
f_binary_unary:
CALL f_pop
COPYRR head_val head_val_1
f_unary:
CALL f_pop
CALLI f_custom_ins
CALL f_push
RETURN
f_stack_error:
COPYLR 0xFF out_dev
JUMP f_stack_error
f_push:
COPYRA head_ptr
SUBLA 253
BCRSC zero_bit status_reg
JUMP f_stack_error
COPYRI head_val head_ptr
INCR head_ptr
RETURN

head_ptr:
.DB 0
stack:
.DB 2,3
stack_offset: