# note8 - CSCI 120 Introduction to Computation Inside a...

This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSCI 120 Introduction to Computation Inside a computer (cont.) (draft) Saad Mneimneh Visiting Professor Hunter College of CUNY 1 Example instruction set Each instruction is identified by a unique bit pattern (called the opcode) and some operands depending on the type of the instruction. For instance, we as- sume just for the sake of illustration that instructions are 16 bit long and that the first 4 bits represent the opcode (i.e. determines what the instruction is). The remaining 12 bits represent the operands depending on the type of the in- struction. Data transfer Register Memory //// | {z } //// | {z } //////// | {z } opcode register memory/operand e.g. Load register with memory location: LOAD R (value) MEM 0001 | {z } //// | {z } //////// | {z } opcode register memory Load register with operand: LOAD R (value) OP 0010 | {z } //// | {z } //////// | {z } opcode register operand Store register in memory location: STORE R (value) MEM 0011 | {z } //// | {z } //////// | {z } opcode register memory Data transfer Register Register //// | {z } 0000 //// | {z } //// | {z } opcode register register e.g. Copy data from register R to register S: COPY R S 0100 | {z } 0000 //// | {z } //// | {z } opcode R S Arithmetic/logical Register, Register, Register //// | {z } //// | {z } //// | {z } //// | {z } opcode register register register e.g. Add values in registers R and S and put result in register T: ADD R S T 0101 | {z } //// | {z } //// | {z } //// | {z } opcode R S T If the value in R &gt; that in S put 1 in T, else put 0 in T: CMP R S T 0110 | {z } //// | {z } //// | {z } //// | {z } opcode R S T If the value in R = that in S put 1 in T, else put 0 in T: EQ R S T 0111 | {z } //// | {z } //// | {z } //// | {z } opcode R S T AND the bit patterns in registers R and S and put result in register T: AND R S T 1000 | {z } //// | {z } //// | {z } //// | {z } opcode R S T OR the bit patterns in registers R and S and put result in register T: OR R S T 1001 | {z } //// | {z } //// | {z } //// | {z } opcode R S T NOT the bit pattern in register R and put result in register S: NOT R S 1010 | {z } 0000 //// | {z } //// | {z } opcode R S Control e.g. Jump to memory location if the value in register R is not 0, else continue: JUMP R (value) MEM 1011 | {z } //// | {z } //////// | {z } opcode R memory Halt: HALT 1100 | {z } 0000 0000 0000 opcode Therefore, the above fictitious (and over simplified) instruction set assumes that the machine has 16 registers (from 0000 to 1111) and 256 memory locations (from 00000000 to 11111111). Moreover, it assumes that the size of each register (also each operand) is 8 bits, i.e. 1 byte (because of instruction 2). 2 The wolf, the sheep, and the lettuce A boy wants to cross the river and transport a wolf, a sheep, and a lettuce to the other side. However, he has a small boat, and can carry only one item at a time. Therefore, he has to make several trips. But if the sheep and lettuce are left unattended, the sheep will eat the lettuce. If the wolf and the sheep are leftleft unattended, the sheep will eat the lettuce....
View Full Document

## This note was uploaded on 03/27/2010 for the course CSCI 120 taught by Professor Saadmneimneh during the Spring '09 term at CUNY Hunter.

### Page1 / 9

note8 - CSCI 120 Introduction to Computation Inside a...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online