LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 588 users online 224579 members 1534 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
zamrambo
6.21.08
Mood: Smart
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
4 online / 31 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Adding Reply

Quoting Post
Archived Topic: It will not be bumped to the top of the forum.
Topic On Program Counter
Membername   Not a member? Sign Up Free (takes 20 seconds)
Password   Forgotten your password?
Post

Font:   Size:   Color:

FAQ Keyword Search:
Post Options
Favorites Manager
Notify me of new replies to this topic by email
Notify me of new replies to this topic by private message
Original Post
bsmanyam Posted 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.

Replies
Kragoth Posted 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...

sakurag Posted 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

All 2 previous replies displayed.