61 lines
1.8 KiB
NASM
61 lines
1.8 KiB
NASM
;
|
|
; Macros for common tasks
|
|
;
|
|
|
|
BasicStub .macro entrypoint, lineno=10, align=16
|
|
.section stub
|
|
.word (+), \lineno
|
|
.null BTOK_SYS, format("%d", \entrypoint)
|
|
+ .word 0
|
|
.if \align > 0
|
|
.align \align
|
|
.endif
|
|
.endsection
|
|
.endmacro
|
|
|
|
FillMem .macro ptr, value, sz
|
|
.for blocksz := 256, ((\sz) % blocksz) > 0, blocksz -= 1
|
|
.endfor
|
|
blocks = (\sz) / blocksz
|
|
|
|
lda #\value
|
|
.if (\value) != 0
|
|
ldx #0
|
|
.else
|
|
tax
|
|
.endif
|
|
- .for b := 0, b < blocks, b += 1
|
|
sta (\ptr) + (b * blocksz), x
|
|
.endfor
|
|
inx
|
|
.if blocksz != 256
|
|
cpx #blocksz
|
|
.endif
|
|
bne -
|
|
+
|
|
.endmacro
|
|
|
|
CopyMem .macro src, dst, sz
|
|
.for blocksz := 256, ((\sz) % blocksz) > 0, blocksz -= 1
|
|
.endfor
|
|
blocks = (\sz) / blocksz
|
|
|
|
ldx #0
|
|
- .for b := 0, b < blocks, b += 1
|
|
lda (\src) + (b * blocksz), x
|
|
sta (\dst) + (b * blocksz), x
|
|
.endfor
|
|
inx
|
|
.if blocksz != 256
|
|
cpx #blocksz
|
|
.endif
|
|
bne -
|
|
+ .endmacro
|
|
|
|
; *=$c000
|
|
;
|
|
; .FillMem 1024, 0, 10000
|
|
; rts
|
|
|
|
; vim: syntax=64tass
|