|
-- Posted by bsmanyam at 5:12 am on Sep. 15, 2004
As with the definition, program counter (also called the instruction pointer in some computers) is a register in a computer processor which indicates where the computer is in its instruction sequence. Is there any possiblility/chance at the assembly level to get, manipulate the value of the program counter register. Is it wasn't easy to change the value at the very low-level of system?? With C programming this facility can be incorporated and I need some pointers to implement the above said at the Low-level.
-- Posted by sakurag at 11:41 am on Sep. 15, 2004
Can you push the value of [IP] (or PC or whatever languages you are using for the program/instruction counter/pointer) onto the stack to read it. Then to modify it, can you change the address pointed to currently by it to the address of whatever you wanted. I don't think you can do just a MOV
-- Posted by Kragoth at 3:49 pm on Aug. 3, 2005
On some architectures the program counter (PC or IP) can be manipulated just like a general register (for example the DEC PDP 11, one of the first 16-bit machines -- yonks old!!; also the IBM mainframe I think? with BAL and BALR), but most instruction sets treat the PC as a special-purpose register and only provide Jump/Branch/Call/Return, because careless fiddling with the PC can send the program off into crash-mode :-( MOV PC,EAX can be simulated with JMP [EAX] or whatever, or by pushing the new address onto the stack and doing a RET (you can also load the PSW at the same time by doing an IRET) One nice thing about the PDP-11 was you could auto-increment/auto-decrement the PC for fetching parameters inline, or trashing the whole of memory by doing MOV (PC)--, (PC)-- which copied itself thru the whole of memory *backwards* until it fell off at location $0000 hehehe...
|