-
Notifications
You must be signed in to change notification settings - Fork 0
/
MACROS_MISC.inc
90 lines (65 loc) · 2.5 KB
/
MACROS_MISC.inc
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
;--------------------------------------------------------------------------------------------
.macro HALT
Z Z (-1) ; Jump to -1 which halts execution
.endm
;--------------------------------------------------------------------------------------------
.macro OUT addr
addr (-1) ; Writing to address -1 will output the value to screen
.endm
;--------------------------------------------------------------------------------------------
.macro IN addr
(-1) addr ; Reading from address -1 will input a value from keyboard
.endm
;--------------------------------------------------------------------------------------------
.macro CTRLC addr
(-2) addr ; Reading from address -2 return the status of the Ctrl-C key
.endm
;--------------------------------------------------------------------------------------------
.macro CLR addr
addr addr
.endm
;--------------------------------------------------------------------------------------------
.macro SET1 addr
CLR addr
INC addr
.endm
;--------------------------------------------------------------------------------------------
.macro INC addr
MINUS1 addr
.endm
;--------------------------------------------------------------------------------------------
.macro DEC addr
CONST_1 addr
.endm
;--------------------------------------------------------------------------------------------
.macro NEG src ; Negate src
CLR tmpA
src tmpA
MOV tmpA src
.endm
;--------------------------------------------------------------------------------------------
.macro SUB a b ; Subtract a from b and store in b
a b
.endm
;--------------------------------------------------------------------------------------------
.macro ADD a b ; Add a to b and store in b
CLR T
a T ; Z = -a
T b ; b = b - Z = b - -a = b + a
.endm
;--------------------------------------------------------------------------------------------
.macro TOGGLE01 dst
Z dst @zorm ; If 0 (or negative)
CLR dst
JMP @done
@zorm: CLR dst
INC dst
@done:
.endm
;--------------------------------------------------------------------------------------------
.macro MOV src dest ; Copy value at src to dest
CLR dest
CLR tMov
src tMov
tMov dest
.endm