Write an assembly intel 8088 16 bit code,(The 8088 includes has four 16-bit data registers (AX, BX, CX and DX). BX can also be used as an address register for indirect addressing. The most/least significant byte of each register can also be addressed directly)
using push, pop, and stack
print the array 9,10,1,2,3,4,5,6,7,8
please show the output .
The question has specified to produce output 9,10,1,2,3,4,5,6,7,8 using 8086 code.
It is assumed that numbers from 1 to10 are stored in order in the stack by using the instruction PUSH.
Here I am writing core which can be implemented in the 8086 trainer kit durectly or the same can be given to different types of assembler like NASM or MASM by adding respective assembler directives.
Each line includes comments which will helpyou understand the problem or code better.
LABEL |
MNEMONICS |
LP1: LP2: : |
MOV AX,01 PUSH AX /* These four line are used to read 10 numbers into the stack */ INC AX /* Pushing numbers into the stack from 1 to 10 */ CMP AX,11 JNZ LP1 /* This line is to check the count */ MOV BX,[SP-1] /* This line is added to take second top element from the stack. SP register is used to point to the top of the stack */ MOV SI,2000 /* Indexing the Array whose starting address is 2000 */ MOV [SI],BX /* As per the input,second top element = 9 will be taken from the stack */ INC SI MOV BX,[SP] /* As per the input,top element = 10 will be taken from the stack */ INC SI /* Increment array index to the next address*/ MOV [SI],BX /* Move next element to the new index */ POP BX POP BX MOV CX,10 MOV BX, [SP-CX] MOV [SI],BX DEC CX CMP CX,02 /* Since already we took two values*/ JNZ LP2 HLT |
Get Answers For Free
Most questions answered within 1 hours.