instruction format
instruction format
• (3 + 4)[10(2 + 6) + 8]
• 34 + 2 6 + 10 * 8 + *
• 3 4 + 2 6 + 10 * 8 + *
6 10 8
4 2 2 8 8 80 80 88
3 3 7 7 7 7 7 7 7 7 616
Instruction Format
INSTRUCTION FORMAT
INSTRUCTION FORMAT
Instruction Fields
• Stack organization.
– PUSH and POP instructions which require an address field
» PUSH X /* TOS ← M[X] */
– Operation-type instructions do not need an address
» ADD
Influence of the number of addresses on computer
instruction
- X = (A + B) * (C + D) :
Three-Address Instructions
Program to evaluate X = (A + B) * (C + D) :
TWO-ADDRESS INSTRUCTIONS
Two-Address Instructions
Program to evaluate X = (A + B) * (C + D) :
LOAD A /* AC ← M[A] */
ADD B /* AC ← AC + M[B] */
STORE T /* M[T] ← AC */
LOAD C /* AC ← M[C] */
ADD D /* AC ← AC + M[D] */
MUL T /* AC ← AC * M[T] */
STORE X /* M[X] ← AC */
Instruction Format
ZERO-ADDRESS INSTRUCTIONS
Zero-Address Instructions
PUSHA /* TOS ← A */
PUSHB /* TOS ← B */
ADD /* TOS ← (A + B)*/
PUSHC /* TOS ← C */
PUSHD /* TOS ← D */
ADD /* TOS ← (C + D)*/
MUL /* TOS ← (C + D) * (A + B) */
POP X /* M[X] ← TOS */
A computer has 32-bit instructions and 12-bit addresses.
If there are 250 two-address instructions, how many one-
address instructions can be formulated?
8 12 12 32 bits
28 = 256 combinations.
256 – 250 = 6 combinations can be used for one address
6 x 212 12 32 bits
Opcode Address
One Address Instructions
X= A-B+C*(D*E-F)
G+H*K
a. Using a general register computer with three address
instructions.
b. Using a general register computer with two address
instructions.
c. Using an accumulator type computer with one address
instructions.
d. Using a stack organized computer with zero-address
operation instructions.
Addressing Modes
ADDRESSING MODES
Addressing Modes
* Specifies a rule for interpreting or modifying the address field of the instruction (before the
operand is actually referenced)
Immediate Mode
Instead of specifying the address of the operand, operand itself is specified
- No need to specify address in the instruction
- However, operand itself needs to be specified
- Sometimes, require more bits than the address
- Fast to acquire an operand
Register Mode
Address specified in the instruction is the register address
- Designated operand need to be in a register
- Shorter address than the memory address
- Saving address field in the instruction
- Faster to acquire an operand than the memory addressing
- EA = IR(R) (IR(R): Register field of IR)
Addressing Modes
399 450
XR = 100
400 700
AC
500 800
600 900
a. direct
Z=Y
a. indirect
Z =M[Y]
a. relative
Z= Y+W+2
a. indexed
Z = Y +W
Data Transfer and Manipulation
* Save the Return Address to get the address of the location in the Calling Program
upon exit from the Subroutine
INTERRUPT PROCEDURE
Interrupt Procedure and Subroutine Call
- The interrupt is usually initiated by an internal or
an external signal rather than from the execution of
an instruction (except for the software interrupt)
PROGRAM INTERRUPT
Types of Interrupts
External interrupts
External Interrupts initiated from the outside of CPU and Memory
- I/O Device -> Data transfer request or Data transfer complete
- Timing Device -> Timeout
- Power Failure
- Operator
Software Interrupts
Both External and Internal Interrupts are initiated by the computer HW.
Software Interrupts are initiated by the executing an instruction.
- Supervisor Call -> Switching from a user mode to the supervisor mode
-> Allows to execute a certain class of operations
which are not allowed in the user mode