Calcola lunghezza di una stringa
String length calculation
;—————————————————————–
; String handling in assembly
; b) String length calculation
;—————————————————————–
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
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 count the string length>
subprog2 : add A,(hl) ;this instruction controls if the value in the hl register is NULL
jp nz, count
ret
count : inc hl
inc BC
ld A,00h
jp subprog2
RET