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