Question

In assembly language computer programming 1. create a 5 element array 2.prompt the user to enter...

In assembly language computer programming 1. create a 5 element array
2.prompt the user to enter 5 numbers to fill the array
3. exchange the number at position 1 with the number at position 4 of the array. (Don't forget that array positions are counted from zero, in our case 5 element array positions are counted 0,1,2,3,4.)
4.Display the array numbers 1 and 4 to show that you did the exchange correctly. Show a message like "The number at position 1 is" and display the number , so that the user knows what each number represents.Do the same for displaying the number at position 4 of the array.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer-1
There are two ways to define an array in assembly language:-
A.
An initialized array is defined in the same way as a scalar variable, but with multiple initial values.
Example-
       Array DB 1,2,3,4,5
       Array is The name of array and DB (Data Byte) , DW (Data Word) are it’s type.
  

B.
Uninitialized arrays are defined using the .space directive.

Note:-
The .space directive allocates the specified number of bytes. Specifying the desired number of array elements is a common mistake.
   scores: .space 400
and also
Now, If we want to declare an array with assigning no value initially then it will be

Array_Name Data_Type Number_Of_Index DUP(?)

To access an array in assembly language, we use a pointer.
A pointer is simply a register or variable that contains a memory address.

Assembly Code:-

.MODEL SMALL
.STACK 100h
.DATA
ARR DB 1,2,3,4,5 ;array declaire
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS,AX
  
MOV CX,5
MOV SI,0
MOV AH,2
  
OUTPUT:
MOV DL, ARR[SI]
ADD DL,30H
INT 21H
INC SI
LOOP OUTPUT

MAIN ENDP
END MAIN

Answer-2
.MODEL SMALL
.STACK 100h
.DATA
ARR DB 20 DUP(?) ; declaire 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-5): "
  
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

Answer 3

DATA SEGMENT
A DB 1,2,3,4,5
B DB 6,7,8,9,10
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
MOV CX,0000
MOV CL,05
LEA BX,A
LEA SI,B
L1:MOV DH,BYTE PTR[BX]
MOV DL,BYTE PTR[SI]
MOV BYTE PTR[BX],DL
MOV BYTE PTR[SI],DH
MOV DH,BYTE PTR[BX]
MOV DL,BYTE PTR[SI]
INC BX
INC SI
DEC CL
CMP CL,00
JNZ L1
MOV AH,4CH
INT 21H
CODE ENDS
END START

Add a comment
Know the answer?
Add Answer to:
In assembly language computer programming 1. create a 5 element array 2.prompt the user to enter...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a complete program in assembly line that:    1. Prompt the user to enter 10...

    Write a complete program in assembly line that:    1. Prompt the user to enter 10 numbers.    2. save those numbers in a 32-bit integer array.    3. Print the array with the same order it was entered.    3. Calculate the sum of the numbers and display it.    4. Calculate the mean of the array and display it.    5. Rotate the members in the array forward one position for        9 times. so the last...

  • 1. print mesage to user to prompt user to enter 10 numbers 2 have program accept...

    1. print mesage to user to prompt user to enter 10 numbers 2 have program accept 10 numbers from user and populate 10 occurrances of an array (use a loop to do this). 3. print message to user to advise user contents of array follows 4. have program display array contents (use loop to do this) end program comment in java please

  • Assembly Language////Write a program that read in 10 integers from the user. Save the numbers into...

    Assembly Language////Write a program that read in 10 integers from the user. Save the numbers into an array; reverse the array and display the reversed array. .data arrayInt DWORD 10 DUP(?) Your program consists of 4 procedures: 1. main procedure: call procedures getInput, reverseArray, displayArray 2. getInput procedure: prompt user to enter 10 integer numbers, save the numbers into the memory for the arrayInt 3. reverseArray: reverse arrayInt 4. displayArray: display the reversed array

  • 1. Prompt the user for one of the arithmetic operators ('op'): +, -, *,/, or **...

    1. Prompt the user for one of the arithmetic operators ('op'): +, -, *,/, or ** 2. Prompt the user for two input integers ('a' and'b') 3. The input numbers can be positive or negative 4. Perform the arithmetic operation using the two input numbers 5. The first entered number ('a') is the left side, the second ('b') the right side of the operation For exponentiation, the first number is the base, the second the exponent Print (display) the following...

  • Write a program in Java language to prompt the user to enter 3 integers (A, B,...

    Write a program in Java language to prompt the user to enter 3 integers (A, B, and C) then display these numbers from the lowest to the highest (sorted ascendingly) . Note that there are 6 different cases to handle proper order. As an example, a user entered 10 for A, 5 for B and 14 for C: the output of the program should look like this Enter number A? 10 Enter number B? 5 Enter number C? 14 Your...

  • Write a perl script to accomplish following tasks: 1. Prompt user to enter their name and...

    Write a perl script to accomplish following tasks: 1. Prompt user to enter their name and age, and then calculate and display their age in days. 2. Initialize a 20-element array of numbers and print each element. 3. Get a system host name. 4. Get a web page and save it to a file. 5. List background services (daemons) on your system.

  • X86 Assembly language lab: TITLE Lab 3: assembly language fundamentals               ;;;;; Q1: Don't...

    X86 Assembly language lab: TITLE Lab 3: assembly language fundamentals               ;;;;; Q1: Don't forget to document your program            ; Name:Yuyan Wang ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;; Answer each question below by writing code at the APPROPRIATE places in the file. ;;;;; Hint: the appropriate place is not always right below the question. ;;;;; Q2: Write the directive to bring in the IO library           ;;;;; Q3: Create a constant called MAX and initialize it to 150...

  • Microsoft Excel VBA (Visual Basic for Applications) Programming Language Objectives: Create an array and redim it...

    Microsoft Excel VBA (Visual Basic for Applications) Programming Language Objectives: Create an array and redim it to a size equal to an assigned value of a variable, populate the array with a series of random numbers, output the array to a message box and to a worksheet. Instructions: - Review the variables already declared. You won't need others. - See comments in the code that will act as your guide. Add new code directly after each comment. - Assign a...

  • using C language Create an array of doubles with 5 elements. In the array prompt the...

    using C language Create an array of doubles with 5 elements. In the array prompt the user to enter 5 temperature values (in degree Fahrenheit). Do this within main. Create a user defined function called convert2Cels. This function will not return any values to main with a return statement. It should have parameters that include the temperature array and the number of elements. The function should convert the values for Fahrenheit to Celsius and save them back into the same...

  • **C programming Language 3) Prompt the user for data points. Data points must be in this...

    **C programming Language 3) Prompt the user for data points. Data points must be in this format: string, int. Store the information before the comma into a string variable and the information after the comma into an integer. The user will enter -1 when they have finished entering data points. Output the data points. Store the string components of the data points in an array of strings. Store the integer components of the data points in an array of integers....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT