Assembly - case conversion, input and output of strings

I checked the content about case conversion on the Internet, and said that I couldn’t understand it. It may be because their thinking is more careful, standardized, and the language is different, so I can’t understand it. I wrote a string about uppercase and lowercase. Conversion, as well as a piece of code using string input and output functions, feel simple and clear, suitable for the understanding of beginners like me,
let briefly talk about the problem of case conversion, my idea is to directly store the characters in the register, Then change the ASCII code in the register, and then save it back to the string, which can realize the conversion between various characters.
Then the following example will use the basic content of subroutines, loops, etc.

上机题目:键盘输入
   内容:从键盘输入一串字母并保存在string开始的地址单元,要求将该字符串中的大写字母转化为小写字母后用子程序实现在终端上依次显示该串字母的 ASCII码。
   string db   n  dup(?)
要求:熟练掌握子程序设计方法,画子程序、主程序流程图

I feel that it is very easy to understand, so I will not comment.

include irvine32.inc
.data
string db 50 dup(?)
.code
main proc far
xor edx,edx
xor esi,esi
lea edx,string
mov ecx,50
call readstring

lop1:
cmp string[esi],'Z'
jg next
mov ah,string[esi]
add ah,20h
mov string[esi],ah
next:
inc esi
cmp string[esi],'z'
jg next1
cmp string[esi],'A'
jl next1
jmp lop1
next1:
lea edx,string
mov ecx,50
call writestring
call crlf
call decbin

exit
main endp

decbin proc near
xor esi,esi
lop2:
xor eax,eax
mov al,string[esi]
call writeint
call crlf
inc esi
;cmp string[esi],'A'
;jl nextx
cmp string[esi],'z'
jg nextx
cmp string[esi],'a'
jl nextx
jmp lop2
nextx:
;mov al,string[esi]
;call writeint
ret
decbin endp

end main

By the way, I will post a somewhat related topic. CSDN is my notebook 233
computer
topic into the unit starting with MAS, and display the 4-byte unit starting with MAS on the terminal.
BUF DW X
MAS DB 4 DUP(?)
Requirements: Proficient in subprogram design method
IUDE IRVINE32.INC
.DATA
BUF DW ?
MAS DB 4 DUP(?)
.CODE
MAIN PROC FAR
XOR EAX,EAX
CALL READHEX
MOV BUF,AX
CALL DECBIN
EXIT
MAIN ENDP ;;;;;;;;;;;;;;;;;;;;;;;
DECBIN PROC NEAR PUSH EAX PUSH ECX XOR ESI,ESI XOR ECX,ECX MOV CL,04H ;;; ;;;;;;;;;;;;;;;;;;; LOP1 : MOV DX,BUF ROL DX,04H











MOV BUF,DX
AND DL,0FH
CMP DL,0AH
JL NEXT
ADD DL,7H
NEXT:
ADD DL,30H
MOV MAS[ESI],DL
MOVZX EAX,MAS[ESI]
CALL WRITEINT
CALL CRLF
INC ESI
LOOP LOP1
POP EAX
POP ECX
RET
DECBIN ENDP
;;;;;;;;;;;;;;;;;;;;;;
END MAIN
“`

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324827903&siteId=291194637