Passing Parameters on the Stack (Example 10.5): m=r7, n=r4, p=r5 SRAM_BASE EQU Ox40000000 AREA PassbyStack, CODE, READONLY ENTRY LDR Sp, =SRAM_BASE MOV r1, #0x40000000 MOV 12, #2 STMIA sp), {r1, r2} ; push parameters onto stack BL saturate LDMDBSP), {r1, r2} ; pop results off stack ; Performs r4 = saturate32 (r5 << r7) STMIA spl, {r3-r7, r} ; LR on stack for reentrancy LDR r5, (sp, #-Ox20} LDR 17, (sp, #-O×1C} SATURATE ALGORITHM STR r4, (sp, #-0x20] LDMDBSP!, {r3-r7, pc} saturate ; get 1" parameter off stack ; get 2 parameter off stack ; move result to bottom of stack ; return END Instructions: For each of the following questions, you may change the three different chunks of code above, only where relevant to answer the question correctly. For all the STM and LDM instructions, instead of using the stack convention, have the corresponding IB, IA, DB, and DA too. 1. As these three pieces of code are written now, what is each's stack policy?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
SATURATE ALGORITHM:
;n = saturate32(p << m)
MOV r6, #0X7FFFFFFF
MOV n, p, LSL m
TEQ
EORNE n, r6, p, ASR #31
; if (pl=(n>>m))
;n=0X7FFFFFFF^sign(p)
P, n, ASR m
Passing Parameters in Registers (Example 10.3): m=r1, n=r2, p=r0
SRAM_BASE EQU Ox40000000
AREA PassbyReg, CODE, READONLY
ENTRY
SR, =SRAM_BASE
MOV r0, #0x40000000
MOV r1, #2
LDR
BL
; Performs r2 = saturate32 (ro << r1)
; r6 = scratch register
STMDBSPL. {r6, I ; LR on stack for reentrancy
saturate
saturate
SATURATE ALGORITHM
LDMIA sp!, {r6, pc} ; return
END
Passing Parameters by Reference (Example 10.4): m=r7, n=r4, p=r5
SRAM BASE EQU Ox40000000
AREA PassbyMem, CODE, READONLY
ENTRY
SR, =SRAM_BASE
r3, =SRAM_BASE+100
MOV r1, #0x40000000
MOV r2, #2
STMIA r3, (r1, r2}
LDR
; memory for param.
LDR
; save off parameters
BL
saturate
; Performs r4 = saturate32 (r5 << r7)
; r6 = scratch register
STMIA sp!, {r4-r7, I}; LR on stack for reentrancy
LDMIA r3, {r5, r7}
saturate.
; get parameters from memory
SATURATE ALGORITHM
STR r4, [r3]
LDMDBSP), {r4-r7, pc}
; move result to memory
; return
END
Transcribed Image Text:SATURATE ALGORITHM: ;n = saturate32(p << m) MOV r6, #0X7FFFFFFF MOV n, p, LSL m TEQ EORNE n, r6, p, ASR #31 ; if (pl=(n>>m)) ;n=0X7FFFFFFF^sign(p) P, n, ASR m Passing Parameters in Registers (Example 10.3): m=r1, n=r2, p=r0 SRAM_BASE EQU Ox40000000 AREA PassbyReg, CODE, READONLY ENTRY SR, =SRAM_BASE MOV r0, #0x40000000 MOV r1, #2 LDR BL ; Performs r2 = saturate32 (ro << r1) ; r6 = scratch register STMDBSPL. {r6, I ; LR on stack for reentrancy saturate saturate SATURATE ALGORITHM LDMIA sp!, {r6, pc} ; return END Passing Parameters by Reference (Example 10.4): m=r7, n=r4, p=r5 SRAM BASE EQU Ox40000000 AREA PassbyMem, CODE, READONLY ENTRY SR, =SRAM_BASE r3, =SRAM_BASE+100 MOV r1, #0x40000000 MOV r2, #2 STMIA r3, (r1, r2} LDR ; memory for param. LDR ; save off parameters BL saturate ; Performs r4 = saturate32 (r5 << r7) ; r6 = scratch register STMIA sp!, {r4-r7, I}; LR on stack for reentrancy LDMIA r3, {r5, r7} saturate. ; get parameters from memory SATURATE ALGORITHM STR r4, [r3] LDMDBSP), {r4-r7, pc} ; move result to memory ; return END
Passing Parameters on the Stack (Example 10.5): m=r7, n=r4, p=r5
• SRAM_BASE EQU Ox40000000
AREA PassbyStack, CODE, READONLY
ENTRY
LDR Sp, =SRAM_BASE
MOV r1, #0x40000000
MOV r2, #2
STMIA spl, {r1, r2} ; push parameters onto stack
BL
saturate
LDMDBSP), {r1, r2} ; pop results off stack
; Performs r4 = saturate32 (r5 << r7)
STMIA spl, {r3-r7, }; LR on stack for reentrancy
LDR r5, (sp, #-0x20}
LDR 17, (sp, #-0x1C}
SATURATE ALGORITHM
saturate
; get 1* parameter off stack
; get 2nd parameter off stack
STR r4, (sp, #-0x20]
LDMDBSP), {r3-r7, pc)
; move result to bottom of stack
; return
END
Instructions: For each of the following questions, you may change the three
different chunks of code above, only where relevant to answer the question
correctly. For all the STM and LDM instructions, instead of using the stack
convention, have the corresponding IB, IA, DB, and DA too.
1. As these three pieces of code are written now, what is each's stack policy?
Transcribed Image Text:Passing Parameters on the Stack (Example 10.5): m=r7, n=r4, p=r5 • SRAM_BASE EQU Ox40000000 AREA PassbyStack, CODE, READONLY ENTRY LDR Sp, =SRAM_BASE MOV r1, #0x40000000 MOV r2, #2 STMIA spl, {r1, r2} ; push parameters onto stack BL saturate LDMDBSP), {r1, r2} ; pop results off stack ; Performs r4 = saturate32 (r5 << r7) STMIA spl, {r3-r7, }; LR on stack for reentrancy LDR r5, (sp, #-0x20} LDR 17, (sp, #-0x1C} SATURATE ALGORITHM saturate ; get 1* parameter off stack ; get 2nd parameter off stack STR r4, (sp, #-0x20] LDMDBSP), {r3-r7, pc) ; move result to bottom of stack ; return END Instructions: For each of the following questions, you may change the three different chunks of code above, only where relevant to answer the question correctly. For all the STM and LDM instructions, instead of using the stack convention, have the corresponding IB, IA, DB, and DA too. 1. As these three pieces of code are written now, what is each's stack policy?
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY