Duplica una stringa in un altro indirizzo della memoria
String duplication
;—————————————————————–
; String handling in assembly
; c) String duplication
;—————————————————————–
ORG 0000h
JP 0100h ;(link to the Hardware RESET)
ORG 0100h
START : ld sp,0fff0h ; stack pointer initialization
ld A,00h
CALL subprog
ld (8000h),hl
ld (8002h),de
ld (8004h),A
ld hl,8000h
ld de,9000h
CALL subprog2
HALT
;This subprogram will define the string>
subprog : ld h,55h ; this subprogram will write the string “LUCA\0″
ld l,4ch
ld d,41h
ld e,43h
RET
;This subprogram will copy the string>
subprog2 : ld a,00h
add A,(hl)
jp z, exit
ld A,(hl)
ld (de), a
inc hl
inc de
jp subprog2
exit :ld a,00h
ld (de), A
ret