Problem – Write a program to add two 16-bit numbers where starting address is 2000 and the numbers are at 3000 and 3002 memory address and store result into 3004 and 3006 memory address.
Example –

Algorithm –
- Load 0000H into CX register (for carry)
- Load the data into AX(accumulator) from memory 3000
- Load the data into BX register from memory 3002
- Add BX with Accumulator AX
- Jump if no carry
- Increment CX by 1
- Move data from AX(accumulator) to memory 3004
- Move data from CX register to memory 3006
- Stop
Program –
Memory |
Mnemonics |
Operands |
Comment |
2000 |
MOV |
CX, 0000 |
[CX] <- 0000 |
2003 |
MOV |
AX, [3000] |
[AX] <- [3000] |
2007 |
MOV |
BX, [3002] |
[BX] <- [3002] |
200B |
ADD |
AX, BX |
[AX] <- [AX] + [BX] |
200D |
JNC |
2010 |
Jump if no carry |
200F |
INC |
CX |
[CX] <- [CX] + 1 |
2010 |
MOV |
[3004], AX |
[3004] <- [AX] |
2014 |
MOV |
[3006], CX |
[3006] <- [CX] |
2018 |
HLT |
|
Stop |
Explanation –
- MOV is used to load and store data.
- ADD is used to add two numbers where their one number is in accumulator or not.
- JNC is a 2-bit command which is used to check whether the carry is generated from accumulator or not.
- INC is used to increment an register by 1.
- HLT is used to stop the program.
- AX is an accumulator which is used to load and store the data.
- BX, CX are general purpose registers where BX is used for storing second number and CX is used to store carry.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
22 May, 2018
Like Article
Save Article