Adds islower()/isupper()
This commit is contained in:
34
src/core.asm
34
src/core.asm
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
section .text
|
section .text
|
||||||
global exit
|
global exit
|
||||||
|
global islower
|
||||||
|
global isupper
|
||||||
|
|
||||||
;----- exit(exit_code) -----;
|
;----- exit(exit_code) -----;
|
||||||
; Exits the program with given exit code
|
; Exits the program with given exit code
|
||||||
@@ -13,3 +15,35 @@ exit:
|
|||||||
sub rsp, SIZE_QWORD
|
sub rsp, SIZE_QWORD
|
||||||
mov rax, NR_exit
|
mov rax, NR_exit
|
||||||
syscall
|
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
|
||||||
|
Reference in New Issue
Block a user