Instructions Instructions referred to as microinstructions in the

  • Slides: 3
Download presentation
Instructions • Instructions (referred to as micro-instructions in the book) specify a relatively simple

Instructions • Instructions (referred to as micro-instructions in the book) specify a relatively simple task to be executed • It is assumed that data are stored in memory called data_mem • Instructions are also stored in another memory called inst_mem • For example – move (x, y) means move contents of memory location x into y – add (x, y, z) means add contents of locations x and y and store result into location z – cmove (cx, y) means move a constant cx into location y – cadd (cx, y, z) means add constant cx and contents of memory location y and store result into memory location z – And similar instruction like for add for sub, and, or, xor. . – See Table 12. 9 in the book for more example 1

Another Type of Instructions • A collection of instructions is called an instruction set

Another Type of Instructions • A collection of instructions is called an instruction set • We operated on contents of memory locations or constants • In more recent instruction sets (RISC for example), operands for most instructions are supposed to be in registers only • Only instructions like LOAD/STORE work with memory operands • Instruction set include instructions like – LD R 5, A /* Load contents of memory location into register R 5 */ – ST R 5, A /* Store contents of R 5 into memory location R 5 */ – ADD R 3, R 4, R 5 /* Add contents of registers R 4 and R 5 and store the result into register R 3 */ – Similar instruction like Add such as SUB< AND< OR XOR • In these instructions only LD and STORE take more time 2

Using Instructions • Using the instructions we can write program • For example for

Using Instructions • Using the instructions we can write program • For example for expression like D = A * B + C will translated into the following program using first instruction set MUL (A, B, D) ADD (D, C, D) • If we use the second instruction set, the program will be LD R 1, A /* Get A into R 1*/ LD R 2, B /* Get B into R 2*/ MUL R 1, R 2 /* Multiply R 1, R 2, result into R 1 */ LD R 2, C /* Get C into R 2 */ ADD R 1, R 2 /* Add R 1 and R 2, result into R 1 */ ST R 1, D /* Store R 1 into D */ • These instructions are stored in program memory and executed using a data path one at a time 3