Intel汇编语言程序设计课后习题,6.5.5

把C语言翻译成汇编语言

if(dx<=cx)
x
=1
else
x
=2
main PROC
mov edx,4
mov ecx,5
cmp edx,ecx
jle L1
mov x,2
jmp next
L1:
mov x,1
next:
mov eax,x
call WriteDec
ret
main endp
if(bx>cx)
x
=1
mov eax,4
mov ebx,5
cmp eax,ebx
jg next
mov x,1
mov eax,x
call WriteDec
next:
ret
if(Val1>cx AND cx>dx)
X
=1
else
X
=2
.data
X DWORD
?
Val1 DWORD
9
.code

main PROC
mov ecx,
8
mov edx,
7
cmp Val1,ecx
jle next
cmp ecx,edx
jle next
mov X,
2
jmp L2
next:
mov X,
1
L2:
mov eax,X
call WriteDec
ret
main endp
if(bx>cx OR bx>VAL1)
X
=1
else
  X=2
.data
X DWORD ?
Val1 DWORD
9
.code

main PROC
mov ebx,5
mov ecx,6
cmp ebx,ecx
jg L1
cmp ebx,Val1
jg L1
mov X,2
jmp next
L1:
mov X,1
next:
mov eax,X
call WriteDec
ret
main endp
if(bx>cx AND bx>dx) OR (dx>ax)
X
=1
else
X
=2
main PROC
mov ebx,5
mov ecx,6
mov edx,7
mov eax,8
cmp edx,eax
jg L1

cmp ebx,ecx
jle L2
cmp ebx,edx
jle L2
L1:
mov X,1
jmp next
L2:
mov X,2
jmp next
next:
mov eax,X
call WriteDec
ret
main endp
posted @ 2011-06-04 10:21  linyilong  阅读(393)  评论(0编辑  收藏  举报