| 1 |
;ACME 0.97 |
| 2 |
!set split_cache = [] ; start every pass with an empty cache |
| 3 |
!ifdef lib_6502_split_a !eof |
| 4 |
lib_6502_split_a = 1 |
| 5 |
|
| 6 |
!macro split_lo @args { |
| 7 |
+split_putbytes 0, @args |
| 8 |
!set split_cache = split_cache + @args |
| 9 |
} |
| 10 |
!macro split_hi @args { |
| 11 |
+split_putbytes 8, @args |
| 12 |
!set split_cache = split_cache + @args |
| 13 |
} |
| 14 |
!macro split_lo { |
| 15 |
+split_putbytes 0, split_cache |
| 16 |
!set split_cache = [] |
| 17 |
} |
| 18 |
!macro split_hi { |
| 19 |
+split_putbytes 8, split_cache |
| 20 |
!set split_cache = [] |
| 21 |
} |
| 22 |
!macro split_putbytes @shift, @bytes { |
| 23 |
!if len(@bytes) { |
| 24 |
!for @idx, 0, len(@bytes) - 1 { |
| 25 |
!by (@bytes[@idx] >> @shift) & $ff |
| 26 |
} |
| 27 |
} |
| 28 |
} |
| 29 |
!eof |
| 30 |
; these macros can be used to split address tables in two separate |
| 31 |
; parts for high- and low-bytes. example: |
| 32 |
|
| 33 |
table_hi |
| 34 |
+split_hi [$0123, $4567, $89ab, $cdef] ; writes $01, $45, $89, $cd |
| 35 |
+split_hi [$1122, $3344, $5566, $7788] ; writes $11, $33, $55, $77 |
| 36 |
table_lo |
| 37 |
+split_lo ; writes $23, $67, $ab, $ef, $22, $44, $66, $88 from cache |
| 38 |
|
| 39 |
; of course you can also put the low bytes first: |
| 40 |
|
| 41 |
table_lo |
| 42 |
+split_lo [$0123, $4567, $89ab, $cdef] ; writes $23, $67, $ab, $ef |
| 43 |
+split_lo [$1122, $3344, $5566, $7788] ; writes $22, $44, $66, $88 |
| 44 |
table_hi |
| 45 |
+split_hi ; writes $01, $45, $89, $cd, $11, $33, $55, $77 from cache |