String length: Difference between revisions

Content added Content deleted
Line 97: Line 97:
done:
done:
RTS</lang>
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}}==
=={{header|4D}}==
===Byte Length===
===Byte Length===
<lang 4d>$length:=Length("Hello, world!")</lang>
<lang 4d>$length:=Length("Hello, world!")</lang>

=={{header|AArch64 Assembly}}==
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}