Problem – Write an assembly language program in 8086 microprocessor to reverse 16 bit number using 8 bit operation.
Example – Assume 16 bit number is stored at memory location 2050 and 2051.

Algorithm –
- Load contents of memory location 2050 in register AL
- Load contents of memory location 2051 in register AH
- Assign 0004 to CX Register Pair
- Rotate the contents of AL by executing ROL instruction using CX
- Rotate the contents of AH by executing ROL instruction using CX
- Store the content of AH in memory location 2050
- Store the content of AL in memory location 2051
Program –
Memory Address |
Mnemonics |
Comments |
400 |
MOV AL, [2050] |
AL<-[2050] |
404 |
MOV AH, [2051] |
AH<-[2051] |
408 |
MOV CX, 0004 |
CX <- 0004 |
40B |
ROL AL, CX |
Rotate AL content left by 4 bits(value of CX) |
40D |
ROL AH, CX |
Rotate AH content left by 4 bits(value of CX) |
40F |
MOV [2050], AH |
[2050]<-AH |
413 |
MOV [2051], AL |
[2051]<-AL |
417 |
HLT |
Stop Execution |
Explanation –
- MOV AL, [2050]: loads contents of memory location 2050 in AL
- MOV AH, [2051]: loads contents of memory location 2051 in AH
- MOV CX, 0004: assign 0004 to CX register pair
- ROL AL, CX: rotate the content of AL register left by 4 bits i.e. value of CX register pair
- ROL AH, CX: rotate the content of AH register left by 4 bits i.e. value of CX register pair
- MOV [2050], AH: stores the content of AH in 2050 memory address
- MOV [2051], AL: stores the content of AL in 2051 memory address
- HLT: stops executing the program
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 :
02 Jul, 2018
Like Article
Save Article