代码:
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