Lecture 8 - More on Sigma16 Flashcards

1
Q

When is AND true?

A

if both operands are true

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

What is OR false?

A

if both operands are false

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

When is XOR true?

A

if both operands are different.

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

How do you work out the bitwise XOR of 2 8-bit words?

A

Compare the binary numbers. If they are the same put 0 and if they are different put 1

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

When is bitwise AND useful and how would it be used?**

A

It is useful when you want to isolate a particular bit

Eg., 4 most significant bits.

If we bitwise AND $F0 to the word you want to isolate the 4 most signficant bits in $7D.
$F0 = 1111 0000
$7D = 0111 1101
Since ANDing any bit with 0 gives 0 and ANDing any bit with 1 leaves the bit unchanged we can mask the bits we aren’t interested in so the
bitwise-AND = 0111 0000

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

What RRR instructions DON’T work with unsigned numbers?

A

MUL, DIV, CMPGT, CMPLT

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

What instructions work for non-numerics?

A

CMPEQ

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

What is special about R15?

A

The remainder from DIV always goes in here

Anything in there is overwritten

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

What is special about R0?

A

It is always 0

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

What is an instruction cycle?

A

The sequence of events & time involved in fetching & executing an instruction.

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

What is a memory cycle?

A

The time involved in reading/writing a single word from & to a single memory location (over the data bus)

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

How many memory cycles are involved in an instruction cycle?*

A

An instruction cycle may involve several memory cycles:

RRR takes 1 memory cycle (fetch)

RX takes 2 memory cycles
(except for LOAD and STORE which take 3 memory cycles)

So generally RX instructions are twice as slow as RRR instructions

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

What 2 instructions will you always find in the CPU?

A

Instruction Register: contains the operation word of the instruction being executed
Program counter: the address of the next instruction that will be executed.

It can be thought of as an index in an array of memory

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

What 2 registers are specific to Sigma16?

A

Instruction register: An address register contains the target address (EA) specified in an RX or X instruction
Data register: holds temporary data.

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

How do you describe the speed of memory cycles?

A

Accessing memory is a relatively slow process.

RRR instructions are 1 memory cycle because they are already on the circuit.

RX instructions generally take 2 memory cycles.
1 . to find out they are an RX instruction eg., JUMP
2. to find out where to go

LOAD & STORE take 3 memory cycles.

  1. to find out they are a LOAD/STORE
  2. to find out what they need to LOAD/STORE
  3. go to memory to load/store it
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does shiftl and shfitr mean?

A

If we have Ra, Rb, Rc: shiftl shifts Rb left by Rc places and stores in Ra. We add zeroes to the end of Ra for the spaces that we’ve shifted and on the other side, the bits are shifted out and dropped off.

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

How many memory cycles does JUMP instruction take?

A

To fetch it, it has two words of machine code.

So two memory cycles

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

What questions do we need to ask when examining the machine code instructions on a new CPU?

A

1) how many memory cycles are needed to fetch the whole instruction?
2) How many cycles are needed to fetch or store data?
3) How many independent memory locations can the instruction access?

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

Why can’t we have multiple types of instructions in a CPU?

A

Many complex instructions mean a long operation word and a complex CU.
A CU with many instruction types is slower than a simple one with few types

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

What is RISC?

A

Reduced instruction set computer

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

Why not have instructions of multiple types in a CPU?

A

Complex instructions mean a long operation word and a complex control unit.
Complex CU will be slower than a simple one with few types.

22
Q

What design does Sigma16 use?

A

RISC

23
Q

What are the benefits of RISC?

A
  1. Simple and limited number of the instruction set
  2. Prevents most instructions from accessing memory, except for LOAD and STORE
  3. Internal registers are used for arthmetic & logical operations to make it as fast as possible.
  4. Simple fast control unit
24
Q

What is a virtual machine?

A

it’s a software model of a machine that may or may not exist as hardware.

25
Q

What is the hypervisor used for?

A

It’s a software that is often run on the host to create and manage new guests that can be complete copies of real machines.

26
Q

Why are virtual machines useful?

A

They allow a certain amount of protection.
It allows us to do certain experiments that might be dangerous to do on our own comp.
Confine sensitive activities.

27
Q

What happens if a VM crashes?

A

The host will usually be fine and so will the hypervisor.

28
Q

What is a subroutine?

