[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: News from the wooden hut (n/m with n < m)
I forgot to convert tabs to spaces:
; Assembler: Macro Assembler AS V1.42
cpu z80 ; z80
org 2000h ; ZBRUN looks here
main:
; backup stack pointer
ld hl,0 ; load HL with 0
add hl,sp ; HL = HL + SP (load HL with SP)
ld (spback),hl ; store HL(SP) to spback:
; set up new SP
ld hl,stack ; HL = address of stack:
ld sp,hl ; SP = HL = address of stack:
ld hl,hello ; HL to point to hello
call print ; print it
; restore SP
ld hl,(spback) ; load saved SP into HL
ld sp,hl ; SP = HL
ret ; back to 6502 land
hello: db "\rHELLO, WORLD\r\0"
spback: db 0,0
print: ld a,(hl) ; A <- (HL)
and a ; update zero flag
ret z ; return if zero
call echo ; print char
inc hl ; HL++
jp print ; back to top
echo: push bc ; back up BC to stack
or 080h ; set 8th bit high (it's an Apple thing)
ld c,2 ; C <- 2
rst 28h ; ZBRUN magic
pop bc ; restore BC from stack
ret
org $+256 ; set stack pointer for 256 bytes
stack: