Increment a numerical string: Difference between revisions
→{{header|Z80 Assembly}}
Puppydrum64 (talk | contribs) |
Puppydrum64 (talk | contribs) |
||
Line 3,370:
=={{header|Z80 Assembly}}==
As a test case, we'll start with 1999 and increment it to 2000.
<lang z80>;;;;;;;;;;;;;;;;;;; HEADER ;;;;;;;;;;;;;;;;;;;
read "\SrcCPC\winape_macros.asm"
Line 3,378:
org &1000
ld hl,NumericString
Line 3,387 ⟶ 3,385:
jr z,displaystring
add &01
cp &3A
ld (hl),a▼
▲jr nc,displaystring
;carry forward
ld a,&30
▲ld (hl),a
inc hl
jr incstring
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
displaystring:
ld (hl),a ;store the last addition.
ld hl,NumericString_End
dec hl
Line 3,401:
cp 255
ret z
call
dec hl
jr disploop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
db 255 ;terminator when reading in reverse
NumericString:
;stored little-endian for convenience
db &
NumericString_End:
db 255 ;terminator
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
read "\SrcCPC\winape_showhex.asm"
read "\SrcCPC\winape_stringop.asm"</lang>
{{out}}
<pre>
=={{header|zkl}}==
|