A

A low-level structure that supports HLL.

Rather than repeating instructions in memory, we store one copy of the instruction in memory, and call it using a JUMP instruction, it runs and then once this has ran return back to the instruction after the call.This repeated each time it is called.

29
Q

What is the return address?

A

After the subroutine is called, we must return to the return address.

30
Q

How do we know where to jump back to after running a subroutine?

A

Use Jump and Link (JAL). JAL stores the return address in Rf, if we have:
JAL Rf, work[R0]

31
Q

Can you have subroutines inside subroutines?

A

Yes, these are called nested subroutine calls

32
Q

Why does an ordinary JUMP not work for a subroutine?

A

Because the location it jumps to is a variable, not a constant.

33
Q

How many memory cycles does an RRR instruction take? Explain.

A

RRR instructions are 1 memory cycle because they are already on the circuit.

34
Q

How many memory cycles does an RX instruction take? Explain.

A

RX instructions generally take 2 memory cycles.
1 . to find out they are an RX instruction eg., JUMP
2. to find out where to go

35
Q

How many memory cycles does an LOAD/STORE instruction take? Explain.

A

LOAD & STORE take 3 memory cycles.

  1. to find out they are a LOAD/STORE
  2. to find out what they need to LOAD/STORE
  3. go to memory to load/store it
36
Q

What is a 3 address instruction?

A

Performing & storing them in 1 go without loading them into registers.

THINK: doing the cooking in the cupboard

37
Q

What are the pros & cons of 3 address instruction? What happened as a result of these?

A

Pros: easier for the programmer because there are less instructions to write

Cons: takes the computer longer to process instructions

Instruction set reduced to a small, but powerful size. You need to write slightly more code eg., LOAD, but doesn’t have check loads of instructions just RRR or RX.

38
Q

How do you count how fast or slow a memory cycle was?

A

Everytime you see…

  • RRR its 1
  • RX it 2
    Load or Store 3
39
Q

Where should we store many nested subroutine calls?

A

In memory

40
Q

Where are the address of the stack bottom and stack top originally set to?

A

The bottom address. At this point the stack is empty.

After a subroutine call, store return address on stack and increment the stack pointer (usually points to one above the stack top)

41
Q

what kind of data structure is a stack (lifo)?

A

LIFO (last in first out)

** It’s like pilling things on top of each other & someone asks you to pick something on the top!

42
Q

What is a stack?

A

A stack is set up and maintained by a programmer.

Unlike an array, a stack can grow and shrink (dynamic).

Occupies consecutive memory locations.

The first address is the stack bottom, the last one is the stack top (grows upwards in memory).

**Its like pilling things on top of each other & someone asks you to pick something on the top!

Don’t indent like an array, it just gives you the thing of the top which is why its good for storing the return address of the subroutine.

43
Q

What part of the stack can you access?

A

The only thing you can access is the top of the stack which works perfectly for nested subroutines.

44
Q

What is a PUSH operation?

A

storing an item on the stack

eg., save the return address

45
Q

What is a PULL or POP operation?

A

Pulling an item from the stack which is always the last one that has been pushed

eg. retrieve the return address

46
Q

What is a stack overflow?

A

Undesirable condition in which a particular computer program tries to use more memory space than the call stack has available.

47
Q

What happens if a JAL call is made while in a subroutine?

A

Return address overwritten with a new return address

Must place the return address onto the stack (memory)

48
Q

What tracks the stack top?

A

A register called the stack pointer (SP) which contains its current address.

49
Q

When the stack is empty, initially the stack top and bottom are the same so…..

A

the stack pointer is set to the stack bottom because that is also where the stack pointer is.

50
Q

Which direction does the stack grow in Sigma16? Is there an alternative way?

A

The stack grows upwards in Sigma16 & is maintained by the programmer

But many CPU designs grow downwards in memory so the stack address is at a lower address than the stack bottom.

51
Q

How do tell if a number is odd/even?

A

Use bitwiseAND.

Mask: 0000 0001

        1001   0111 MASK 0000 0001

/// need to check this if it is odd or even

one will have 00000001
one will have 00000000

Not sure which**

52
Q

How many words are in these:

  1. LEA R1,0[R0]
  2. ADD R1, R0, R0
A
  1. 2 words of machinie code
  2. 1 word of machine code

Both mean the same thing