tolower(), toupper()

This commit is contained in:
2025-06-23 15:47:05 +02:00
parent ed83e83885
commit 3ec591aab4
2 changed files with 56 additions and 0 deletions

View File

@ -5,6 +5,8 @@ section .text
global maxu
global islower
global isupper
global tolower
global toupper
;----- min(int a, int b) -----;
; return value: lowest value
@ -86,3 +88,37 @@ isupper:
.quit:
leave
ret
;----- tolower(char* c) -----;
; return value: ASCII value. Same as original if it was not an uppercase letter, otherwise lowercase letter
tolower:
push rbp
mov rbp, rsp
xor rax, rax
call isupper
mov rcx, rax
mov al, byte [rdi]
cmp rcx, 1
je .dtl
.dtl:
add al, 32
leave
ret
;----- toupper(char* c) -----;
; return value: ASCII value. Same as original if it was not a lowercase letter, otherwise uppercase letter
toupper:
push rbp
mov rbp, rsp
xor rax, rax
call islower
mov rcx, rax
mov al, byte [rdi]
cmp rcx, 1
je .dtu
.dtu:
sub al, 32
leave
ret