Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
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.






List of 32 messages in thread
TopicAuthorDate
Where can I ask newbie questions?            01/01/70 00:00      
   There is no such thing as a newbie question            01/01/70 00:00      
      the question            01/01/70 00:00      
         jump table            01/01/70 00:00      
            WOW, this is what I'm looking for!            01/01/70 00:00      
               *Very* Dangerous game!            01/01/70 00:00      
                  Agree with Dangerous            01/01/70 00:00      
                  PC            01/01/70 00:00      
               A and ACC            01/01/70 00:00      
                  ACC            01/01/70 00:00      
                     Different ways of getting to the same thing            01/01/70 00:00      
                        NO!            01/01/70 00:00      
                           OK, to put it another way...            01/01/70 00:00      
               jump table            01/01/70 00:00      
         the simple and stupid way...            01/01/70 00:00      
   One way to do this            01/01/70 00:00      
      Compare with JMP @A+PC            01/01/70 00:00      
         Yes there is            01/01/70 00:00      
         JMP @A+PC?            01/01/70 00:00      
            Oops            01/01/70 00:00      
   FAQ?            01/01/70 00:00      
      I think...            01/01/70 00:00      
         That's fine            01/01/70 00:00      
         English,            01/01/70 00:00      
   Newbie questions            01/01/70 00:00      
      Steve, I disagree            01/01/70 00:00      
   One question at a time            01/01/70 00:00      
   Agree to one question at time...            01/01/70 00:00      
      manipulating PC            01/01/70 00:00      
         PC            01/01/70 00:00      
   isnt an abuse ask more questions?            01/01/70 00:00      
      You said it yourself - start a new thread!            01/01/70 00:00      

Back to Subject List