tohex1.asm
; z88dk / WebMSX
; z80asm -b -l tohex1.asm
; appmake +msx -b tohex1.bin --org 0xd000 --fmsx
chget equ $009f
chput equ $00a2
org $d000
start:
call chget
ld hl, val
ld (hl), a
ld de, buf
call tohex
ld hl, buf
call puts
jr start
puts:
ld a, (hl)
or a
ret z
call chput
inc hl
jr puts
tohex:
ld a, (hl)
srl a
srl a
srl a
srl a
cp $0a
ccf
adc a, $30
daa
ld (de), a
inc de
ld a, (hl)
and $0f
cp $0a
ccf
adc a, $30
daa
ld (de), a
ret
val: defs 1
buf: defm "xx ", 0
tohex1.cas
をCassetteにドロップする。
テープアイコンのメニューから[Run Program]を選択する。
他の例
tohex1.asm
; z88dk / WebMSX
; z80asm -b -l tohex1.asm
; appmake +msx -b tohex1.bin --org 0xd000 --fmsx
chget equ $009f
chput equ $00a2
org $d000
start:
call chget
ld de, buf
call tohex
ld hl, buf
call puts
jr start
puts:
ld a, (hl)
or a
ret z
call chput
inc hl
jr puts
tohex:
push af
rrca
rrca
rrca
rrca
and $0f
ld hl, hexarr
ld b, 0
ld c, a
add hl, bc
ld a, (hl)
ld (de), a
inc de
pop af
and $0f
ld hl, hexarr
ld c, a
add hl, bc
ld a, (hl)
ld (de), a
ret
hexarr: defm "0123456789ABCDEF"
buf: defm "xx ", 0