RosettaCodeData/Task/Empty-string/X86-64-Assembly/empty-string.x86-64

33 lines
757 B
Plaintext

option casemap:none
printf proto :qword, :VARARG
exit proto :dword
.data
e_str db 1 dup (0)
.code
main proc
xor rcx, rcx
lea rax, e_str
cmp byte ptr [rax+rcx],0 ;; Is e_str[0] equal to 0?
je _isempty ;; Yes so goto isEmpty
jne _notempty ;; No, got notEmpty
jmp _exit ;; Neither condition is met, so exit.
_isempty:
invoke printf, CSTR("e_str is empty",10)
lea rax, e_str
mov byte ptr [rax+0], 's' ;; Copy a char into e_str[0]
jmp main ;; Test again..
_notempty:
invoke printf, CSTR("e_str is NOT empty",10)
;; Fall though to exit here..
_exit:
xor rsi, rsi
call exit
ret
main endp
end