Programming Models Flashcards

1
Q

Briefly describe the Instruction cycle.

A

it is the procedure of processing an instruction by the microprocessor.
Fetch->Decode->Execute

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does a processor programming model do?

A

It defines the instruction set:
1. What instructions are available.
2. How instructions access their operands.
3. How instructions are described in the processor’s assembly langauge.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the 3 types of instructions?

A

Data transfer Instructions, Data operation Instructions, Program Control Instructions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Give some examples of data transfer instructions and explain how they work.

A

Load data from memory (e.g RAm) into the microprocessor -> copy data (i.e LD)
Store data from the microprocessor into the memory -> copied into opposite direction (i.e ST)
Move data within the microprocessor -> move data from one microprocessor register to another (i.e. MOV)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Give some examples of Data operation instructions and explain how they work.

A

Arithemetic instructions -
ADD/SUB/MUL etc
instructions that increment/decrement (INC/DEC)
Floating point instructions that operate on floating point values. (FADD/FSUB etc)
Logic Instructions -
AND/OR/XOR etc
Shift Instructions -
The bits of a register or memory bytes to be shifted one bit to the left/right SL/SR/RR/RL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Give some examples of Program Control Instructions and explain how they work.

A

Jump and Branch Instructions -(condition or unconditional)
- JZ: jump if 0 flag is set
- JNZ: jump if 0 flag is not set
- JMP: unconditional jump: flags ignored
Comparison instructions -
- TEST: logic bitwise AND
Calls and Returns (conditional or unconditional)
- CALL: calls a function
- RET: return from a subroutine (function)
INRET: interrupt and retrun
Software Interrupt -
They are generated by devices outside of a microprocessor called a hardware interrupt (INT).
Exceptions and traps - triggered when valid instructions perform invalid operations e.g dividing by 0.
Halt instructions - causes the processor to stop executions e.g at the end of a program (HALT)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Describe what the Stack-Based Architecture consists of.

A

The Stack operates on a LIFO (last in first out) data structure and supports 2 operations:
PUSH- places value of the argument on top of the stack
POP- removes top element from stack.
The advantge to this is that program code takes little memory, you also don’t need to specify the address of the operands in memory or registers (for push you need to specify the operand). However, once the data is used, it’s gone.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the difference between Infix notation and Postfix notation?

A

Infix notation is the traditional way of representing expressions, with operation placed between operands e.g a+b
Postfix notation is when the operation is placed after the operands e.g a b +

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Why are expressions turned into postfux notation when being processed in a stack-based architecture?

A

So that the implementation of it in programs is easier.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Describe how the General Purpose Register Architecture works.

A

The instructions read their operands and write their result to a random access register file. GPRA allows the access of any register in any order by specifying the number (register ID) of the register. The main difference to the stack is that it will produce the same result adn won’t modify the state of the register file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do instructions work in the GPRA?

A

They need to specify the register that hold their input operands and the register that will hold the result. The most common format is the 3 operands instruction format e.g ADD r1 r2 r3 -> r2 + r3 = r1. The GPRA program can choose which values should be stored in the register file at any given time. GPRA has a better performance at the cost of needing more storage space.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do programs work in the GPRA?

A

There is less structure than in the stack, however there are also fewer restrictions on the order in which operations can be executed. Any order that places 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What mechanism is used to save/restore registers in stack ?

A

Since it is impossible to determine which registers may be safely used by the procedure , a mechanism to save/restore registers of the calling program has to be in place. Procedures need a way to figure out where they were called from so the execution can return to the calling program when the procedure completes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly