Adds islower()/isupper()

This commit is contained in:
2025-07-09 22:57:33 +02:00
parent 368457f5c3
commit 2a4f3b2558

View File

@@ -2,6 +2,8 @@
section .text
global exit
global islower
global isupper
;----- exit(exit_code) -----;
; Exits the program with given exit code
@@ -13,3 +15,35 @@ exit:
sub rsp, SIZE_QWORD
mov rax, NR_exit
syscall
;----- islower(c) -----;
; Checks if given ASCII character is lowercase (a-z)
; Return value: 1 if ASCII character is lowercase (is in range a-z), 0 otherwise
; Used registers:
; rax* (ret)
; rdi (arg) Character to check
islower:
xor rax, rax
cmp dil, 'a'
jb .quit
cmp dil, 'z'
ja .quit
mov rax, 1
.quit:
ret
;----- isupper(c) -----;
; Checks if given ASCII character is uppercase (A-Z)
; Return value: 1 if ASCII character is uppercase (is in range A-Z), 0 otherwise
; Used registers:
; rax* (ret)
; rdi (arg) Character to check
isupper:
xor rax, rax
cmp dil, 'A'
jb .quit
cmp dil, 'Z'
ja .quit
mov rax, 1
.quit:
ret