Set 1 Flashcards
Checked by Matt. Covers everything above SA 1 on BPCompSci topic list
What are the advantages of RPN?
- Eliminates the need for brackets in sub-expressions
- There is no need for order of precedence of operators (DON’T MENTION BIDMAS)
- The expressions are in a form suitable for evaluation using a stack, as the expression can be evaluated from left to right
What is main memory?
Memory that is directly addressable by the processor
What is the system bus?
- A set of parallel wires connecting independent components of a computer system
- It is used to pass signals between the components.
- These signals can represent data, address, or control information.
What is the stored program concept?
Two parts:
(a) A program must be resident in main memory to be executed.
(b) Machine code instructions are fetched and executed serially (one at a time) by the processor.
What are the two types of stored program concept?
- Von Neumann (where data and instructions are stored in main memory)
- Harvard Architecture (where instructions and data are stored separately, using separate buses)
Why is Harvard Architecture sometimes used in preference to Von Neumann?
Von Neumann:
- Competition for resources as all share same bus
Harvard:
- Instructions and writing/reading data can take place in parallel so can be faster
- Avoid bottleneck of single data/address bus
- Instruction and data memory can have different word lengths
- Avoids possibility of data being executed as code, which is one method that can be exploited by hackers
Where is Harvard Architecture used?
Embedded systems and digital signal processing systems
Describe the role of the control unit
- To control operation of the fetch-execute cycle
- It controls fetching (or loading or storing) operations
- It determines the type of an instruction
- To execute (some) instructions
- To synchronise the operation of the processor
- To send control signals and commands to other components
- To control the transfer of data between registers
- To handle interrupts
Describe the fetch part of the fetch decode execute cycle
Fetch:
- Contents of Program Counter transferred to Memory Address Register
- Address bus used to transfer this address to main memory
- Read signal sent along control bus
- Transfer of main memory content uses the data bus
- Contents of addressed memory location loaded into the Memory Buffer Register
- Contents of memory buffer register are copied to the current instruction register
- Increment Program Counter (part of Fetch stage, but not directly involved in fetching an instruction)
Describe the decode part of the fetch decode execute cycle
Decode:
- Instruction to decode held by the Current Instruction Register
- The control unit decodes the instruction
- Instruction split into opcode and operand(s)
Describe the execute part of the fetch decode execute cycle
Execute:
- If necessary, data is fetched or stored
- The opcode identifies the type of operation to be performed by the processor
- The operation (identified by the opcode) is performed by the control unit.
- The ALU is used for calculation (or comparisons)
- The result (may be) stored in a register (or main memory)
- The status register is updated
- If a branch is required then the program counter is updated
- The control bus will transfer signals to other components to initiate or sequence actions
How would you subtract a binary number A from a binary number B?
Convert A into -A using two’s complement. Then use binary addition with -A and B.
Why use hexadecimal instead of binary?
- Easier for humans to read/write/remember
- More compact representation
- Fewer digits required for the same value
- Less screen space
(NOT BECAUSE IT TAKES LESS MEMORY SPACE. IT DOESN’T TAKE LESS STORAGE SPACE!)
What is the data bus used for? What is its direction?
The data bus is used to transfer data between components.
The data bus is bidirectional
What is the address bus used for? What is its direction?
The address bus is used to transfer memory addresses and I/O (input output) locations.
The address bus is unidirectional from the processor
What is the control bus used for? What is its direction?
*The control bus is used to transport control signals between components.
*Indicate that a memory write is occurring
*Transfer clock signal
*Indicate the number of bits being transferred
*Receive transfer acknowledgement
*Send signal to request use of system bus
*Receive signal granting use of system bus
*The control bus is bidirectional
Give three examples of control signals
- Clock signals
- Memory read
- Memory write
What is the difference between volatile and non-volatile memory
- Volatile memory maintains its data only while the device is powered.
- Non-volatile memory retains stored information even after power is removed
Give an example of non-volatile main memory
ROM (Read Only Memory)
What is the instruction set?
- The set of binary codes for the machine operations that a processor has been designed to perform.
- It is specific to the processor
What is the purpose of main memory?
Main Memory holds the instructions and data currently being used by the processes.
What is the ALU?
The Arithmetic Logic Unit is the part of the CPU that is responsible for executing arithmetic operations (e.g. addition, subtraction, binary shifts) and logic comparisons (e.g. Or / And / Not)
What is a register?
Extremely fast, very small, memory in the processor for temporary storage of binary values
What does the program counter do?
Stores the address of the next instruction to be executed
What does the MAR do?
- Temporarily holds the address of the memory location that data will be read/written to
- The MAR is the processor’s direct connection to the address bus for accessing main memory
- Holds the address of the instruction in the fetch stage as it is fetched
What does the MBR do?
- Temporarily stores data read from or written to main memory
- The MBR is the processor’s direct connection to the data bus for accessing main memory
- Holds the instruction in the fetch stage before it is copied into the CIR
What is the role of the CIR in the FDE cycle?
- Stores the recently fetched instruction to be decoded by the control unit before it is executed
What information is stored in the status register?
- The status register contains many bits (binary flags) that are set (1) or cleared (0) depending on the result of an instruction
- Each bit represents a boolean value, for example if an overflow error has occurred
What is the purpose of general purpose registers?
- Have no specific value stored
- Usually used as temporary storage while performing arithmetic operations
- Often store the operands of processor instructions
4 reasons secondary storage is needed
- Main memory is volatile, so secondary storage needed to store files that are needed multiple times
- Secondary storage can be used to store larger files, as it usually has a much higher capacity than main memory
- Secondary storage can be used for virtual memory
- Main memory is expensive
4 advantages of Harvard architecture
- Instruction and data can be accessed simultaneously
- Instruction and data memory can have different word lengths
- Different technologies can be used to implement instruction and data memory
- For systems with a predetermined use, instruction memory can be implemented as ROM which protects the programs from hacking
What is the significance of the leftmost bit in two’s complement?
- The most significant bit (leftmost) is the sign bit, which represents a negative number when set to 1
- The MSB also contributes to the value of the number
What is 1111…111 in two’s complement binary?
-1
Range of an 8-bit number represented as:
1. unsigned binary number
2. two’s complement number
- Unsigned: 0 to 255
- Two’s complement: -128 to 127
An 8-bit two’s complement binary number can be between ___ and ___
-128 and 127
How to turn a negative number into its positive version in two’s complement (and vice versa)?
- From the right, every bit up to and including the first 1 stays the same.
- Everything else gets flipped.
(This is the same as flipping every bit then adding 1)
Where is Von Neumann architecture used?
General purpose computing systems
What is an identifier in the following examples?
static void SetValue(int num){};
static string name;
SetValue
name
num
(Notice there is no other code given).
What is iteration?
Where a code block is repeated through a ‘for’ loop or a ‘foreach’ loop
What is a selection structure?
Either an ‘if’ or a ‘switch’
What values does the following code generate?
int num = random.Next(1,100)
Integers from 1 - 99
What is nested selection?
Where you have an if within an if
What is nested iteration?
Where you have a for loop within a for loop
In the following code what is the highest value of the counting variable i reached:
for(int i = 0; i < 10; i++)
{
Console.WriteLine(i);
}
The highest value of i printed to the console is 9, but i gets to 10 and then the condition ( i < 10) is no longer met and the for loop exits
What are the steps for converting postfix to infix?
- Convert “num num op” triplets one at a time, adding brackets each time
- Remove any unnecessary brackets
Alternatively:
- From left to right push numbers into a stack
- When you reach an operator pop the last two numbers (or expressions) off the stack and apply the operator
- push the result back onto the stack
(Note that in this case to ‘apply’ an operator you should not evaluate e.g. 3 4 + -> 3 + 4 NOT 7)
What are the steps for converting infix to postfix?
- Add brackets around every operation
- Draw arrow from operator to end of its bracket
- Write expression, keeping numbers in the same order
What is concatenation?
When two string data type variables are merged together into a single variable
Describe the role of an I/O controller
Allows processor to communicate with a peripheral using an I/O port
Allows peripheral to appear as a set of registers / memory locations to the processor
Translates data received from a peripheral into a form that can be processed by the computer
Buffer data being received from a peripheral so the processor does not have to wait for it
Allows new peripherals to be added without having to redesign the processor
Allows peripheral designers to create new peripherals to one common interface standard
To carry out some of the I/O related processing
To check that data received from peripherals is not corrupted
Implements the protocols used by I/O devices for communication
Generates an interrupt when data is ready to be transferred from an I/O device