(Solved) : Question4 Refer Caller Code Follows Ldi 5dec Dst D Push 5ldi Retl1dec Dst D Push Return Ad Q42748867 . . .

Question4

Again, refer to the caller code as follows:

ldi a,5dec dst (d),a // push 5ldi a,retL1dec dst (d),a // push return addressjmpi xyz // continues execution at xyzretL1:inc d // deallocates stack space used by param

Let’s say subroutine xyz is defined as follows in C:

uint8_t xyz(uint8_t x){ return x;}

What value should we fill in in the following TTP assembly codeto implement this subroutine?

xyz: ldi a,___ add a,d ld a,(a) // this specifies the return value ld b,(d) inc d jmp b

Question 5

In the case of multiple parameters, the first parameter ispushed last. Consider the following C code:

x=sub1(2,3,4);

The call itself is implemented as follows:

ldi a,4dec dst (d),aldi a,3dec dst (d),aldi a,2dec dst (d),aldi a,retL1dec dst (d),ajmpi sub1retL1:

When accessed from the called subroutine, how does the addressof the first parameter relate to the address of the lastparameter?

Group of answer choices

a) the address of the first parameter is less than the addressof the last parameter

b) the address of the first parameter is greater than theaddress of the last parameter

c) the relationship between the addresses of parameters cannotbe determined by the caller code

d) the address of the first parameter equals the address of thelast parameter

question 6

Refer to the code in the previous question (repeated here):

ldi a,4dec dst (d),aldi a,3dec dst (d),aldi a,2dec dst (d),aldi a,retL1dec dst (d),ajmpi sub1retL1:

Assume the C prototype of sub1 is as follows:

uint8_t sub1(uint8_t a, uint8_t b, uint8_t c);

Now consider the subroutine (sub1) code as follows:

sub1: ldi a,2 add a,d // what is a at this point? … // some additional code that is not part of this question

What is register A right after the “add” instruction?

Group of answer choices

a) the address of parameter a (&a in C)

b) the value of parameter b

c) the return address

d) the address of parameter b (&b in C)

e) the value of parameter a

Expert Answer


Answer to Question4 Again, refer to the caller code as follows: ldi a,5 dec d st (d),a // push 5 ldi a,retL1 dec d st (d),a // pu…

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us