Topic A Flashcards

1
Q

What are the levels in a personal computer system?

A

User → System/Application software → OS → Hardware

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

Describe The Von Neumann Model

A
  • Input device is used to load program instructions & data into memory
  • CPU fetches the program instructions from memory, processes the data and generates results
  • Results are sent to an output device
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the stored program concept?

A
  • That programs and data is both stored in memory.

- Programs are loaded into the CPU when they need to be executed

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

What is the role of the clock?

What are clock cycles measure in?`

A

To drive the CPU, it operates on a certain cycle in terms of speed of a CPU

Measure in Gigahertz

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

Name the components in a modern system

A
  • Clock
  • CPU
  • I/O devices
  • System BUs
  • Memory subsystem
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Describe how the components in a modern system cooperate

A
  • The clock drives the CPU, at every clock beat the CPU will fetch instructions from memory.
  • The CPU is connected to a system bus (set of wires).
  • All devices are connected to the same system bus. This transfers data between the CPU and everything else
  • The memory subsystem is connected to the system bus so the CPU can read/write data into memory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the system bus?

A

A collection of wires that allow communication between various components on the motherboard

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

What is the alternative to the system bus and how does it work?

A

The point-to-point system - where each component is wired to all the others
- don’t use this as it’s more expensive and complicated

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

What is bus contention?

A
  • Only one piece of data can be in one position on the bus at a time.
  • If all the buses want to communicate simultaneously, as would be normal in a modern system there must be a system to manage who has access to which bus when.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the 3 buses and what is their function?

A
  • Address bus: used to specify a memory address to be accessed in memory
  • Data bus: used to carry a value to be transferred
  • Control bus: used to tell the receiver what to do
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Give examples of I/O devices?

A
  • Audio and video cards
  • Printers
  • scanners
  • disk drives
  • keyboards
  • mouse
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

When performing I/O, what information does the CPU need to know?

A

it needs to know:

  • When a device is ready to receive / transmit
  • When a device has completed a request
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is polling?

A

Polling is periodically checking the device status of all the I/O devices
- so it knows when a device is ready to transmit and receive data and when it has completed a request.
(however this is not a good use of CPU time)

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

When are interrupts used regarding I/O?

A

A device sends a signal when it is ready, interrupting the CPU activity and causing an interrupt handler to be invoked

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

Prior to being processed what must happen to all data and programs?

A

They must be converted into binary form and brought into the computer memory (so it can be stored properly)

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

Name the 3 types of memory

A
  • RAM (Random access memory) allows you to read and write data to it randomly. it’s volatile
  • ROM (Read only memory) it’s non-volatile and stores system boot code
  • Flash allows you to read and write data to it. Non volatile, used in pen drives and SSDs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What does volatile mean?

A

Everything is lost when the power is turned off

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

What is stored in ROM?

A

A very small program that’s used to load the OS into RAM

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

How can we picture memory + explain the diagram

A
  • Filing cabinet, each file has an associated (byte) number.
  • can think of this as a sequence of ‘words’
  • each word holds its own content
  • each words has it’s own unique memory address, which points to four bytes (32 bits)
  • So each row on the diagram = 4 bytes of memory known as a word.
  • If we want to move to the next piece of data in memory we add 4 onto the memory address.
  • most modern systems are byte addressable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is a word formed from?

A
  • formed from one or more bytes
  • individual bits are zero-indexed from right to left
  • Bit zero is the least significant bit
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What are the components of the CPU

A
  • CU (control unit)
  • ALU (arithmetic logic unit)
  • Registers (16 in total)
  • 4 general purpose registers A,B,C,D
  • Instruction register and instruction pointer
  • Interface to main memory
  • MAR and MDR
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What does the control unit do?

A

it fetches instructions and works out what do with them

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

What does the ALU do?

A

Performs numeric and logical bit-manipulation operations.

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

What does the instruction pointer do?

A

The instruction pointer (or program counter) points to the next instruction to be executed

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

What does the MAR do?

A

The MAR stores the address of something we want to write to or retrieve from RAM

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

What does the MDR do?

A

The MDR stores the data retrieved from RAM that was in the address stored in the MAR

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

Why do we use registers?

A

It’s much easier to manipulate the registers than it is main memory, which is comparatively much slower to get to read/write to.

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

What are registers

A

They are temporary storage locations internal to the CPU

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

What does the Instruction register do?

A

It holds the current instruction to be executed

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

Which two registers are used to interface with main memory?

A

The MAR and MDR. The CPU manipulates these two registers. They can’t be accessed by programmers.

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

What are the steps of the Fetch Decode Execute Cycle

A

Step 1: Contents of the PC are copied into the MAR. The address in MAR is sent down the address bus to RAM
Step 2: Contents of specified memory address are sent down the data bus to the MBR. The PC is incremented by 1 to point to the next instruction.
Step 3: Contents of the MBR are copied to the CIR
Step 4: Decode Instruction register by splitting it into opcode/operand.
Step 5: Fetch any operands
Step 6: Carry out execution
Step 7: repeat process

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

How many bits would we add to increment the program counter in 32 and 64 bit systems?

A
  • Add 4 bits in a 32 bit system

- Add 8 bits in a 64 bit system

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

What does a Typical Instruction Set include?

A
  • Data transfer (load, store, push, pop)
  • Arithmetic (add, subtract, multiply, divide, etc…)
  • Logical (AND, OR, NOT, shift, rotate)
  • Test and compare
  • Control flow (conditional jump, unconditional jump, subroutine call/return)
  • Miscellaneous other
34
Q

What must happen to all high-level language code?

A

It must be translated into basic machine code instructions to be executed

35
Q

What is true about each individual CPU?

A

Each CPU has its own instruction set and each instruction will have a particular number associated with it.
- For example let 12 be the add instruction. If 12 represented as a bit pattern is in the IR, the CPU knows it needs to perform an add operation and that it needs to retrieve more area of memory to find the two things that it will be adding together.

36
Q

Difference between Machine Code and Assembly language

A
  • Machine code is the lowest level, it’s numbers stored as bytes/bit patterns
  • It’s difficult to learn to write in and read since you have to remember what every number represents
  • Assembly language is a more readable low level language as it uses mnemonics
  • Assembly language is directly tied to machine code
  • There will be some sort of translation to change a mnemonic such as ‘ADD’ into its associated Machine code
37
Q

What 2 things are instructions made of?

A
  • Opcode - the operation to be performed

- Operand - the data or memory location holding the data

38
Q

what is the structure of an operand specifier?

A

Source 1, Source 2, destination.

instructions have a well defined structure so CPU’s know how many data words to read

39
Q

What are the 4 addressing modes?

A
  • Immediate
  • Register
  • Direct
  • Register Indirect
40
Q

Why is it important that we know the addressing mode?

A
  • Where the operands are and how we need to access them depends on the addressing mode we’re using.
  • Often the operand is put into a register and we tell the CPU that that’s where the operand is.
41
Q

What is immediate addressing

A

The operand is encoded directly into the instruction. (e.g. a number - 6)

42
Q

What is register addressing

A

The operand resides in a CPU register

43
Q

What is direct addressing

A

The operand resides in a memory address in RAM

44
Q

What is register indirect addressing

A

The operand specifies a register which holds the memory address of the value we want

45
Q

What is a compiler?

A
  • A systems program which translates high level code into low level code
  • It does this by analysing the source code, checking for certain types of error and generating the equivalent object code.
46
Q

What does a person who builds a new high level language also have to build?

A

A compiler which will translate the HLL into machine code.

47
Q

What does putting your HHL code (which is saved as source code) through a compiler do?

A

It turns it into object code (machine code bytes stored in memory)

48
Q

What is the job of the linker?

A

To take your compiled object code, link it with somebody’s library code and produce the final executable program

49
Q

What may a single HHL statement convert to after it’s been compiled?

A

It may convert to many many low level instructions (a reason why programmers to prefer to program in HLL)

50
Q

Why don’t programmers write machine code directly in binary?

A

This is too difficult, time consuming and error prone

51
Q

What is assembly language?

A
  • Each assembly language statement corresponds to a single machine instruction
  • Opcodes are specified using mnemonics
  • Registers are given names (hence ECX, EBX, EAX…)
  • Addresses are specified using labels
52
Q

What can labels in assembly language point to?

A
  • Areas of memory where data might be stored

- Places in our code to jump to depending on circumstances

53
Q

What do we use to indicate comments with in assembly language?

A

We can use the semicolon ‘ ; ‘ to indicate any comments on our code

54
Q

What does an assembler do?

A

It translates assembly language into binary machine code

55
Q

How many intel x86 registers are there?

A

There are 4 registers inside the CPU:

  • EAX: accumulator register
  • EBX: base register
  • EBX: counter register
  • EDX: data register
56
Q

What is EAX?

A

A is the accumulator - most of the work is done here, it’s for general purpose data storage and computation

57
Q

What is ECX?

A

ECX has a special purpose when we’re doing loops, we can put a value in the ECX register and there’s an operation that uses it as the counter for the loops

58
Q

What is EPS?

A

EPS is the stack counter

59
Q

What does RAX, EAX, AH, AL and AX refer to in terms of bits in the accumulator?

A
RAX - all of the register
EAX - we will get the lowest 32 bits
AH - we will get the highest 8 bits of AX
AL - we will get the lowest 8 bits
AX - we will get the lowest 16 bits
60
Q

What is the layout of an assembly code operation?

A

opcode, operand, operand
-the first operand is the destination to store the values in and the second operation is the value that we’re storing in that destination

61
Q

What is a useful tip for writing assembly code programs?

A

It’s useful when writing code in assembly language to write it in a high level language first and then translate it into the low level code.

62
Q

What do we often use to do Conditions in Assembly Language?

A

We use flag registers in conjunction with jump instructions. The status of an operation is recorded in these flag registers.

63
Q

What are the common flag operations?

A

S: sign (indicates whether result is +ve or -ve)
Z: zero ( (indicates whether result is zero or not)
C: carry (indicates an arithmetic carry)
O: overflow (arithmetic overflow error)

64
Q

What is the syntax for an unconditional jump?

A

JMP

65
Q

When do conditional jumps make the jump?

A

If a specified condition holds

66
Q

What happens if the condition is false for a conditional jump?

A

The execution falls through to the next instruction

67
Q

What are jump statements equivalent to in HHLs

A

They are equivalent to if-else statements

68
Q

What are the 8 jump test flags?

A
JC - jump if carry flag is 1
JNC - jump if carry flag is 0
JZ - jump if zero flag is 1
JNZ - jump if zero flag is 0
JS - jump if Sign flag is 1
JNS - jump if Sign flag is 0
JO - jump if overflow flag is 1
JNO - jump if overflow flag is 0
69
Q

What does the CMP do?

A

It compares two values prior to a conditional jump

- internally it subtracts one value from another without changing the values but updating the flags

70
Q

What are the other CMP 6 jumps (not flags)?

A

JE - jump if first operand = second operand
JNE - jump if first operand =! second operand
JG/JNLE - jump if first operand is greater
JLE/JNG - jump if first operand is less or equal
JL/JNGE - jump if first operand is less
JGE/JNL - jump if first operand is greater or equal

71
Q

How can iteration be achieved in Assembly language?

A

By jumping backwards in the code

72
Q

How are While loops achieved in Assembly language?

A
  • a while loop simply repeats while a given condition is true
  • If the comparison at the start fails we move past the jump command immediately after.
73
Q

How are Do-while loops achieved in Assembly language?

A

Instead the condition is tested at the end so we always do the loop at least once

74
Q

How are For loops achieved in Assembly language?

A

They are implemented in exactly the same way as a while loop, however we can use the ECX or counter register.

75
Q

What can reversing the order of your code to?

A

if it doesn’t change the function can optimise it

76
Q

What does the special instruction LOOP do?

A

LOOP which will automatically decrease ECX and jump to the label (desired line) if ECX is not zero

77
Q

When do we use LOOP?

A

If we want to repeat something n times we can store the value n in ECX, set up a label at the start of the loop, the actions inside the loop and then put the instruct LOOP at the end of the code.

78
Q

How can we get the address of a variable in assembly language?

A

Use the LEA instruction (load effective address)
- put LEA followed by the name of the register, followed by a label pointing to an area of memory instead of getting the value of that variable in memory it will store the address instead.

79
Q

When do we use square brackets in assembly language?

A

if a register has a valid address stored in it already, it will retrieve whatever is located at that address

80
Q

How can we access the value pointed to by using register indirect addressing mode?

A
  • mov eax, [ebx]
  • it will go to the memory address that’s stored in EBX, it will look at the contents of that memory address and it will store it in the accumulator.
81
Q

If the memory address on the first item in an array is 1000 then in our high level language grades[0] is at the memory location 1000.

What is the memory location of the next element?

A

The next element is at 1004 because it’s 4 bytes further on in a 32 bit system.

grades[1] = 1004
grades[2] = 1008
82
Q

What do we do to increment the loop register by 1?

A

Add 4 to the counter register:

add ebx, 4