11_EEL4742-Notes#11 - -Using register to pass an address...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
EEL 4742- Embedded Systems Note#11 Possible address modes with the call immediate call #label PC Lable absolute call &label PC mem(Lable) indirect call label PC mem(Lable) Register call Rs PC Rs index call X(Rs) PC mem(X+Rs) indirect register call @Rs PC mem(Rs) indirect auto increment call @Rs+ PC mem(Rs), Rs Rs+1 Passing data (values and result) to a subroutine OR a function - by register STR mov.w value1, R6 mov.w value2, R5 call #add ED jmp ED add add.w Rs, R6 result returned in R6 Ret - Using stack( used in C , pascal for functions) STR mov.w value1, R6 push.w R6 mov.w value2, R6 push.w R6 call #add push.w R5 result in R5 ED jmp ED add pop.w R8 pop.w R9 pop.w R10 push.w R10 push.w R10 3 solutions here, Ret push return address and Ret, BR R8 branch to register that has the return address mov.w R8, PC update pc with return address, PC R8 so there are several ways of returning from a function. When there are many items to pass or return from a function, the address of the variables are passed
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: -Using register to pass an address STR mov.w #value1, R6 address if value 1 in R6 mov.w #value2, R5 address if value 2 in R5 call #add ED jmp ED add mov.w 0(R6), R8 mov.w 0(R5), R7 add.w R8, R9 Ret -Using the stack STR mov.w #value1, R6 push.w R6 mov.w #value2, R6 push.w R6 mov.w #Result, R6 push.w R6 call #add ED jmp ED add pop.w R5 ;Ret address pop.w R6 ;address of result pop.w R7 ;address of value2 push.w R8 ;address of value 1 mov.w 0(R7), R7 ;get value 2 mov.w 0(R8), R8 ;get value 1 add.w R7, R8 mov.w R8, 0(R6) push.w R5 Ret Argument list – the variables are included with the subroutine function. call SUB( A, B) .word A, B Dot follows the subroutine call STR call #add .word value1, value2 , Result ED jmp ED add pop.w R6 R6 address of value1 mov.w 0(R6), R8 R8 value1 incd.w R6 R6 R6+2 mov.w 0(R6), R9 R9 value2 incd.w R6 add.w R8, R9 mov.w R9, 0(R6) Result R9 incd.w R6, 0(R6) push.w R6 point R6 to the return address Ret...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern