Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
32
Task/Repeat-a-string/8080-Assembly/repeat-a-string.8080
Normal file
32
Task/Repeat-a-string/8080-Assembly/repeat-a-string.8080
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
org 100h
|
||||
jmp demo
|
||||
|
||||
; Repeat the string at DE into HL, B times
|
||||
repeat: mvi c,'$' ; string terminator
|
||||
xra a ; repeat 0x?
|
||||
ora b
|
||||
mov m,c ; then empty string
|
||||
rz
|
||||
rpt1: push d ; save begin of string to repeat
|
||||
chcpy: ldax d ; copy character from input to output
|
||||
mov m,a
|
||||
inx d ; advance pointers
|
||||
inx h
|
||||
cmp c ; end of string?
|
||||
jnz chcpy
|
||||
pop d ; restore begin of string to repeat
|
||||
dcx h ; move back past terminator in copy
|
||||
dcr b ; done yet?
|
||||
jnz rpt1 ; if not add another copy
|
||||
ret
|
||||
|
||||
demo: lxi d,ha ; get string to repeat
|
||||
lxi h,buf ; place to store result
|
||||
mvi b,5 ; repeat 5 times
|
||||
call repeat
|
||||
lxi d,buf ; print result using CP/M call
|
||||
mvi c,9
|
||||
jmp 5
|
||||
|
||||
ha: db 'ha$' ; string to repeat
|
||||
buf: ds 32 ; place to store repeated string
|
||||
Loading…
Add table
Add a link
Reference in a new issue