Skip to content
Related Articles

Related Articles

8086 program to add the content of one segment to another segment

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 28 May, 2018

Problem – Write a program to add the content of memory location 2000 : 0500 with content of memory location 3000 : 0600 and store result into 5000 : 0700 memory location.

Example –

Algorithm –

  1. Move 2000 into CX register
  2. Move CX into DS segment (now we are in 2000 data segment)
  3. Move value of 500 into AX register
  4. Move 3000 into CX register
  5. Move CX into DS segment (now we are in 3000 data segment)
  6. Add value of AX(accumulator) with value at memory 600
  7. Move 5000 into CX register
  8. Move CX into ES segment (now we are in 5000 extra segment)
  9. Move the content of AX into 700 memory location
  10. Stop

Program –

MemoryMnemonicsOperandsComment
1000MOVCX, 2000[CX] <- 2000
1004MOVDS, CX[DS] <- [CX]
1006MOVAX, [500][AX] <- [500]
100AMOVCX, 3000[CX] <- 3000
100EMOVDS, CX[DS] <- [CX]
1010ADDAX, [600][AX] <- [AX] + [600]
1014MOVCX, 5000[CX] <- 5000
1018MOVES, CX[ES] <- [CX]
101AMOV[700], AX[700] <- [AX] RESULT
101EHLTStop

Explanation –

Registers used AX, CX for general purpose.
Segments used DS, ES for changing the segments.
MOV is used to transfer the data
ADD is used for addition
HLT is used to halt the program

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!