From 2a4f3b2558926f5469a891cb72e6bbd543022db2 Mon Sep 17 00:00:00 2001 From: Kwarde Date: Wed, 9 Jul 2025 22:57:33 +0200 Subject: [PATCH] Adds islower()/isupper() --- src/core.asm | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/core.asm b/src/core.asm index 9911208..5339070 100644 --- a/src/core.asm +++ b/src/core.asm @@ -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