8086 program to add the content of one segment to another segment
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 –
- Move 2000 into CX register
- Move CX into DS segment (now we are in 2000 data segment)
- Move value of 500 into AX register
- Move 3000 into CX register
- Move CX into DS segment (now we are in 3000 data segment)
- Add value of AX(accumulator) with value at memory 600
- Move 5000 into CX register
- Move CX into ES segment (now we are in 5000 extra segment)
- Move the content of AX into 700 memory location
- Stop
Program –
Memory | Mnemonics | Operands | Comment |
---|---|---|---|
1000 | MOV | CX, 2000 | [CX] <- 2000 |
1004 | MOV | DS, CX | [DS] <- [CX] |
1006 | MOV | AX, [500] | [AX] <- [500] |
100A | MOV | CX, 3000 | [CX] <- 3000 |
100E | MOV | DS, CX | [DS] <- [CX] |
1010 | ADD | AX, [600] | [AX] <- [AX] + [600] |
1014 | MOV | CX, 5000 | [CX] <- 5000 |
1018 | MOV | ES, CX | [ES] <- [CX] |
101A | MOV | [700], AX | [700] <- [AX] RESULT |
101E | HLT | Stop |
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
Please Login to comment...