Embed presentation
Download to read offline
![Assembly Language:
Reverse an array.
Use a loop with indirect or indexed addressing to reverse the elements of an integer array in
place. Do not copy the elements to any other array. Do not use stack operations. Use the
SIZEOF, TYPE, LENGTHOF operators.
Fibonacci Numbers.
Write a code that fills the array of 15 elements with consecutive Fibonacci numbers: Fib(1) =
Fib(2) = 1; Fib (n) = Fib(n-1) + Fib(n-2) for each N > 2.
corrent code:
Solution
data barray BYTE 6 DUP (?) dwarray DWORD 3 DUP (?) TOTAL_LENGTH = $-barray
bdmessage BYTE "Today as stored in a double word", 0dh, 0ah, 0 dwmessage BYTE 0dh,
0ah, "Seeing bytes in a single word", 0dh, 0ah, 0 lengthmessage BYTE 0dh, 0ah, "total bytes
used: ", 0 finalmessage BYTE 0dh, 0ah, "Press any key to continue ...", 0 .code main PROC
CALL Crlf MOV edx, OFFSET bdmessage CALL WriteString MOV eax, DWORD
PTR [barray + 2] CALL WriteDec MOV edx, OFFSET dwmessage CALL WriteString
MOVZX eax, WORD PTR [dwarray + 6] CALL WriteDec MOV edx, OFFSET
lengthmessage CALL WriteString MOV eax, TOTAL_LENGTH CALL WriteDec
MOV edx, OFFSET finalmessage CALL WriteString CALL ReadChar INVOKE
ExitProcess, 0 main ENDP END main](https://image.slidesharecdn.com/assemblylanguagereverseanarray-230702063434-9ad0ac61/75/Assembly-LanguageReverse-an-array-Use-a-loop-with-indirect-or-i-pdf-1-2048.jpg)
The document provides instructions for an assembly language program to reverse an integer array in place without using additional storage or stack operations, emphasizing the use of loop and indirect addressing methods. It also includes code for populating a 15-element array with Fibonacci numbers and displays various messages related to the array's size and content. The provided code is structured with specific data declarations and procedure definitions for execution in an assembly environment.
![Assembly Language:
Reverse an array.
Use a loop with indirect or indexed addressing to reverse the elements of an integer array in
place. Do not copy the elements to any other array. Do not use stack operations. Use the
SIZEOF, TYPE, LENGTHOF operators.
Fibonacci Numbers.
Write a code that fills the array of 15 elements with consecutive Fibonacci numbers: Fib(1) =
Fib(2) = 1; Fib (n) = Fib(n-1) + Fib(n-2) for each N > 2.
corrent code:
Solution
data barray BYTE 6 DUP (?) dwarray DWORD 3 DUP (?) TOTAL_LENGTH = $-barray
bdmessage BYTE "Today as stored in a double word", 0dh, 0ah, 0 dwmessage BYTE 0dh,
0ah, "Seeing bytes in a single word", 0dh, 0ah, 0 lengthmessage BYTE 0dh, 0ah, "total bytes
used: ", 0 finalmessage BYTE 0dh, 0ah, "Press any key to continue ...", 0 .code main PROC
CALL Crlf MOV edx, OFFSET bdmessage CALL WriteString MOV eax, DWORD
PTR [barray + 2] CALL WriteDec MOV edx, OFFSET dwmessage CALL WriteString
MOVZX eax, WORD PTR [dwarray + 6] CALL WriteDec MOV edx, OFFSET
lengthmessage CALL WriteString MOV eax, TOTAL_LENGTH CALL WriteDec
MOV edx, OFFSET finalmessage CALL WriteString CALL ReadChar INVOKE
ExitProcess, 0 main ENDP END main](https://image.slidesharecdn.com/assemblylanguagereverseanarray-230702063434-9ad0ac61/75/Assembly-LanguageReverse-an-array-Use-a-loop-with-indirect-or-i-pdf-1-2048.jpg)