Write common assembly language (RISC) programs to a) sum the first n elements of an array A, and b) compute r = ab for unsigned integers a and b. Each program will consist of a driver and a subprogram. The drivers will 1) read one or more values from the keyboard, 2) call the subprogram, and 3) print a result. The subprograms must not: ● store into memory, ● use registers $1 – $9, or ● make system calls


Copyable
Code:
a)
.DATA
array DW 100 DUP (?) ;declare array maximum size is 100
num DB DUP(?) ;declare Number
sum DB DUP(?)
.CODE
mov ah, 4 ;system call code for int read
INT 21H
sub al, 30H
mov num, al
mov ebx,0 ; array offset
mov ecx,[num] ;loop counter
LOOP:
mov ah, 4 ;system call code for int read
INT 21H
sub al, 30H
mov array[ebx], al ;save int in the array at offset ebx
addi ebx, 4 ;increment the offset by 4
dec ecx ;decrement the ecx counter
jnz LOOP ;jump to loop if not zero
push array ;push the array values
push num ;push given num
call SumValue
mov sum, eax ;save the sum in eax register
int 21H ;for display the sum
SumValue:
push ebp
mov ebp, esp
mov eax, 0 ;save value of sum
mov ebx, [ebp+4] ;load num
mov ecx, [ebp+8] ;load the array base address
loopSum:
mov edx, [ecx] ;load array values
add eax,edx ;add array element that is edx to eax
addi ecx, 4 ;increment offset by 4
dec ebx
jnz loopSum
mov esp, ebp
pop ebp
ret
b)
.DATA
a DB DUP(?) ;declare a
b DB DUP(?) ;declare b
r DB DUP(?) ;declare r
.CODE
mov ah, 4 ;system call code for read int a
INT 21H
sub al, 30H
mov a, al
mov ah, 4 ;system call code for read int b
INT 21H
sub al, 30H
mov b, al
push a ;push a value
push b ;push b value
call MULTIPLY ;call MULTIPLY function
mov [r], eax ;move the result r to eax
int 21H ;for display
MULTIPLY:
push ebp
mov ebp, esp
mov eax, [ebp+4] ; load b value
mov ebx, [ebp+8] ; load a value
mul eax,ebx ;for r = a* b that is eax = eax*ebx
mov esp, ebp
pop ebp
ret
Write common assembly language (RISC) programs to a) sum the first n elements of an array...
E2.15 In assembly code, write a program to count the number of elements in an array that are smaller than 16. The array is stored at memory locations starting from $1010. The array has 30 8-bit unsigned elements. Store the count in the memory location $C001.
PLEASE USE VERY BASIC REGISTERS AND CODE TO DO THE FOLLOWING Objectives: -write assembly language programs to: -define a recursive procedure/function and call it. -use syscall operations to display integers and strings on the console window -use syscall operations to read integers from the keyboard. Assignment Description: Implement a MIPS assembly language program that defines "main", and "function1" procedures. The function1 is recursive and should be defined as: function1(n) = (2*n)+9 if n <= 5 =...
Assembly Language/ Microprocessors - Question: (INVOKE): Write a procedure to accept three parameters of type DWORD. Read three unsigned integers from console and call the procedure to return their sum. Note that the sum must be returned in EAX register. Call procedure using INVOKE. Print the sum returned from procedure to the console
3. Write a program in assembly language that reads a number from the keyboard and displays it on the screen. 4. Write a program in assembly language to ask two digits from the user, store the digits in the EAX and EBX register, respectively, add the values, store the result in a memory location 'res' and finally display the result.
Write an Assembly Language program StackReverse which uses the runtime stack to reverse an array Vector of N unsigned double-word integers.
Write a PIC 18F452 assembly program that uses an array of signed integers of 10 elements and computes the sum of all the elements in the array.
Create the following two programs in assembly language: 1. Write a program that will call a procedure to push the following Decimal value into eax - 31000 and then clear the register using pop. 2. Write a program that will call a procedure to use minMax to push an array values into eax register.
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
Programming Problem: SUMMING ARRAY ELEMENTS - Use Assembly Language x86 (MASM) Write an assembly code calculates the sum of all array elements. Save the sum in the EAX register. ------------------------------------------------------------------------------- This is my code so far: INCLUDE Irvine32.inc N=10 .data array SDWORD N DUP(0,1,2,3,4,5,6,7,8,9) j DWORD ? k DWORD ? .code main PROC ; not complete exit main ENDP END main
Write a c program to implement threads. Accept an array of 40 integers, write a thread method named sum of array elements. Divide the array into 4 equal elements and call threads to find the sum of each part. Store the sum in a variable called “arrays'. Print the sum in the main function. (10 points)