Question: 9 . ( 5 0 pts ) . Build an assembly language subroutine named Normalize that will take an argument on the stack and transform
pts Build an assembly language subroutine named Normalize that will take an argument on
the stack and transform it as per the following description. If the value of the argument is odd, your
subroutine should just return the original argument on the stack. If the value of the argument is greater
than the value in R your subroutine should subtract the value in R from the value of the argument
and return the new value of the argument by placing it on the stack. If the value of the argument is less
than the value in R your subroutine should add the value of R to the value of the argument and
return the new value of the argument by placing it on the stack. Your subroutine must be placed at
address x in program memory and must use only instructions that are contained in the CS AVR
instruction subset. The following code shows how your subroutine will be used:
push R ; push R value onto stack
call Normalize ; Normalize the value
pop R ; put result into R
Note: Only these instructions should be used ADD, ADC, CP CPI, NEG, COM, AND, ANDI, EOR, OR ORI, LSR ASR, BRBC BRBS JMP RJMP CALL, RCALL, RET, RETI, MOV, IN OUT, LDI, LDS PUSH, POP, NOP, STS
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
