This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: ST Y+, r20 ;store result into memory at Y and increment Y DEC r16 BRNE outerloop Problem 3: As written, the loop breaks prior to performing the Fnal addition and only starts counting down from 30 to begin with. It sums the numbers 2-30, not 1-32. Because this value is too large to Ft in one byte, the value store in 0x0200 will be (2+3+. ..+29+30) mod 256 = 464 mod 256 = 208. Problem 4: Port D:0 Port D:4 1 1 Problem 5: Simply swap the appropriate memory locations: LDS r16, $0100 ;load into register r16 data at 0x0100 LDS r17, $0103 ;load into register r17 data at 0x0103 STS $0103, r16 ;set memory at 0x0103 to contents of r16 STS $0100, r17 ;set memory at 0x0100 to contents of r17 LDS r16, $0101 ;load into register r16 data at 0x0101 LDS r17, $0102 ;load into register r17 data at 0x0102 STS $0102, r16 ;set memory at 0x0102 to contents of r16 STS $0101, r17 ;set memory at 0x0101 to contents of r17...
View Full Document
- Fall '07
- r16, LDI, register r16