Lec17 - ECE 212 Digital Circuits II Wednesday, 2 April 2008...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 ECE 212 Digital Circuits II Wednesday, 2 April 2008 HW Set 17 : Problem 1 Dan S. Problem 2 No presenter Problem 3 Colin T. Problem 4 Ben T. Problem 5 Rytis U. Lecture 17 Goals To understand the significance of a Return Address To understand how the 6812 manages its stack. To understand how the stack is used to save Return Addresses. To understand how we can use the stack to save registers contents.
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 An asm Program main: ;Set up the parameters: ldaa #16 ; 16 Bytes to read; ldx #B ; Start address = B. ldy #PortE ; Read from Port E. bsr GetBytes ;Get the Bytes. ;Next set of parameters: ldx #B ; Start address = B; ldy #16 ; 16 Bytes to process; ldaa #0xFF ; Search for - 0. clrb ; Replace with + 0. bsr Replace ;Do the search-and-replace. bsr SendBytes ;Send the sixteen Bytes. jmp DBug12 GetBytes: . . . done: rts Replace: . . . rts SendBytes: . . . rts Main Subroutine Subroutine Subroutine Main, Subroutine Execution 11 main: 0113 8610 12 ldaa #16 0115 CE0103 13 ldx #B 0118 18CE100A 14 ldy #PortE 011C 8D11 15 bsr GetBytes 17 011E CE0103 18 ldx #B 0121 18CE0010 19 ldy #16 0125 86FF 20 ldaa #0xFF 0127 5F 21 clrb 0128 8D12 22 bsr Replace 23 012A 8D22 24 bsr SendBytes 012C 7EFF7C 25 jmp DBug12 36 GetBytes: 012F 4D 37 tsta . . . . . . 013B 39 45 rts 57 Replace: 013C 188C0000 58 cpy #0 . . . . . . 014D 39 68 rts 71 SendBytes: 014E CE0103 72 ldx #B . . . . . . 015C 39 80 rts .dump File: Program execution. Each time we call a subroutine: We must remember a Return Address (the address of the instruction following bsr ).
Background image of page 2
3 11 main: 0113 8610 12 ldaa #16 0115 CE0103 13 ldx #B 0118 18CE100A 14 ldy #PortE 011C 8D11 15 bsr GetBytes 17 011E CE0103 18 ldx #B 0121 18CE0010 19 ldy #16 0125 86FF 20 ldaa #0xFF 0127 5F 21 clrb 0128 8D12 22 bsr Replace 23 012A 8D22 24 bsr SendBytes 012C 7EFF7C 25 jmp DBug12 36 GetBytes: 012F 4D 37 tsta . . . . . . 013B 39 45 rts 57 Replace: 013C 188C0000 58 cpy #0 . . . . . . 014D 39 68 rts 71 SendBytes: 014E CE0103 72 ldx #B . . . . . . 015C 39 80 rts .dump File: Return Addresses bsr GetBytes bsr Replace bsr SendBytes Where do we save the return address? Return Address = 011E
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/17/2008 for the course ECE 212 taught by Professor Greco during the Spring '08 term at Lafayette.

Page1 / 11

Lec17 - ECE 212 Digital Circuits II Wednesday, 2 April 2008...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online