Empty string: Difference between revisions
→{{header|8th}}
(add BQN) |
Puppydrum64 (talk | contribs) |
||
Line 21:
I !s.empty
print(‘String s is not empty.’)</lang>
=={{header|6502 Assembly}}==
An empty string is just a null terminator with no text in front.
<lang 6502>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.
<lang 6502asm>lda #<EmptyString ;address of string we wish to check
sta $00
lda #>EmptyString
sta $01
ldy #0
ldx #0
getStringLength:
lda ($00),y
beq Terminated
iny
jmp getStringLength
Terminated:
cpy #0
beq StringIsEmpty ;if this branch is taken, the string is empty
;otherwise, the string is not empty</lang>
=={{header|8th}}==
|