Use subroutine to complete certain arithmetic operations For

Use subroutine to complete certain arithmetic operations For this task, design an assembly program with a subroutine that is able to complete the following calculation: Z = (M + N*3)/2-4; Where Z is a 16-bit unsigned number to be stored into memory locations starting from M[$2020]; M is an 8-bit unsigned number to be retrieved from memory locations starting from M[$2000]; N is an 8-bit unsigned number to be retrieved from memory locations starting from M[$2010]; Please use either call-by-value or call-by-reference method to transfer your subroutine input/output parameters. Your code shall be able to compute the above calculations for the following five sets of test data M and N, at least. Please store the source data M in the memory locations starling from $2000 to $2004 using data directives. Please store the source data N in the memory locations starting from $2010 to $2014 using data directives. Please store the result data Z in the memory locations starting from $2020 to $2029. Please provide the following answers in your lest submission. Did you choose Call-by-value or Call-by -reference method for this task? What is your assembly program? What is the Code-Warrior simulation result (showing register and memory contents from address $2000 to $202F) before subroutine calculations? What is the Code-Warrior simulation result (showing register and memory contents from address $2000 to $202F) after subroutine calculations?

Solution

assembly code for :

z=(m+n*3)/2-4; arithmatic expression .

printf@plt-0x10:
pushq 0x200bb2(%rip) # 601008 <_GLOBAL_OFFSET_TABLE_+0x8>
jmpq *0x200bb4(%rip) # 601010 <_GLOBAL_OFFSET_TABLE_+0x10>
nopl 0x0(%rax)
printf@plt:
jmpq *0x200bb2(%rip) # 601018 <_GLOBAL_OFFSET_TABLE_+0x18>
pushq $0x0
jmpq 400450 <_init+0x20>
scanf@plt:
jmpq *0x200ba2(%rip) # 601028 <_GLOBAL_OFFSET_TABLE_+0x28>
pushq $0x2
jmpq 400450 <_init+0x20>
.plt.got:
jmpq *0x200b62(%rip) # 600ff8 <_DYNAMIC+0x200>
xchg %ax,%ax
main:
push %rbp
mov %rsp,%rbp
sub $0x10,%rsp
mov $0x400684,%edi
mov $0x0,%eax
callq 400460 <printf@plt>
lea -0xc(%rbp),%rdx
lea -0x8(%rbp),%rax
mov %rax,%rsi
mov $0x40069f,%edi
mov $0x0,%eax
callq 400480 <scanf@plt>
mov -0xc(%rbp),%edx
mov %edx,%eax
add %eax,%eax
add %eax,%edx
mov -0x8(%rbp),%eax
add %edx,%eax
shr %eax
sub $0x4,%eax
mov %eax,-0x4(%rbp)
mov -0x4(%rbp),%eax
mov %eax,%esi
mov $0x4006a4,%edi
mov $0x0,%eax
callq 400460 <printf@plt>
mov $0x0,%eax
leaveq
retq   
nopl 0x0(%rax,%rax,1)

 Use subroutine to complete certain arithmetic operations For this task, design an assembly program with a subroutine that is able to complete the following cal
 Use subroutine to complete certain arithmetic operations For this task, design an assembly program with a subroutine that is able to complete the following cal

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site