; 万の位
OR A ; Cyクリア
LD A,'0'
LD BC,30000
SBC HL,BC
JP NC,SKIP1_0
ADD HL,BC
OR A
JP SKIP1_1
SKIP1_0:
ADD A,3
SKIP1_1:
LD BC,20000
SBC HL,BC
JP NC,SKIP1_2
ADD HL,BC
OR A
JP SKIP1_3
SKIP1_2:
ADD A,2
SKIP1_3:
LD BC,10000
SBC HL,BC
JP NC,SKIP1_4
ADD HL,BC
OR A
JP SKIP1_5
SKIP1_4:
INC A
SKIP1_5:
LD (DE),A
INC DE
; 千の位
LD A,'0'
LD BC,5000
SBC HL,BC
JP NC,SKIP2_0
ADD HL,BC
OR A
JP SKIP2_1
SKIP2_0:
ADD A,5
SKIP2_1:
LD BC,3000
SBC HL,BC
JP NC,SKIP2_2
ADD HL,BC
OR A
JP SKIP2_3
SKIP2_2:
ADD A,3
SKIP2_3:
LD BC,2000
SBC HL,BC
JP NC,SKIP2_4
ADD HL,BC
OR A
JP SKIP2_5
SKIP2_4:
ADD A,2
SKIP2_5:
LD BC,1000
SBC HL,BC
JP NC,SKIP2_6
ADD HL,BC
OR A
JP SKIP2_7
SKIP2_6:
INC A
SKIP2_7:
LD (DE),A
INC DE
; 百の位
LD A,'0'
LD BC,500
SBC HL,BC
JP NC,SKIP3_0
ADD HL,BC
OR A
JP SKIP3_1
SKIP3_0:
ADD A,5
SKIP3_1:
LD BC,300
SBC HL,BC
JP NC,SKIP3_2
ADD HL,BC
OR A
JP SKIP3_3
SKIP3_2:
ADD A,3
SKIP3_3:
LD BC,200
SBC HL,BC
JP NC,SKIP3_4
ADD HL,BC
OR A
JP SKIP3_5
SKIP3_4:
ADD A,2
SKIP3_5:
LD BC,100
SBC HL,BC
JP NC,SKIP3_6
ADD HL,BC
OR A
JP SKIP3_7
SKIP3_6:
INC A
SKIP3_7:
LD (DE),A
INC DE
; 十の位
LD A,L
SUB A,50
JP NC,SKIP4_0
ADD A,50
JP SKIP4_1
SKIP4_0:
LD H,5
SKIP4_1:
SUB A,30
JP NC,SKIP4_2
ADD A,30
JP SKIP4_3
SKIP4_2:
INC H
INC H
INC H
SKIP4_3:
SUB A,20
JP NC,SKIP4_4
ADD A,20
JP SKIP4_5
SKIP4_4:
INC H
INC H
SKIP4_5:
SUB A,10
JP NC,SKIP4_6
ADD A,10
JP SKIP4_7
SKIP4_6:
INC H
SKIP4_7:
ADD A,'0'
LD L,A
LD A,H
ADD A,'0'
LD (DE),A
INC DE
LD A,L
LD (DE),A
RET