masm32

Difference between dword ptr and dword ptr:es

ぐ巨炮叔叔 提交于 2019-12-02 10:08:20
问题 I was just checking the disassembly of my C++ program in VS2010. Here it is : int main() { 00B613A0 push ebp 00B613A1 mov ebp,esp 00B613A3 sub esp,0D4h 00B613A9 push ebx 00B613AA push esi 00B613AB push edi 00B613AC lea edi,[ebp-0D4h] 00B613B2 mov ecx,35h 00B613B7 mov eax,0CCCCCCCCh 00B613BC rep stos dword ptr es:[edi] 00B613BE mov eax,dword ptr [___security_cookie (0B67000h)] 00B613C3 xor eax,ebp 00B613C5 mov dword ptr [ebp-4],eax char temp[] = "hello"; 00B613C8 mov eax,dword ptr [string

Calling MASM32 procedure from .c

一笑奈何 提交于 2019-12-02 09:52:44
问题 I am using visual studio at the moment. I need to build a win32 application and need to call a procedure from a C function but I am always getting a build error: Error 3 error LNK1120: 1 unresolved externals I have reduced everything down to a simple main function and simple .asm file with one procedure and I am still getting the same build (or rather link) error. I'm at a loss. Both are using the cdecl convention. The MASM32 code (in its own .asm file): .MODEL FLAT, C .DATA .CODE PUBLIC

Why is it better to use the ebp than the esp register to locate parameters on the stack?

我只是一个虾纸丫 提交于 2019-12-02 04:22:38
I am new to MASM. I have confusion regarding these pointer registers. I would really appreciate if you guys help me. Thanks Encoding an addressing mode using [ebp + disp8] is one byte shorter than [esp+disp8] , because using ESP as a base register requires a SIB byte. See rbp not allowed as SIB base? for details. (That question title is asking about the fact that [ebp] has to be encoded as [ebp+0] .) The first time [esp + disp8] is used after a push or pop, or after a call , will require a stack-sync uop on Intel CPUs. ( What is the stack engine in the Sandybridge microarchitecture? ). Of

masm32 invoking stdout gives no output

佐手、 提交于 2019-12-02 03:51:32
I am using masm32 to compile and link on windows 7, which works just fine with below code. However invoking stdOut isn't simply printing anything on my command prompt. what am i doing wrong? .386 .model flat, stdcall option casemap:none include C:\masm32\include\windows.inc include C:\masm32\include\kernel32.inc include C:\masm32\include\user32.inc include C:\masm32\include\masm32.inc includelib C:\masm32\lib\kernel32.lib includelib C:\masm32\lib\user32.lib includelib C:\masm32\lib\masm32.lib .data MsgBoxCaption db "Message Box Caption", 0 MsgBoxText db "Win32 Assembly is great!", 0 .data? ;

x86 instructions to set parity, overflow, & sign flags

半世苍凉 提交于 2019-12-02 00:07:52
问题 We have the STC instruction to set the carry flag. Do we have similar instructions for parity, overflow, sign flags etc? I have tried STP , STS etc but it seems these don't exist! 回答1: No, those commands don't exist. The way you find out is by reading the instruction reference manuals carefully. They don't really need to exist. You can effectively implement them pretty easily. Here's one of many ways, if you don't mind other bits getting set: STP: XOR AL,AL ; resets parity bit XOR AL,1 ; ...

Accessing Segment Registers MASM

a 夏天 提交于 2019-12-01 23:42:06
问题 I'm trying to query the value located in the Process Enviornment Block, pointed to by the FS segment register. Attempting to compile code with the fs:[0] segment included results in an error (error A2108: use of register assumed to ERROR). How do you query the segment registers?! Thanks 回答1: MASM by default assumes that any access to the segment registers is an error (which usually it is). You need to redefine the assumptions for the FS register using ASSUME FS:NOTHING . You can place this

Accessing Segment Registers MASM

五迷三道 提交于 2019-12-01 21:35:59
I'm trying to query the value located in the Process Enviornment Block, pointed to by the FS segment register. Attempting to compile code with the fs:[0] segment included results in an error (error A2108: use of register assumed to ERROR). How do you query the segment registers?! Thanks MASM by default assumes that any access to the segment registers is an error (which usually it is). You need to redefine the assumptions for the FS register using ASSUME FS:NOTHING . You can place this directive at the top of your file, OR you could "reassume" the FS register temporarily. Example: ASSUME FS

x86 instructions to set parity, overflow, & sign flags

此生再无相见时 提交于 2019-12-01 20:47:44
We have the STC instruction to set the carry flag. Do we have similar instructions for parity, overflow, sign flags etc? I have tried STP , STS etc but it seems these don't exist! No, those commands don't exist. The way you find out is by reading the instruction reference manuals carefully. They don't really need to exist. You can effectively implement them pretty easily. Here's one of many ways, if you don't mind other bits getting set: STP: XOR AL,AL ; resets parity bit XOR AL,1 ; ... then set parity bit STO: OR AL, 0FFh SUB AL, 080h ; sets overflow STS: OR AL, 0FFh ; sets sign bit If you

Why is my masm32 program crashing whenever I try using interrupts?

孤街浪徒 提交于 2019-12-01 17:54:14
问题 Here's the code: .386 ;target for maximum compatibility .model small,stdcall ;model .code main: int 20h END main Result: http://img705.imageshack.us/img705/3738/resultom.png "test.exe has stopped working" - always right when it reaches the interrupt. This is the interrupt I'm trying to use. It should simply exit the program. Others I've tried include character input/output, etc.. Nothing works. I'm on windows 7, using masm32 with the WinAsm IDE. There are so many cool things it seems I should

Assembly language - masm32 - multiplying

和自甴很熟 提交于 2019-12-01 14:42:33
I am multiplying 3 numbers which works good even with a carry. I want to add a 4th number to multiply just for learning purposes. After i multiply 3 numbers i shift into EDX and print. Works great. After i add a 4th number i think i am multiplying 32bit x 32bit? So it stores into EDX:EAX? Would i then need to shift EAX into EDX so they are together to print? Im not sure if i am doing it right for the 4th number? .data? num1 dd ? num2 dd ? num3 dd ? num4 dd ? .data sum dd 0 prod dd 0 prod2 dd 0 here are the prompts mov EAX, sval(input("Enter first number: ")) mov num1, EAX mov EAX, sval(input(