Given that
in 32 bit MASM assembly language and the procedure return the sum of every 3rd elements.
Given, Asked to write an assembly language code to perform the addition of every 3rd offset value and returns the sum.
Explanation: I used x86-64 GCC to compile this code. Hope this is the one you are looking.
Assembly Code:
sumOffset(int*, int):
push %rbp
mov %rbp, %rsp
mov QWORD PTR [%rbp-24], %rdi
mov DWORD PTR [%rbp-28], %esi
mov DWORD PTR [%rbp-8], 0
mov DWORD PTR [%rbp-4], 0
jmp .L2
.L3:
mov %eax, DWORD PTR [%rbp-4]
mov DWORD PTR [%rbp-36], %eax
mov DWORD PTR [%rbp-40], 1431655766
mov %eax, DWORD PTR [%rbp-40]
imul DWORD PTR [%rbp-36]
mov %ecx, %edx
mov %eax, DWORD PTR [%rbp-36]
sar %eax, 31
mov %edx, %ecx
sub %edx, %eax
mov DWORD PTR [%rbp-32], %edx
mov %eax, DWORD PTR [%rbp-32]
add %eax, %eax
add %eax, DWORD PTR [%rbp-32]
mov %edx, DWORD PTR [%rbp-36]
sub %edx, %eax
mov DWORD PTR [%rbp-32], %edx
cmp DWORD PTR [%rbp-32], 0
jne .L4
mov %eax, DWORD PTR [%rbp-4]
cdqe
sal %rax, 2
add %rax, QWORD PTR [%rbp-24]
mov %eax, DWORD PTR [%rax]
add DWORD PTR [%rbp-8], %eax
.L4:
inc DWORD PTR [%rbp-4]
.L2:
mov %eax, DWORD PTR [%rbp-4]
cmp %eax, DWORD PTR [%rbp-28]
jl .L3
mov %eax, DWORD PTR [%rbp-8]
leave
ret
.LC0:
.string "%d"
main:
push %rbp
mov %rbp, %rsp
sub %rsp, 416
mov DWORD PTR [%rbp-12], 3
mov DWORD PTR [%rbp-8], 0
lea %rsi, [%rbp-16]
mov %edi, OFFSET FLAT:.LC0
mov %eax, 0
call scanf
mov DWORD PTR [%rbp-4], 0
jmp .L9
.L10:
mov %eax, DWORD PTR [%rbp-4]
lea %rdx, [%rbp-416]
cdqe
sal %rax, 2
lea %rsi, [%rdx+%rax]
mov %edi, OFFSET FLAT:.LC0
mov %eax, 0
call scanf
inc DWORD PTR [%rbp-4]
.L9:
mov %eax, DWORD PTR [%rbp-16]
cmp DWORD PTR [%rbp-4], %eax
jl .L10
mov %esi, DWORD PTR [%rbp-16]
lea %rdi, [%rbp-416]
call sumOffset(int*, int)
mov %esi, %eax
mov %edi, OFFSET FLAT:.LC0
mov %eax, 0
call printf
mov %eax, 0
leave
ret
In 32-bit MASM assembly language, write a procedure that accelpts an offset and a lenght of...
Code in assembly language please "Write an assembly 32 bit program that adds two numbers (other than 5 and 6) and stores the value to a variable called 'sum'. Also, use a block COMMENT to depict the name and description of the program, author of the program, and date."
Write an assembly intel 8088 16 bit code MASM,(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 8,9,10,1,2,3,4,5,6,7 please provide the full assembly code.
Write a program in ARM assembly language that copies each element of array A to consecutive fourth elements of array B, i.e., A[0] to B[0], A[1] to B[3], A[2] to B[7], etc. The array A is 12 elements long, and each element is a number that is 32 bits (1 word) wide. Assume the base address of array A is in register R2, and the base address of array B is in R3.
Assembly Language Program Help Write a procedure named CountNearMatches that receives pointers to two arrays of signed doublewords, a parameter that indicates the length of the two arrays, and a parameter that indicates the maximum allowed difference (called diff) between any two matching elements. For each element x(i) in the first array, if the difference between it and the corresponding y(i) in the second array is less than or equal to diff, increment a count. At the end, return a...
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
INTEL 80x86 ASSEMBLY LANGUAGE CODE Write a windows32 assembly language program that utilizes a recursive procedure. The main (_MainProc) procedure should: accept, from the user, a positive integer. Guard against non-positive integers being entered using a loop. call the sumseries sub-procedure using the cdecl protocol, receive the results of the sub-procedure, and display the results. The sumseries sub-procedure should: recursively find the sum of the series: 1*2 + 2*3 + 3*4 + ... + i*(i+1) (This is an iterative definition....
Use Assembly (Masm and Irvine32 library) to write a complete program that: 1. Asks the user to enter 2 numbers. Assume that the user enters unsigned 32-bit integers only. 2. Displays the product of the two numbers. Assume that the result will never be larger than 32 bits. 3. This process will continue till the user enters 0 for both inputs. You can’t use mul instruction in your program: You need to use shifting and addition only. Your program must...
CDA-3101 – MIPS Assembly Programming 1. Write the following code segment in MIPS assembly language code: 3. Write a MIPS program to find the sum of squares from 1 to n. Where n=10. For example, the sum of squares for 10 is as follows: 12+22+32+……+n2=385
MASM Assembly Language x86 Processor. Must use windows32 framework Write a non-recursive algorithm to find the greatest common divisor of two positive numbers. . • Your program should read the two positive integers using dialog boxes. If they are not positive, a message box should be displayed with an appropriate message. • Your program needs to have a procedure that takes two positive integers as parameters. • You need to follow cdecl protocol for parameter passing. • Display the valid...
MASM Assembly Language x86 Processor. Must use windows32 framework Write a non-recursive algorithm to find the greatest common divisor of two positive numbers. . • Your program should read the two positive integers using dialog boxes. If they are not positive, a message box should be displayed with an appropriate message. • Your program needs to have a procedure that takes two positive integers as parameters. • You need to follow cdecl protocol for parameter passing. • Display the valid...