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.
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
In assembly language computer programming 1. create a 5 element array 2.prompt the user to enter...
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 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 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
Write a C program to prompt the user to enter 5 numbers in an array. The program will then calculate the average number in the array and displays the numbers higher than the average value.( using stdio.h).
Write a program that will create an array of ten integers, allow the user to enter those integers, and eventually search through the array based on index position: 1. Declare the array. You cannot assign elements to an array until it has first been created. 2. Next, run a for loop so that the user can enter an integer to save in each index position of the array. Since you this array holds ten elements , the index position starts...
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, 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 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 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 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...