{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw13SLN

# hw13SLN - ECE 212 HW 13 SOLUTIONS p 1 of 10 ECE 212...

This preview shows pages 1–5. Sign up to view the full content.

ECE 212 HW 13 SOLUTIONS p 1 of 10 ECE 212 Homework Set 13 SOLUTIONS 1. For the given memory contents, determine the effect of each instruction (the instructions are executed in sequence). ` Location Contents 00FD 35 00FE 6E 00FF C8 0100 1F 0101 A9 0102 B2 0103 7E 0104 CD 0105 B2 A B X Y ?? ?? ???? ???? ldaa 0x105 ldab 0xFD ldx #0xFD ldx 0x101 ldx #0x101 ldaa 3,X ldab 0,X ldx 2,X Solution: A B X Y ?? ?? ???? ???? ldaa 0x105 B2 ?? ???? ???? ldab 0xFD B2 35 ???? ???? ldx #0xFD B2 35 00FD ???? ldx 0x101 B2 35 A9B2 ???? (X receives the contents of mem locs 0101, 0102) ldx #0x101 B2 35 0101 ???? ldaa 3,X CD 35 0101 ???? ldab 0,X CD A9 0101 ???? ldx 2,X CD A9 7ECD ???? (X receives the contents of mem locs 0103, 0104)

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

View Full Document
ECE 212 HW 13 SOLUTIONS p 2 of 10 2. Write a 6812 program to accept five Bytes from PortA and to put them into memory locations 0150 through 0154. Use indexed addressing. One Solution: main: ldx #0x150 ;Initialize a pointer to the first location. ldaa PortA ;Get a Byte, staa 1,X+ ; store it, and point to the next location. ldaa PortA ;Get the second Byte, staa 1,X+ ; and store it. ldaa PortA ;And the third Byte, staa 1,X+ ; ldaa PortA ; fourth Byte, staa 1,X+ ; ldaa PortA ; fifth Byte. staa 0,X ; jmp DBug12 ;All done. Another Solution: main: ldx #0x150 ;Initialize a pointer to the first location. movb PortA 1,X+ ;Get a Byte, store it, ; and point to the next location. movb PortA 1,X+ ;Same for next Byte, movb PortA 1,X+ ; third Byte, movb PortA 1,X+ ; fourth Byte, movb PortA 0,X ; and fifth. jmp DBug12 ;All done.
ECE 212 HW 13 SOLUTIONS p 3 of 10 3. Write a 6812 program to complement the contents of each Byte in memory locations 0160 through 0164. (Can you do this without reading the data into A or B?) One Solution: The instruction com can the complement the contents of a memory location. This instruction does not affect the contents of registers A or B. We can use indexed addressing to access the memory location. main: ldx #0x160 ;Initialize a pointer to the first location. com 1,X+ ;Complement a Byte, and point to the next ; location (0161). com 1,X+ ;Complement the Byte at location 0161, com 1,X+ ; 0162, com 1,X+ ; 0163, com 0,X ; 0164, jmp DBug12 ;All done.

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

View Full Document
ECE 212 HW 13 SOLUTIONS p 4 of 10 4. (a) Write a 6812 program to copy a block of memory: Copy the contents of location 0190 to location 01B0;
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}