汇编语言上机题目

代码:

include irvine32.inc
.data
 dat word 1111h,3333h,9999h,000ch
 max word ?
.code
 main proc
 mov ecx,lengthof dat
 dec ecx
 xor esi,esi
 mov ax,dat[esi]
again:
 add esi,2
 cmp ax,dat[esi]
 jge next
 mov ax,dat[esi]
next:
 dec ecx
 jnz again
 mov max,ax
 mov eax,dword ptr max
 call writehex
 exit
 main endp
 end main

 

 

代码:

include irvine32.inc
.data
 tab byte 10,52,36,51,25,99,56,14
 dat byte 14
 no byte ?
.code
 main proc
 mov dl,0
 mov ecx,lengthof tab
 xor esi,esi
 mov al,dat
again:
 cmp tab[esi],al
 jz ext1
 inc esi
 inc dl
 dec ecx
 jnz again
ext1:
 cmp ecx,0
 jz nfound
 mov no,dl
 jmp ext2
nfound:
 mov no,0ffh
ext2:
 movsx eax,no
 call writehex
 exit
 main endp
 end main

 

代码: 

include irvine32.inc
.data
 tab byte 1,5,2,6,12,3,16
 dat byte 7 dup(?)
.code
 main proc
 mov ecx,lengthof tab
again:
 mov ax,word ptr tab[ecx]
 mov word ptr dat[ecx],ax
 loop again
 mov ax,word ptr tab[ecx]
 mov word ptr dat[ecx],ax
 xor ecx,ecx
 mov ecx,lengthof tab
 dec ecx
again1:
 mov edi, ecx
 xor ebx,ebx
again2:
 mov al,dat[ebx]
 cmp al,dat[ebx+1]
 jae next
 xchg al,dat[ebx+1]
 mov dat[ebx],al
next:
 inc ebx
 dec ecx
 cmp ecx,0
 jnz again2
 mov ecx,edi
 dec ecx
 cmp ecx,0
 jnz again1
 exit
 main endp
 end main

 

 

 代码:

include irvine32.inc
.data
 buf word 1234h
 mas byte 4 dup(?)
.code
 main proc
 push offset mas
 push offset buf
 call decbin
 exit
 main endp
 decbin proc
 push ebp
 mov ebp,esp
 xor dx,dx
 mov edi,[ebp+8]
 mov esi,0
 mov ecx,4h
again:
 mov dx,word ptr [edi]
 rol dx,4
 mov word ptr [edi],dx
 and dl,0fh
 cmp dl,0ah
 jb num
 add dl,7
num:
 add dl,30h
 mov mas[esi],dl
 movsx eax,mas[esi]
 call writeint
 call crlf
 inc esi
 dec ecx
 cmp ecx,0
 jnz again
 pop ebp
 ret 8
 decbin endp
 end main  

 

代码:

include irvine32.inc
n=100
.data
 string byte n dup(?)
 len dword 0
.code
 main proc
 lea edx,string
 mov ecx,n
 call readstring
 mov len,eax
 call change
 push offset len
 call print
 exit
 main endp
change proc
 push eax
 push ecx 
 push esi
 push edx
 mov esi,0
 mov ecx,len
again1:
 mov al,string[esi]
 cmp al,61h
 jae no_upper
 add al,32
 mov string[esi],al
no_upper:
 inc esi
 loop again1
 pop esi
 pop eax
 pop ecx
 pop edx
 ret
change endp
print proc
 push ebp
 mov ebp,esp
 mov edi,[ebp+4]
 mov esi,0
 mov ecx,[edi]
again:
 movsx eax,string[esi]
 call writehex
 call crlf
 inc esi
 loop again
 pop ebp
 ret 8
 print endp
end main

代码: 

include irvine32.inc
.data
 dat word 100 dup(?)
 p word 100 dup(?)
 no word ?
.code
 main proc
 call readhex
 mov ecx,eax
 mov edx,0
 mov ebx,ecx
again:
 call readhex
 mov dat[edx],ax
 inc edx
 loop again
 mov ecx,ebx
 push offset dat
 push offset p
 push offset no
 call even_number
 movsx eax,no
 call writehex
 exit
 main endp
even_number proc
 push ebp
 mov edx,0
 mov ebp,esp
 mov edi,[ebp+12]
 mov esi,[ebp+16]
again1:
 mov ax,word ptr [esi]
 and eax,1
 cmp eax,0
 jnz last
 mov eax,[esi]
 mov dword ptr [edi],eax
 inc edi
 inc edx
last:
 inc esi
 loop again1
 mov esi,[ebp+8]
 mov [esi],edx
 pop ebp
 ret 12
 even_number endp
 end main

代码: 

include irvine32.inc
.data
 tab dword 300 dup(?)
 x dword 5h
 min dword ?
.code
 main proc
 call readhex
 mov min,0
 mov ecx,eax
 mov ebx,0
 mov edx,ecx
again:
 call readint
 mov tab[ebx],eax
 add ebx,4
 loop again
 mov ecx,edx
 push offset tab
 push offset min
 call Min_num
 mov eax,min
 call writeint
 exit
 main endp
Min_num proc
 push ebp
 mov ebp,esp
 mov edi,[ebp+8]
 mov esi,[ebp+12]
again1:
 mov eax,[esi]
 cmp eax,0
 jge last
 not eax
 inc eax
 cmp eax,x
 jbe last
 cmp eax,[edi]
 jb last
 mov [edi],eax
last:
 inc esi
 loop again1
 pop ebp
 ret 8
 Min_num endp
 end main

 

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值