Assembly language > Assembly discussions
Assembler Doesn't Accept PUSH Immediate instruction
(1/1)
PabloMack:
I just tried to assemble a push immediate instruction and the
assembler doesn't like it. The AMD64 Ref Manual Vol 3 says
that it should take a number, sign extend it and push the
resulting 64-bit number onto the stack. The immediate can be
either a 1-byte (Opcode 6A) or 4-byte (Opcode 68) value.
The error is: "Invalid combination of opcode and operands (or wrong CPU setting)"
;Empty Main Program
.code
;********** Empty Main Program **********
main proc
push 28h
main endp
end
Vortex:
In 64-bit assembly programming, you cannot push immediate values to the stack :
--- Code: --- hwnd=CreateWindowEx(
WS_EX_CLIENTEDGE,
szClassName,
"Simple window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 480, 400,
NULL, NULL, hInstance, NULL);
--- End code ---
assembled as :
--- Code: ---xor eax, eax
mov qword ptr [rsp+58H], rax
mov qword ptr [rsp+50H], rbx
xor eax, eax
mov qword ptr [rsp+48H], rax
xor eax, eax
mov qword ptr [rsp+40H], rax
mov eax, 400
mov dword ptr [rsp+38H], eax
mov eax, 480
mov dword ptr [rsp+30H], eax
mov eax, 2147483648
mov dword ptr [rsp+28H], eax
mov eax, 2147483648
mov dword ptr [rsp+20H], eax
mov r9d, 13565952
lea r8, ptr [@337]
lea rdx, ptr [szClassName]
mov ecx, 512
call qword ptr [__imp_CreateWindowExA]
--- End code ---
jj2007:
--- Quote from: Vortex on May 11, 2019, 01:03:26 PM ---In 64-bit assembly programming, you cannot push immediate values to the stack :
--- End quote ---
Why not?
--- Code: ---0000000140001229 | 68 78 56 34 12 | push 12345678 |
000000014000122E | 58 | pop rax |
0000000140001229 | 6A 7B | push 7B |
000000014000122B | 58 | pop rax |
--- End code ---
Vortex:
OK, a correction here : Poasm does not accept this :
--- Code: ---\PellesC\bin\poasm.exe /AAMD64 Test.asm
Test.asm(5): error: Invalid combination of opcode and operands (or wrong CPU setting).
--- End code ---
--- Code: ---.code
start:
push 12345678
ret
END
--- End code ---
Navigation
[0] Message Index
Go to full version