15 lines
644 B
Plaintext
15 lines
644 B
Plaintext
LEA EmptyString,A0 ;assign the empty string to address register A0
|
|
|
|
getStringLength:
|
|
MOVE.L A0,-(SP) ;push A0 onto the stack. This will be used to check if the string is empty.
|
|
|
|
loop_getStringLength:
|
|
MOVE.B (A0)+,D0
|
|
BEQ Terminated
|
|
JMP loop_getStringLength
|
|
|
|
SUBQ.L #1,A0 ;after the terminator is read, A0 is incremented to point to the byte after it. This fixes that.
|
|
CMP.L A0,(SP) ;compare the current A0 with the original value.
|
|
BEQ StringIsEmpty ;if they are equal, then nothing was read besides the terminator. Therefore the string is empty.
|
|
;if the above branch wasn't taken, the string is not empty and execution arrives here.
|