Anyone has any insight into how pic deals with storage of registers when entering a subroutine? There doesn't seem to be a designated stack pointer. Maybe use indirect addressing, and use the SFR as a stack pointer? Things would really get ugly when you have nested subroutines if we don't have a stack

Views: 44

Reply to This

Replies to This Discussion

actually, there probably is a stack, where the pic puts the return address when a subroutine is called, just no idea where it is

Storage of registers inst a problem. Theres only really one register (which is the working register) everything else is RAM/data memory. There probably is a stack for return addresses. No idea where that's located though 

My TA said it can deal with like 10 nested subroutines before u need to do anything manually regarding the return address. But i think if u need to save and restore a register you just use a temp variable

 

 yea so I've ask this question below, how do we make a temp. variable that can store things?

use res to reserve 1 byte of memory, that's what would do

test 0x70 udata_shr
test res 1

and then when I want to store something in W into test:
movewf test

is this correct?

I don't know what test 0x70 does, I think udata_shr automatically puts the register at the shared address located at the bottom of every bank. but yeah, movwf moves w into test

kk got it. btw is there an instruction to directly move the value in PORTA/B/C/D into a temp. varaible? I couldn't find one on the textbook.

 movf PORT, w movwf temp

guess must do it in two lines, thx!

RSS

© 2024   Created by PML.   Powered by

Badges  |  Report an Issue  |  Terms of Service