:mortar_board: Sunway University BSc in CS notes :memo: (201701 intake)
Lecturer: Dr Adelina Tang Lai Toh
45 2E 20 53 61 6C 74
0011 0111
, so twos complement representation of -55 would be 1100 1000
then added 1
to become 1100 1001
0001 0111
, so -23 would be 11101001
Draw a Karnaugh map to simplify in Sum of Products (SOP) and Product of Sums (PSO) forms, if they exist.
Design the corresponding combinational circuits of the simplified forms in the previous question.
Differentiate between combinational and sequential circuits.
Combinational Logic Circuits | Sequential Logic Circuits |
---|---|
Output is a function of the present inputs (Time Independent Logic) | Output is a function of clock, present inputs and the previous states of the system. |
Do not have the ability to store data (state) | Have memory to store the present states that is sent as contro input (enable) for the next operation. |
It does not require any feedback. It simply outputs the input according to the logic designed. | It involves feedback from output to input that is stored in the memory for the next operation. |
Used mainly for Arithmetic and Boolean operations | Used for storing data |
Logic gates are elementary building blocks. | Flip flops (binary storage device) are the elementary building unit |
Independent of clock and hence does not require triggering to operate. | Clocked (triggered for operation with electronic pulses) |
Eg: Adder (1 + 0 = 1); Dependency only on present inputs ie. 1 and 0 | Eg. Counter (Previous OP + 1 = Current OP); Depedency on present input as well as previous input. |
What type of circuit has “two outputs which are complements of each other”?
Is it possible to write an instruction using only one address? How would you do this?
Explain the little-endianbyte ordering scheme.
Big Endian - most significant byte in smallest address
Address | Value |
---|---|
1000 | 90 |
1001 | AB |
1002 | 12 |
1003 | CD |
Little Endian - least significant byte in smallest address
Address | Value |
---|---|
1000 | CD |
1001 | 12 |
1002 | AB |
1003 | 90 |
Basically, difference is like right-to-left langauges vs left-to-right languages. Only difference in representation of data.
Differentiate between the “shift” and “rotate” operations.
ADD B
- Add contents of register B to accumulator.ADD a
- Look in memory at address a
for operand.MVI D,00
LDA C020
MOV C,M
INX H
MOV B,C
There are 5 types of addressing modes: (Parentheses are to be interpreted as contents of)
Addresing Mode | Algorithm | Main Advantage | Main Disadvantage |
---|---|---|---|
Immediate | Operand = A | No memory reference | Limited operand magnitude |
Direct | EA = A | Simple | Limited address space |
Indirect | EA = (A) | Large address space | Multiple memory references |
Register | EA = R | No memory reference | Limited address space |
Register Indirect | EA = (R) | Large address space | Extra memory reference |
Stack | EA = top of stack | No memory reference | Limited applicability |
Examples of addressing modes
Addresing Mode | Explanation | Example |
---|---|---|
Immediate | Operand is part of instruction | ADD 5 - Add 5 to accumulator |
Direct | Address field contains address of operand | ADD (a) - Add contents of memory location (a) to accumulator |
Indirect | Memory cell pointed to by address field contains the address of (pointer to) the oprand | ADD (a) - add contents of the memory location pointed to by (a) to accumulator ((a) is a pointer in a memory cell) |
Register | Operand is held in register named in address filed | MOV A, B - move contents of register B to register A |
Register Indirect | Operand is in memory location pointed to (pointer) by contents of register R | ADD (a) - add contents of the memory location pointed to by (a) to accumulator ((a) is a pointer in register) |
Stack | Operand is (implicitly) on top of stack | PUSH B - copy values from register B onto stack |
What are the differences between SRAM and DRAM in terms of speed and cost?
SRAM | Both | DRAM |
---|---|---|
low capacity | volatile | higher capacity |
used for CPU cache | used for computer RAM | |
expensive ($5000/GB) | cheaper ($50/GB) | |
low power consumption | higher power consumption |
Compare TWO key characteristics that can differentiate CISC and RISC.
CISC | RISC |
---|---|
Less register space | More register space |
More addressing modes | Less addressing modes |
Bigger instruction size | Smaller instruction size |
Software:
Notes: Acc = Accumulator
Opcode | Function | Mnemonic |
---|---|---|
MVI X, Y |
Moves Y (hex/dec) to X immediately | Move Immediately |
MOV X, Y |
Moves content in register Y to register X | Move |
ADD X |
Adds content in register X to Acc | Add |
SUB X |
Subtracts content in register X from Acc | Subtract |
LDA X |
Loads content from memory X into Acc | Load from Accumulator |
STA X |
Stores content in Acc to memory X | Store To Accumulator |
ADI X |
Increments Acc by X | Add to Immediately |
SUI X |
Decrements Acc by X | Subtract from Immediately |
INR X |
Increments Acc by 1 | Increment |
STAX X |
Store contents of Acc into memory address in register X | Store Accumulator To X |
LDAX X |
Load contents of memory address in register X to Acc | Load to Accumulator in X |
PUSH X |
Pushes content in register X to stack | Push to Stack |
POP X |
Retrieves content from top of stack into register X | Pop from Stack |
SPHL |
Forces stack pointer to point to memory address stored in register HL | Stack Pointer to register HL |
<name>: |
Loop name / Function name | |
JNZ <name> |
Ends loop / function | |
CALL <name> |
Runs code inside <name> |
|
RET |
Ends functions (required, similar to break; ) |
S - Z - AC - P - C
Flag | Name | Function |
---|---|---|
SF/S | Sign bit | works with C flag to show that result of operation is 0 |
Z | Zero | switched on if result of operation at Accumulator is 0 |
AC/AF | Auxilary carry | appears if a carry bit is used at 4th bit (exceeds 4 bits) |
P | Parity | appears if operation causes EVEN numbers of 1s in binary (Eg: 1010 , 1100 , 1110 1000 ) |
C | carry | appears if a carry is performed at 8th bit OR result is a 2’s complement (only if S = 1 as well) |
Notes: SF = 1
, C = 1
= negative operation result
Part A - Two Questions
Question 1 - MCQ (10m)
Question 2 - Discussion type (20m)
Part B - Choose TWO out of THREE questions (2x10m)