??? 01/14/08 10:06 Read: times |
#149420 - PC Responding to: ???'s previous message |
I'm not understanding what you want to achieve Chico. To set the PC to a value, you simply do a ljmp. As for reading the value of the PC, the value is implied - the piece of code to read the value is in a fixed memory location - you already know where that location is, so reading PC is of no value.
Here are some guesses as to what you might want to achieve... call pstring db "hello there",0 ... ... .. .. ; ; prints the string located in the code area following the call ; pstring: pop caller's address of the stack into DPTR print the string pointed to by dptr when finished, dptr should point to the code address just past the end of the string push dptr onto the stack (has the address to return to) ret another time you might want to manipulate addresses is with a pre-emptive task switcher where you might have an interrupt, but you want the interrupt to return to a different task. again, we manipulate the stack rather than the PC directly look carefully at Esko's code where he pushes and pops the return addresses off the stack. Short of doing a call or return, you really can't touch the PC directly - it doesn't make sense. If you can carefully describe what you want to do rather than ask us about changing the PC, then we can give a specific answer - you described a jump table, we showed you ways to do this. Probably the best way to learn about manipulating the stack is to use a simulator - that way you can step instruction by instruction and look what values are on the stack and how they are used. You can quickly see if you code does what you want or whether it falls over violently. |