LoginSignup
0
0

More than 5 years have passed since last update.

MSX 16進変換サンプル

Last updated at Posted at 2018-07-31
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]を選択する。
WMSX Screen.png

WebMSX テープ版

他の例

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
0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0