String length: Difference between revisions

Line 97:
done:
RTS</lang>
 
=={{header|8086 Assembly}}==
{{trans|68000 Assembly}}
===Byte Length===
<lang asm>;INPUT: DS:SI = BASE ADDR. OF STRING
;TYPICALLY, MS-DOS USES $ TO TERMINATE STRINGS.
GetStringLength:
xor cx,cx ;this takes fewer bytes to encode than "mov cx,0"
cld ;makes string functions post-inc rather than post-dec.
 
loop_GetStringLength:
lodsb ;equivalent of "mov al,[ds:si],inc si" except this doesn't alter the flags.
cmp '$'
je done ;if equal, we're finished.
inc cx ;add 1 to length counter. A null string will have a length of zero.
jmp loop_GetStringLength
 
done:
ret
 
=={{header|4D}}==
===Byte Length===
<lang 4d>$length:=Length("Hello, world!")</lang>
 
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
1,489

edits