输入一个年份,判断其是否是闰年。
include vcIO.inc
.data
frmStr1 byte '%d', 0
year dword ?
hello2 byte 'runnian',0
hello3 byte 'feirunnian',0
a dword ?
.code
main proc
invoke scanf, offset frmStr1,offset year
mov eax,year
mov ebx,400
xor edx,edx
div ebx
xor ebx,ebx
cmp ebx,edx
jz runnian
mov ebx,4
mov eax,edx
mov a,edx
xor edx,edx
div ebx
xor ebx,ebx
cmp ebx,edx
jnz feirunnian
mov ebx,100
mov eax,a
xor edx,edx
div ebx
xor ebx,ebx
cmp ebx,edx
jz feirunnian
jnz runnian
jmp feirunnian
runnian:
invoke printf,offset hello2
jmp endf
feirunnian:
invoke printf,offset hello3
endf:
pushad
invoke _getch
popad
ret
main endp
end main
采用无条件和条件转移指令构造while和do while循环结构,完成下面的求和任务并输出sum和n(sum ,n为双字)
do-while:
include vcIO.inc
.data
n dword 100
sum dword ?
frmStr1 byte 'n=%d sum=%5d',0ah,0ah,0
.code
main proc
mov ecx,n
xor eax,eax
l1:
add eax,ecx
dec ecx
cmp ecx,0
jne l1
pushad
invoke printf, offset frmStr1,n,eax
invoke _getch
popad
ret
main endp
end main
while:
include vcIO.inc
.data
n dword 100
sum dword ?
frmStr1 byte 'n=%d sum=%5d',0ah,0ah,0
.code
main proc
mov ecx,n
xor eax,eax
l1:
cmp ecx,0
jz fin
add eax,ecx
dec ecx
jmp l1
fin:
pushad
invoke printf, offset frmStr1,n,eax
invoke _getch
popad
ret
main endp
end main
从键盘上输入3个有符号的双字整数,编写一完整的程序按照又大到小的顺序输出这3个数
include vcIO.inc
.data
frmStr1 byte '%d %d %d',0
frmStr2 byte '%d %d %d',0ah,0ah,0ah,0
a dword ?
b dword ?
d dword ?
.code
main proc
invoke scanf, offset frmStr1,offset a,offset b,offset d
mov eax,a
cmp eax,b
jns l1
l4:
cmp eax,d
jns l2
l5:
mov eax,b
cmp eax,d
jns l3
jmp fin
l1:
xchg b,eax
mov a,eax
jmp l4
l2:
xchg d,eax
mov a,eax
jmp l5
l3:
xchg d,eax
mov b,eax
fin:
pushad
invoke printf, offset frmStr2,a,b,d
invoke _getch
popad
ret
main endp
end main