Exercise after Intel assembly language programming, 6.5.5

Source: Internet
Author: User
Translate C language into assembly language
 
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
ElseX = 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.