1. 上机题目:代码转换 内容:用子程序设计的方法,分别把BUF字单元中的四位十六进制数转换为ASCII码存入MAS开始的单元中,并在终端上显示MAS开始的4个字节单元。
BUF DW X
MAS DB 4 DUP(?)
要求:熟练掌握子程序设计方法
include Irvine32.inc
.data
buf dw 013ACH
mas dd 4 dup(?)
.code
main proc
call zh
exit
main endp
zh proc
mov esi,3
mov ecx,4
mov edi,16
mov eax,dword ptr buf
mov ebx,offset mas
start:
mov edx,0
div edi
mov [ebx+esi*4],edx
dec esi
loop start
mov ecx,0
mov esi,-1
swap1:
cmp ecx,4
jge sc1
inc esi
inc ecx
mov eax,[ebx+esi*4]
;call writeint
cmp eax,09H
jg swap2
add eax,48
mov [ebx+esi*4],eax
jmp swap1
swap2:
add eax,55
mov [ebx+esi*4],eax
jmp swap1
sc1: mov esi,0
sc: mov eax,[ebx+esi*4]
call writeint
inc esi
loop sc
ret
exit
zh endp
end main
上机题目2:键盘输入 内容:从键盘输入一串字母并保存在string开始的地址单元,要求将该字符串中的大写字母转化为小写字母后用子程序实现,在终端上依次显示该串字母的 ASCII码。 string db n dup(?)
要求:熟练掌握子程序设计方法,画子程序、主程序流程图
include Irvine32.inc
.data
string db 25 dup(?)
.code
main proc
call get
call zh
exit
main endp
get proc
mov edx, offset string ; 将字符串地址传递给ReadString
mov ecx, lengthof string ;设置长度,不然会提示128bits啥玩意的
call readstring
ret
exit
get endp
zh proc
mov ebx,0
mov esi,-1
mov edx,lengthof string
inc edx
start:
inc esi
dec edx
cmp edx,0
jle sc1
movzx eax, byte ptr [string + esi]
cmp eax,32
jl start
panduan1:
inc ebx
cmp eax,65
jl start
cmp eax,91
jl panduan2
jmp start
panduan2:
add eax,32
mov byte ptr [string + esi],al;读取eax的低八位也就是eax+32的那个值(不超过16的平方)
jmp start
sc1:
mov ecx,0
mov edx, offset string
call writestring
call crlf
mov esi,-1
guodu:
mov ecx,ebx
mov esi,0
sc2:
movzx eax,byte ptr [string + esi]
inc esi
call writeint
loop sc2
exit
zh endp
end main