Skip to content
Related Articles
Open in App
Not now

Related Articles

8086 program to reverse 8 bit number using 8 bit operation

Improve Article
Save Article
Like Article
  • Last Updated : 14 Jun, 2018
Improve Article
Save Article
Like Article

Problem – Write an assembly language program in 8086 microprocessor to reverse 8 bit number using 8 bit operation.

Example – Assume 8 bit number is stored at memory location 2050

Algorithm –

  1. Load contents of memory location 2050 in register AL
  2. Assign 0004 to CX Register Pair
  3. Rotate the contents of AL by executing ROL instruction using CX
  4. Store the content of AL in memory location 2050

Program –

Memory AddressMnemonicsComments
400MOV AL, [2050]AL<-[2050]
404MOV CX, 0004CX <- 0004
407ROL AL, CXRotate AL content left by 4 bits(value of CX)
409MOV [2050], AL[2050]<-AL
40DHLTStop Execution

Explanation –

  1. MOV AL, [2050] loads contents of memory location 2050 in AL
  2. MOV CX, 0004 assign 0004 to CX register pair
  3. ROL AL, CX rotate the content of AL register left by 4 bits i.e. value of CX register pair
  4. MOV [2050], AL stores the content of AL in 2050 memory address
  5. HLT stops executing the program
My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!