Python Forum
difference between Instruction Pointer and opcode in a Stack data structure
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
difference between Instruction Pointer and opcode in a Stack data structure
#1
Hi, trying to learn code and i have an assignment in stack data structure, so I'm reading about everything that is in the assignment

but they mention both Instruction pointer and opcodes and i can't find documents about what sets them apart
Reply
#2
Hi, for me Wikipedia is usually a good place to start. So you can try with their article on opcode as well as their article on Program counter. Program counter is another, and I suppose more common, name for Instruction pointer.
Reply
#3
The instruction pointer is a value usually stored in a dedicated register.
The register has to be set to the memory location of the first 'op code' of the code.
This varies by computer, but is usually at a fixed point, and the instruction register is initialized (usually) to that point (in memory).
As the program progresses, the instruction pointer is auto incremented by the length of the instruction being executed, or may be modified by the code itself (as in a branch instruction)

An Op code is the instruction 'command' if you will. It has a fixed value, for example in an unconditional branch instruction
will have a fixed value (set by the processor), say 0x65. This op code may be (doesn't have to be) followed by any number of
arguments, which may include: memory address, length same as computer data buss for example 64 bits (8 bytes) and that followed by flags, port numbers, or any other needed arguments.
Reply
#4
(Sep-02-2018, 12:26 PM)Larz60+ Wrote: The instruction pointer is a value usually stored in a dedicated register.
The register has to be set to the memory location of the first 'op code' of the code.
This varies by computer, but is usually at a fixed point, and the instruction register is initialized (usually) to that point (in memory).
As the program progresses, the instruction pointer is auto incremented by the length of the instruction being executed, or may be modified by the code itself (as in a branch instruction)

An Op code is the instruction 'command' if you will. It has a fixed value, for example in an unconditional branch instruction
will have a fixed value (set by the processor), say 0x65. This op code may be (doesn't have to be) followed by any number of
arguments, which may include: memory address, length same as computer data buss for example 64 bits (4 bytes) and that followed by flags, port numbers, or any other needed arguments.
Thank you very much, got information from you which i didn't even get from the wiki :D!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020