-
Notifications
You must be signed in to change notification settings - Fork 2
Labels
Robert Kuhfß edited this page Oct 30, 2018
·
1 revision
Labels in SPASM are much like TASM 3.2. The preferred style of label is the colon terminated, like this:
label:
ld a,30
ret
With labels, you can use this syntax:
label: ld a,25 \ ret
Also permitted is the non-colon terminated line label.
label
xor a
ld (ram_loc), a
ret
Like above, the following is acceptable:
label2 inc a
ld (ram_loc+1),a
ret
SPASM uses no-questions-asked order of operations: left-to-right. This is prefered for speed reasons as well as ambiguity between operators -- who really knows which of these operators should come first? % or &?
The operators available are as follows: * / - + % ^ & | << >>
ld a,10*15 ;= 150 multiply
ld b,254/12 ;= 12 integer divide (it truncates)
ld c,10-30 ;= -20 subtract
ld d,-(10-23) ;= 13 negate
ld e,10+10 ;= 20 addition
ld h,10^3 ;= 9 bitwise exclusive or
ld l,17 & 1 ;= 1 bitwise and
.db 10 | 5 ;= 15 bitwise or
.dw 1<<4 ;= 16 arithmetic left shift
ld hl,16>>4 ;= 1 arithmetic right shift
Example of order of operations:
ld hl,25*256+10 ;h = 25, l = 10
ld hl,10+25*256 ;h = 350,l = 0
ld hl,10+(25*256) ;h = 25, l = 10