Assembly Language: 5) What is the output of the following assembly code segment?
ID: 3812254 • Letter: A
Question
Assembly Language:
5) What is the output of the following assembly code segment? How would the code be written in a higher-level language?
mov x, 25
mov y, 3
mov ax, x
cmp ax, y
je One
cmp y, 0
jnl Two
jmp Next
One: imul y
jmp Next
Two: mov Num, 10
imul Num
Next: call PutDec
6) What is the output of the following assembly code segment? How would the code be written in a higher-level language?
mov x, 5
mov y, 5
mov ax, x
cmp ax, y
je One
cmp y, 0
jnl Two
jmp Next
One: imul y
jmp Next
Two: mov Num, 10
imul Num
Next: call PutDec
Explanation / Answer
Question 5)
Output: +250
High level language Code(Java):
class Problem5{
public static void main(String a[])
{
int x=25;//mov x, 25
int y=3;//mov y, 3
int ax=x;//mov ax, x ax is accumulator
if(ax==y)//ax is equal to y
{
//One label code
//al is lower 8 bits in ax.Here ax=25=al
int al=ax;
ax = al*y;//imul y
//Next label code
System.out.println(ax);//call PutDec
}
else if(y>=0)//y is not less than 0
{
//Two label code
int Num = 10;//mov Num, 10
int al=ax;//al is lower 8 bits in ax.Here ax=25=al
ax = al*Num;//imul Num
//Next label code
System.out.println(ax);//call PutDec
}
else
{
//Next label code
System.out.println(ax);//call PutDec
}
}
}
Question 6)
Output: +25
High level language Code(Java):
class Problem6{
public static void main(String a[])
{
int x=5;//mov x, 5
int y=5;//mov y, 5
int ax=x;//mov ax, x ax is accumulator
if(ax==y)//ax is equal to y
{
//One label code
//al is lower 8 bits in ax.Here ax=5=al
int al=ax;
ax = al*y;//imul y
//Next label code
System.out.println(ax);//call PutDec
}
else if(y>=0)//y is not less than 0
{
//Two label code
int Num = 10;//mov Num, 10
int al=ax;//al is lower 8 bits in ax.Here ax=5=al
ax = al*Num;//imul Num
//Next label code
System.out.println(ax);//call PutDec
}
else
{
//Next label code
System.out.println(ax);//call PutDec
}
}
}
Hope this helps. If anything not understandable, please comment to my answer. always happy to help.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.