FZU 汇编上机实验 四 子程序设计

  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

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值