Lecture 2 Flashcards
Programming models
What is the instruction cycle?
The procedure of processing an instruction by the microprocessor
What does a programming model define?
- What instructions are avaılable
- How instructions access their operands
- How instructions are described in the processors assembly language
N.B. Processors with different programming models can offer similar sets of operations but may require VERY different approaches to programming
What is a data transfer instruction?
Operations that move data from one place to another. They DON’T modify data, just copies it to destination
What is a data operation instruction?
Instructions that modify the data values and store the result
What is a program control instruction?
Jump or branch instructions used to go into another part of the program. Jumps can be absolute or conditional (If else)
What are the different data transfer instructions?
Load data
Store data
Move data
Input data
Output data
What does Input data do?
Instructions that input data from the input device into the microprocessor (e.g. what key was pressed)
What does output data do?
Microprocessor copies data from one of its internal registers to and output device (e.g. show what key has been pressed)
What does load data do?
Copy data from memory intro microprocessors registers
What does store data do?
Similar to load data but data is copied in to opposite direction. Data is saved from internal microprocessor registers into the memory
What does move data do?
Move data from one microprocessor register to another
Explain how instructions use the stack
Instructions get their operands from the stack and write their results back to the stack
What are some advantages of stack based architecture?
Program code takes little memory
- No need to specify the address of the operands in memory or registers
- Push is one exception because it needs to specify the operand
What are stack based processors better suited for? Postfix or infix?
Postfix, writing programs for stack-based architectures is not easy
What is infix notation
a+b
What is postfix notation?
ab+
What is needed for an expression to be easy to implement in a stack-based architecture?
Convert it into postfix notation
What is a specific to a general purpose register architecture?
- The instructions read and writes to random access register file
- the register file allows the access of any register in any order by specifying the register ID
What is the main difference between stack based and general purpose register?
- Repeatedly reading a register will produce the same result and will not modify the state of the register file (which it will in stack-based)
- Programs can choose which values should be stored in the register file at any given time, allowing them to cache most accessed data (in stack, once the data has been used, it’s gone)
What does a GPR (general purpose register) need to specify?
- The register that hold their input operands
- And the register that will hold the result
ADD r1, r2, r3
What performance metric is the difference between GPR and stack-based?
GPR architectures have better performance but at the expense of needing more storage space for the programs
What is the difference between programming GPR architecture processor compared to stack-based?
There are fewer restrictions on the order in which the operations can be executed
- On a stack-based, instructions should execute in the order that would leave the operands for the next instructions on the top of the stack
- On GPR, any order that place the operands for the next instruction in the register file BEFORE that instruction executes is valid
- Operations that access different registers can be reordered without making the program invalid.
Compare Stack based and GPR architectures
Stack-based:
- Instructions take fewer bits to encode
- Reduced amount of memory taken up by programs
- Manages the use of register automatically
- Instruction set does not change if size of register file has changed
Still good for certain embedded systems
GPR:
With evolution of technology, the amount of space taken up by a program is less important
- Compilers for GPR achieve better performance with a given number of GPRs than those on stack-based architectures with same numbers of register. The compiler can choose which values to keep (Cache) in register file at any time
Used in modern computers