본문 바로가기

컴퓨터 공학 자료(학부)/Assembly

간단한 대소문자 변환


INCLUDE Irvine32.inc

.data
string BYTE "welcome to the ASSEMBLY world", 0

.code
main PROC
mov edx, OFFSET string
mov esi, OFFSET string
call WriteString
call crlf
call ChangeString
mov edx, esi
call WriteString
exit
main ENDP


ChangeString PROC
PUSH EBP
MOV EBP, ESP
PUSHAD

L1:
inc esi
mov al, [esi]
cmp al, 32 
je SPACE
cmp al, 0 
je DONE
cmp al, 'a'
jb L2
jae L3

L2:
add BYTE PTR [esi], 32
jmp L1

L3:
sub BYTE PTR [esi], 32
jmp L1

SPACE:
jmp L1

DONE:
POPAD
POP EBP
RET

exit
ChangeString ENDP

END main

간단한 대소문자 변환

welcome to ASSEMBLY world를
대문자는 소문자로 소문자는 대문자로 아스키코드값을 비교해 루프,연산한다