My original assignment question is this:
Write a program that uses the variables below and MOV instructions to copy the value from bigEndian to littleEndian, reversing the order of the bytes. The number's 32 - bit value is understood to be 12345678 hexadecimal.
.data bigEndian BYTE 12h, 34h, 56h, 78h littleEndian DWORD?
I think my code is right but I can't figure out why I am getting this error. Here's my code and error:
.386
.model flat, stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.data
bigEndian BYTE 12h, 34h, 56h, 78h
littleEndian DWORD ?
.code
main PROC
mov eax, DWORD PTR bigEndian; eax = 87654321h
mov littleEndian, eax
invoke ExitProcess, 0
main ENDP
END main
1>------ Build started: Project: BigEndianLittleEndian, Configuration: Debug Win32 ------
1> Assembling BigEndiantoLittleEndian.asm...
1>BigEndiantoLittleEndian.asm(20): error A2008: syntax error
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations\masm.targets(50,5): error MSB3721: The command "ml.exe /c /nologo /Zi /Fo"Debug\BigEndiantoLittleEndian.obj" /W3 /errorReport:prompt /TaBigEndiantoLittleEndian.asm" exited with code 1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
How can I fix this error?
Here is updated code:
.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
The error I get
1>------ Build started: Project: BigEndianLittleEndian, Configuration: Debug Win32 ------
1> Assembling BigEndiantoLittleEndian.asm...
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(708,9): error MSB4030: "main" is an invalid value for the "NoEntryPoint" parameter of the "Link" task. The "NoEntryPoint" parameter is of type "System.Boolean".
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========