mirror of
https://github.com/antoinevignau/source.git
synced 2025-01-08 13:29:45 +00:00
1 line
1.2 KiB
Plaintext
Executable File
1 line
1.2 KiB
Plaintext
Executable File
;
|
|
; Heap.mac - Heap macros
|
|
;
|
|
; Copyright © 1989, Claris Corporation
|
|
;
|
|
; 1-13-89 Kevin A. Watts
|
|
; 1-17-89 kaw - added Deref
|
|
|
|
|
|
; BeginZ - prologue for use with Zero Page
|
|
|
|
MACRO
|
|
BeginZ
|
|
phd
|
|
lda #0 ; Replace with the address of the zero page
|
|
tcd
|
|
ENDM
|
|
|
|
|
|
; ReturnZ - epilog for use with Zero Page
|
|
|
|
MACRO
|
|
ReturnZ
|
|
pld
|
|
rtl
|
|
ENDM
|
|
|
|
|
|
; DefineZ - modify routine using BeginZ prologue.
|
|
; Zero page address must be in accumulator, and data bank must equal code bank
|
|
|
|
MACRO
|
|
DefineZ &routine
|
|
sta &routine+2
|
|
ENDM
|
|
|
|
|
|
; Deref Ptr - equivalent to "MoveLong [Ptr],Ptr", but this one works.
|
|
; Ptr should be a direct page variable
|
|
; Regs: a, x, y
|
|
; Side-effect: leaves Ptr in ax
|
|
|
|
MACRO
|
|
Deref &Ptr
|
|
ldy #2
|
|
lda [&Ptr],y
|
|
tax
|
|
lda [&Ptr]
|
|
sta &Ptr
|
|
stx &Ptr+2
|
|
ENDM
|
|
|
|
|
|
; DivByPwr2 Var,Divisor - divide Var by Divisor,
|
|
; - where Divisor is a power of 2
|
|
|
|
MACRO
|
|
DivByPwr2 &Var,&Divisor
|
|
LCLA &count
|
|
&count: SETA &eval( &Divisor )
|
|
WHILE &count > 1 DO
|
|
lsr &Var
|
|
&count: SETA &count/2
|
|
ENDWHILE
|
|
ENDM
|
|
|
|
|
|
; MulByPwr2 Var,Multiplier - multiply Var by Multiplier,
|
|
; - where Multiplier is a power of 2
|
|
|
|
MACRO
|
|
MulByPwr2 &Var,&Multiplier
|
|
LCLA &count
|
|
&count: SETA &eval( &Multiplier )
|
|
WHILE &count > 1 DO
|
|
asl &Var
|
|
&count: SETA &count/2
|
|
ENDWHILE
|
|
ENDM
|