tolower(), toupper()
This commit is contained in:
36
core.asm
36
core.asm
@ -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
|
||||
|
Reference in New Issue
Block a user