Question: 1 . ( 1 2 marks ) For the program: Convert the following assembly code into machine code Identify the bugs from the NASM point

1.(12 marks) For the program:
Convert the following assembly code into machine code
Identify the bugs from the NASM point of view
Identify the design defect (has no effect on the program operation)
Is the memory properly aligned?
ORG 4B01H
NUM1 DB 2
NUM2 DW 3
NUM3 DB 4
ORG 0400H MOV AH, Num1 MOV AL, Num1
MOV BX,[04B0H] AND AX,BX
MOV Num2, AX INT 3
2.(4 marks) For question 1, determine the program size and cycle count. Do not include INT3 as part
of the metrics.
Assembly
#
~
ORG 4B01H
NUM1 DB 2
NUM2 DW 3
NUM3 DB 4
ORG 0400H
MOV AH, NUM1
MOV AL, NUM1
MOV BX,[04B0H]
AND AX, BX
MOV NUM2, AX
INT 3
TOTALS
3.(6 marks) Convert the following machine code into assembly code. You can use any address for the
data section.
04B006
04B100
04B202
04B300
04B402
0400 A1
0401 B0
040204
04038B
04041E
0405 B2
040604
040703
0408 C3
0409 A3
040A B0
040B 04
040C 22
040D E0
040E 88
040F 26
0410 B4
041104
0412 CC
4.(6 marks) Convert the following C code snippet into assembly language. Assume that the data section begins at 04C0H.
uint8_t Num1=2, Num2=5, Num3; if(Num1> Num2) Num3= Num1+ Num2; else Num1= Num2- Num1;
There are many possible solutions.
5. BONUS (6 marks) Convert the assembly code in question 4 into machine code.
6. BONUS (4 marks) Determine the program size in question 4, as well as the cycle count (worst-case and best-case, e.g. based on whether the branch is taken or not).
Label
Assembly
#,~
Worst Case
#,~
Best Case
#,~
7.(4 marks) There are multiple ways to convert AX =3+ DX into assembly. Which of the following is the best solution? (careful, there are some hidden considerations as well)
8.(3 marks) What is wrong with the following code (general point of view for assembly), and how does the second style rectify the problem?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!