unctional block of code that follows it. .DEF temp=R16 ; .DSEG Results: .byte 1 Param1: .byte 1 Param2: .byte 1 .CSEG .ORG 0x0000 RJMP setup .ORG 0x100 setup: LDI temp, LOW(ramend) OUT SPL, temp LDI temp, HIGH(ramend) OUT SPH, temp main: ; Write a comment describing the next four lines of code LDI temp, 0x0f STS Param1, temp LDI temp, 0x10 STS Param2, temp ; Write a comment describing the next five lines of code CALL calculate LDS temp, Results end: NOP RJMP end calculate: ; Write a comment describing the next four lines of code PUSH r17 PUSH r18 PUSH r0 PUSH r1 ; Write a comment describing the next five lines of code LDS r17, Param1 LDS r18, Param2 MUL r17, r18 OR r0, r1 STS Results, r0 ; Write a comment describing the next five lines of code POP r1 POP r0 POP r18 POP r17 RET
Walk through the assembly program below. Add comments where indicated that describe what is happening for the functional block of code that follows it.
.DEF
temp=R16
;
.DSEG
Results: .byte 1
Param1: .byte 1
Param2: .byte 1
.CSEG
.ORG 0x0000
RJMP setup
.ORG 0x100
setup:
LDI temp, LOW(ramend)
OUT SPL, temp
LDI temp, HIGH(ramend)
OUT SPH, temp
main:
; Write a comment describing the next four lines of code
LDI temp, 0x0f
STS Param1, temp
LDI temp, 0x10
STS Param2, temp
; Write a comment describing the next five lines of code
CALL calculate
LDS temp, Results
end:
NOP
RJMP end
calculate:
; Write a comment describing the next four lines of code
PUSH r17
PUSH r18
PUSH r0
PUSH r1
; Write a comment describing the next five lines of code
LDS r17, Param1
LDS r18, Param2
MUL r17, r18
OR r0, r1
STS Results, r0
; Write a comment describing the next five lines of code
POP r1
POP r0
POP r18
POP r17
RET
Here we write comment of each line :
==============================================================================
Figure 1:
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images