Empty string: Difference between revisions
Content added Content deleted
(add gwbasic) |
Puppydrum64 (talk | contribs) |
||
Line 3,040: | Line 3,040: | ||
"); |
"); |
||
]</lang> |
]</lang> |
||
=={{header|Z80 Assembly}}== |
|||
{{trans|6502 Assembly}} |
|||
An empty string is just a null terminator with no text in front. |
|||
<lang z80>EmptyString: |
|||
byte 0</lang> |
|||
Checking if a string is empty is simple, just count the number of characters before you reach the terminator. If that count equals zero, the string is empty. Otherwise, the string is not empty. |
|||
<lang z80>ld hl,MyString |
|||
GetStringLength: |
|||
ld b,0 ;zero the length counter |
|||
loop_getStringLength: |
|||
ld a,(hl) |
|||
or a ;compare A to zero |
|||
ret z ;exit if zero |
|||
inc hl ;next char |
|||
inc b ;add 1 to length counter |
|||
jr loop_getStringLength |
|||
ld b,a |
|||
or a |
|||
jr z,StringIsEmpty</lang> |
|||
</lang> |
|||
=={{header|zkl}}== |
=={{header|zkl}}== |