Week 4 Flashcards
(36 cards)
What do machine code instructions contain?
- Some operation (op-code) such as add, jump etc.
- Necessary auxiliary info (where to get the operands, store results, where to jump to)
Where are instructions held?
In memory (as consecutive addresses) as one or more words.
What is the op-code?
It’s part of the operation word. It tells the control unit (CU) which operation this is e.g. ADD, MULTIPLY etc
How do we prevent instructions from becoming too long?
Restrictions may be imposed on where a particular instruction can be accessed.
What are addressing modes in the CPU design?
They specify where an operand for an instruction is to be found or a result should be stored. There are 5 common examples:
1) immediate, e.g. ADD 2
2) Absolute, e.g. gives the numeric address of the memory location involved
3) Register indirect, e.g. tells the control unit to go to the register you specify and fully from memory the value correlating to the address
4) Indexed addressing, e.g. take the base address (memory address) and add to the number in the register.
What 3 things does Sigma 16 consist of?
It consists of:
- 16 registers (R0…R15 where R0 is always 0)
- the Program Counter
- 16-bit memory locations (16-bit memory locations with addresses 0000_16 to ffff_16)
Where are operands located?
In any memory location or register file register.
What is the effective address?
Where the operand is stored (either in memory location or reg file reg).
What is Sigma-16?
Virtual CPU (runs as software, not hardware), everything is 16-bits.
What is the op-field in Sigma 16?
The most significant 4-bits of the operation word (which is 16-bits long) is called the op-field.
What addressing modes are used in Sigma-16?
Register addressing and indexed addressing
What are the three Sigma 16 instruction formats?
RRR (Register Register Register)
RX
X
how many op codes are there in RRR instruction format?
14: \+ - x % compare less than compare equals compare greater than bitwise boolean: inv, and, or, xor logic shifts: shift left, shift right trap
Are all numbers in RRR 16 bit twos-complement or unsigned?
2’s complement
Which addressing mode does RRR instruction use?
register addressing
e.g. ADD R_x,R_y,R_z
What is assembly language?
A list of assembly language statements (gets translated into machine code instruction) and occasionally assembler directives (does not get translated to MC, it’s rarely used). It’s simply an instruction to the assembly program to do something.
How are assembly language statements constructed?
Label Mnemonic Operands ;Comment
- Label is chosen by the programmer. If there’s no label, make a space.
- Mnemonic: short name for the instruction
- Comment: optional, starts with ;
- for an RRR, the operand field always lists the 3 registers Rd,Ra,Rb (no spaces).
How do we denote a hexadecimal number, e.g. 100_16?
$100
What does the DATA directive (type of assembler directive) do?
Allows data to be preset in specific memory.
e.g.
x DATA $3000 ;Comment
Gives the label x to the next available memory location and initialises it to $3000.
It’s now possible for other instructions to use the label x as a variable.
How many RX Instructions are there?
It has 6 instructions.
How are RX instructions composed?
op code, d, a and b.
d and a are needed to specify registers.
b is not. We put a value in the b field (1,2,3) to differentiate between the RX instructions. This is the extension of the op-code.
op code is F (1111)
What are the six RX instructions?
LEA Load effective address - loads constants into the register file LOAD - copies data from memory STORE JUMP False JUMP True Jump and link
What do the RX parameters stand for?
X - memory address/effective address
R - register
What is a destination register
d field