CS401 Assembly Notes Ch1 To Ch5
CS401 Assembly Notes Ch1 To Ch5
Programming (Chapters 1 to 5)
These notes include topic-wise explanations, summaries, code examples, and possible
MCQs.
Topics Covered:
- Basic Computer Architecture
- Registers
- Instruction Groups
- Intel iAPX88 Architecture
- History of Intel Processors
- Register Architecture
- First Assembly Program
- Segmented Memory Model
Summary:
- Explains how a computer communicates using Address, Data, and Control buses.
- Introduces registers like AX, BX, CX, DX, IP, SP, etc.
- Mnemonics are readable forms of machine instructions (e.g., MOV, ADD).
- Segment:Offset pair is used to calculate physical addresses.
- Provides first assembly program that adds three numbers.
Code Example:
[org 0x0100]
mov ax, 5
mov bx, 10
add ax, bx
mov bx, 15
add ax, bx
mov ax, 0x4c00
int 0x21
Possible MCQs:
1. Q: What is the function of the Instruction Pointer (IP)?
2. Q: What is the difference between mnemonic and opcode?
3. Q: What is the maximum memory 8088 can access?
Topics Covered:
- Data Declaration
- Direct Addressing
- Size Mismatch Errors
- Register Indirect Addressing
- Register + Offset Addressing
- Segment Association
- Address Wraparound
- Addressing Modes Summary
Summary:
- Use db/dw to declare memory variables.
- Access memory via direct addressing (e.g., [num1]).
- Avoid size mismatch errors when moving data.
- Address memory indirectly using registers.
- Offset and segment determine the final physical address.
Possible MCQs:
4. Q: What does 'db' stand for in assembly?
5. Q: What causes size mismatch error in MOV instruction?
6. Q: What is register indirect addressing?
Chapter 3: Branching
Topics Covered:
- Comparison and Conditions
- Conditional Jumps
- Unconditional Jump
- Relative Addressing
- Types of Jump
- Sorting Example
Summary:
- Use CMP to compare values.
- Use JE, JNE, JG, JL, etc. to jump based on conditions.
- JMP is an unconditional jump.
- Branching changes program flow based on logic.
Possible MCQs:
7. Q: Which instruction is used to compare two values?
8. Q: What is the range of short jump in relative addressing?
9. Q: Which instruction performs unconditional jump?
Topics Covered:
- Multiplication Algorithm
- Shifting and Rotations
- Multiplication in Assembly Language
- Extended Operations
- Bitwise Logical Operations
- Masking Operations
Summary:
- Bitwise operations: AND, OR, XOR, NOT.
- Shifts: SHL (left), SHR (right).
- Rotates: ROL (left rotate), ROR (right rotate).
- Masking isolates specific bits using AND.
Possible MCQs:
10. Q: What is the result of SHR AL, 1?
11. Q: What does masking do?
12. Q: Which instruction rotates bits left?
Chapter 5: Subroutines
Topics Covered:
- Program Flow
- Our First Subroutine
- Stack
- Saving and Restoring Registers
- Parameter Passing Through Stack
- Local Variables
Summary:
- CALL and RET are used to implement subroutines.
- Stack is used to store return addresses and parameters.
- PUSH and POP store and retrieve register values.
- Subroutines improve code modularity.
Possible MCQs:
13. Q: What instruction returns from a subroutine?
14. Q: What is the purpose of the stack pointer (SP)?
15. Q: How are parameters passed in a subroutine?