PLEASE USE EXACT SAME LANGUAGE AND NOTATION, THIS IS AN ENTRY CLASS KEEP IT SMIP
ID: 3849278 • Letter: P
Question
PLEASE USE EXACT SAME LANGUAGE AND NOTATION, THIS IS AN ENTRY CLASS KEEP IT SMIPLE
QUESTION: Write a function to change variable from little endian to big endian notation in assembly. The basic structure of the function is given in the attached assembly language file. You are expected to complete the function int toBigEndian(int variable) which converts an integer variable passed from little endian to big endian notation. The conversion function should simply accept the number variable and flip the order of the bytes and return the resulting value.
For example
Variable passed to function 0xAABBCCDD
The value returned from the function 0xDDCCBBAA
Complete the function implementation which takes a little endian notation as input and returns the big endian notation of the given value from the function as given in the above example.
The function with the basic commands for the function entry and exit / return are already given. Use the given function and fill in your implementation where it is specified as below:
/*
TO DO: Your implementation should be here
*/
QUESTION: Write a function to check if a machine uses little endian or big endian notation. The basic structure of the program is given in the attached assembly language file. You are expected to write the function int isLittleEndian(). Complete the function implementation to return the following values from the function.
The function int isLittleEndian () should return the following values:
• 1 if the architecture is "Little Endian"
• 0 if the architecture is "Big Endian"
PLEASE USE EXACT SAME LANGUAGE AND NOTATION, THIS IS AN ENTRY CLASS KEEP IT SMIPLE
Explanation / Answer
.386
.model flat, stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.data
bigEndian BYTE 12h, 34h, 56h, 78h
littleEndian DWORD ?
.code
main PROC
mov ah, byte ptr bigEndian+0
mov al, byte ptr bigEndian+1
mov word ptr littleEndian+2,ax;here I want to move my now full register into the 32bit register eax.
mov ah, byte ptr bigEndian+2
mov al, byte ptr bigEndian+3
mov word ptr littleEndian+2,ax here I want to move my now full register into the 32bit register eax which results in the order being reversed.
invoke ExitProcess, 0
main ENDP
END main
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.