Qwestrum Engineering360 · Electrical & Electronics · Microprocessors & Microcontrollers
Assembly Language Programming
Assembly programming moves data between registers and memory (MOV), performs arithmetic that updates flags, and controls flow with loops and conditional jumps; CX is the built-in loop counter.
Exam tip: keep SI units consistent end-to-end, write the governing relation symbolically before substituting, and sanity-check magnitude and sign.
Key formulas & points
Skim these first — then read the full notes below.
- Directives: DB, DW, END, SEGMENT, ASSUME
- Procedures CALL/RET; stack for parameters and return address
- String ops MOVS, CMPS with REP prefix
Topic details
Introduction
Instructions operate on registers and memory with addressing modes (immediate, register, direct, register-indirect, based-indexed). Data-transfer (MOV, PUSH, POP), arithmetic (ADD, SUB, MUL, DIV) and control (JMP, Jcc, LOOP, CALL) form the core instruction set.
Scope in B.Tech and GATE syllabus
The LOOP instruction decrements CX and jumps while CX ≠ 0, making counted loops compact. Conditional jumps test flags set by the previous arithmetic/compare.
Key relations & formulas
Formulas (Indian textbook notation)
Formulas (Indian textbook notation)
Formulas (Indian textbook notation)
Notation and sign conventions
Relation 1 —
Formulas (Indian textbook notation)
Write this relation with symbols exactly as in Microprocessor Architecture & Programming — Ramesh Gaonkar before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.
Relation 2 —
Formulas (Indian textbook notation)
Write this relation with symbols exactly as in Microprocessor Architecture & Programming — Ramesh Gaonkar before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.
Relation 3 —
Formulas (Indian textbook notation)
Write this relation with symbols exactly as in Microprocessor Architecture & Programming — Ramesh Gaonkar before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.
Fundamentals and definitions
The stack (in the stack segment, indexed by SP) holds return addresses for CALL/RET and saved registers via PUSH/POP; each PUSH decrements SP by 2, each POP increments it by 2.
Governing relations in practice
String instructions (MOVS, CMPS, SCAS) process arrays automatically incrementing SI/DI, and the REP prefix repeats them CX times — efficient block moves and searches.
Design and analysis considerations
Assembler directives (DB, DW define bytes/words; SEGMENT, ASSUME, END structure the program) are processed at assembly time, not run time; distinguishing them from executable instructions is a common exam point.
Assumptions and validity limits
State assumptions explicitly before using any relation for assembly language programming — steady state, uniform properties, linear elastic material, ideal gas, incompressible flow, etc., as applicable.
Wrong assumptions invalidate the entire solution even when the formula is correct. In Microprocessors viva and GATE descriptive questions, listing valid assumptions often earns separate marks.
Step-by-step problem approach
1. Read the question and list given data with SI units (common in Microprocessors papers).
2. Draw a neat labelled diagram where applicable — examiners in Indian universities award diagram marks even when arithmetic slips.
3. Identify which relation from this topic applies to assembly language programming.
4. Use equation 1:
5. Use equation 2:
6. Substitute values, compute, and verify units and sign (direction).
7. State conclusion in one line — e.g. safe/unsafe, stable/unstable, feasible/infeasible.
2. Draw a neat labelled diagram where applicable — examiners in Indian universities award diagram marks even when arithmetic slips.
3. Identify which relation from this topic applies to assembly language programming.
4. Use equation 1:
.
5. Use equation 2:
.
6. Substitute values, compute, and verify units and sign (direction).
7. State conclusion in one line — e.g. safe/unsafe, stable/unstable, feasible/infeasible.
Applications & exam relevance
Assembly Language Programming appears in embedded and industrial controllers. In Indian electrical curricula this topic is tested because it connects theory to 8086 architecture and interfacing.
GATE and semester exams often combine assembly language programming with earlier units — revise prerequisites before attempting mixed problems.
Industry interview panels sometimes ask: "Where did you use assembly language programming?" — answer with a lab, mini-project, or plant visit example if possible.
Common mistakes in exams
• Forgetting MUL/DIV use implicit AX (and DX) rather than an arbitrary register
• Miscounting SP changes across PUSH/POP (2 bytes each in 8086)
• Using LOOP without initialising CX
• Confusing assembler directives with executable instructions
• Miscounting SP changes across PUSH/POP (2 bytes each in 8086)
• Using LOOP without initialising CX
• Confusing assembler directives with executable instructions
Quick revision checklist
Before attempting assembly language programming problems, confirm you can:
1. Directives: DB, DW, END, SEGMENT, ASSUME
2. Procedures CALL/RET; stack for parameters and return address
3. String ops MOVS, CMPS with REP prefix
2. Procedures CALL/RET; stack for parameters and return address
3. String ops MOVS, CMPS with REP prefix
Revise the solved examples in Microprocessor Architecture & Programming — Ramesh Gaonkar and one previous-year GATE or university paper for this unit.
Worked examples
Try the problem first — open the solution when you are ready to check.
Stack pointer after PUSH operations
Problem
SP = 2000H initially. Trace SP after PUSH AX, PUSH BX, then one POP in an 8086.
Solution
Each PUSH decrements SP by 2.
After PUSH AX: SP = 2000H − 2 = 1FFEH.
After PUSH BX: SP = 1FFEH − 2 = 1FFCH.
After one POP: SP = 1FFCH + 2 = 1FFEH.
After PUSH AX: SP = 2000H − 2 = 1FFEH.
After PUSH BX: SP = 1FFEH − 2 = 1FFCH.
After one POP: SP = 1FFCH + 2 = 1FFEH.
Conceptual check — Assembly Language Programming
Problem
In a Microprocessors semester or GATE paper you are asked: "State the main assumption, the governing relation, and one practical consequence of assembly language programming." What should a complete answer include?
Exams & GATE
Gaonkar — trace stack after CALL and PUSH sequence.
📖 Standard books (India)
Microprocessor Architecture & Programming — Ramesh Gaonkar
Read: Syllabus unit
8085/8086 — widely used in Indian colleges
Explore related topics
See real electrical & electronics careers
After exams and interviews, see how engineers actually built careers — milestones and decisions from people in the field.