Take user Input in an array and show output in assembly language emu8086

An array is a collection of similar elements. These similar elements could be all int, or all float, or all char etc. Usually, the array of characters is called a ‘string’, whereas an array of int or float is called simply an array. But in assembly language, the data types should be DB (Data Byte) or DW (Data Word). So we have to declare array using DB or DW data types. Like other language we have to initialize array either it's value null or something. To know more about array declaration in assembly I will request you to read Array_Declare_in_Assembly_Language this article first.

Here we will learn about how to take user input in an array in assembly language and print it as output

Please have a look on the code and I will explain it line by line.
INCLUDE 'EMU8086.INC' ;include an assembly library .MODEL SMALL .STACK 100h .DATA ARR DB 50 DUP(?) ; declare array with null value initially .CODE MAIN PROC MOV AX,@DATA MOV DS,AX XOR BX,BX XOR CX,CX PRINT "How many number you want to store(1-9): " MOV AH,1 INT 21H AND AL,0FH ;convert from ascii value to real value MOV CL,AL MOV BL,AL MOV SI,0 PRINTN PRINT "Enter values(without press enter or space): " PRINTN INPUT: INT 21H MOV ARR[SI],AL INC SI LOOP INPUT PRINTN PRINT "OUTPUT: " PRINTN MOV CX,BX MOV SI,0 MOV AH,2 OUTPUT: MOV DL,ARR[SI] INT 21h INC SI LOOP OUTPUT MAIN ENDP END MAIN

In  data section we have declared the array named ARR with the size of 50 indexes and each
index has null value initially. Then we are taking an user input for the number of inserting
values. User should enter numbers without pressing enter or space button in our code. We are
using SI register as array index which initialize with value 0. Then We are running a loop
for storing the values in our array and increasing the index value or SI register. Again using
another loop we are printing the values from our array.

Are you searching someone to do your programming assignments? Go to the link and place order. I will help you. Click here

Comments

Post a Comment

Popular posts from this blog

How To Print New Line in Assembly Language emu8086

How to Declare array in Assembly languages emu8086

Simple Input and output in assembly Language EMU8086