Debian Codegraph @

test/declare_var_mac.asm

raw
1 ;
2 ; the purpose of this macro is to declare a global variable without need to know its exact location
3 ; the location is automatically derived from its predecessor 'next_var' which gets redefined at every
4 ; occurence. This way one can copy-paste, comment-out or conditional-define variable declarations
5 ; without worrying. Memory usage will be always as compact as possible
6 ;
7 .PROCESSOR 6803
8
9 #ifnconst RAM_START
10 RAM_START .EQU 0x80
11 #endif
12
13 .mac declare_var ; {name},{size}
14 {1} .EQU next_var
15 next_var .set ({1}+{2})
16 .endm
17
18 next_var .set RAM_START
19
20 declare_var first, 1 ; declare variable name "first" 8bit
21 declare_var second, 2 ; declare variable name "second" 16bit
22 #if (RAM_START == 0x60)
23 declare_var extra, 3 ; in case of special define, include variable extra 24bit
24 #endif
25 declare_var third, 4 ; declare variable name "third" 32bit
26
27 .ORG 0x8000
28
29 example_code:
30 ldx #third
31 txs
32 ldaa first
33 staa ,X
34 #if (RAM_START == 0x60)
35 staa.w extra
36 #endif
37