LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 930 users online 158934 members 1467 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Video | Dictionary | News | FAQ
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 / 64 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic

On Program Counter
program counter Register feature at assembly level
Replies: 2Last Post Aug. 3, 2005 3:49pm by Kragoth
Single page for this topic Email Print Favorite
( bsmanyam )


Novice
Reply
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.


5:12 am on Sep. 15, 2004 | Joined Sep. 2004 | 1 Days Active
Join to learn more about bsmanyam United States | 1 Posts | 11 Points
sakurag


Dairy Product Addict

Ad Free
Reply
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

-------
I've got spurs that jingle jangle jingle.
As I go riding merrily along.
And they sing, "Oh, ain't you glad you're single?"
And that song ain't so very far from wrong.


11:41 am on Sep. 15, 2004 | Joined Oct. 2002 | 460 Days Active
Join to learn more about sakurag Washington, United States | Straight Male | 1892 Posts | 8074 Points
Kragoth


Lawn Care Specialist
Reply
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...



-------
Best before date on end of packet


3:49 pm on Aug. 3, 2005 | Joined July 2005 | 7 Days Active
Join to learn more about Kragoth United Kingdom | Bisexual Male | 13 Posts | 84 Points
Single page for this topic Email Print Favorite

Quick Reply

You are signed in as our guest.

Looking for something else?
 

  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic