NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: xellos on April 25, 2011, 06:28:39 PM

Title: why is my code not working?
Post by: xellos on April 25, 2011, 06:28:39 PM
it compiles without errors

Code: [Select]
import SetCursorPos user32.dll
extern SetCursorPos

import ExitProcess kernel32.dll
extern ExitProcess

segment .data use32
x dd 10
y dd 10

segment .bbs use32

segment .code use32

..start:
push 0
push x
push y
call [SetCursorPos]

push dword 0x00
call [ExitProcess]
ret
Title: Re: why is my code not working?
Post by: Keith Kanios on April 25, 2011, 08:57:55 PM
Off-hand you are not using SetCursorPos correctly. It expects only two arguments, both integer values.
Title: Re: why is my code not working?
Post by: Frank Kotler on April 26, 2011, 03:51:57 AM
In case you don't get what Keith is telling you about "values"...

Code: [Select]
push x
push y

pushes the addresses (offsets) of the two variables. To get the "values", you'd:

Code: [Select]
push dword [x]
push dword [y]

(I'll take a guess that you're supposed to push "[y]" first, too - you can figure it out when you make 'em different)

Best,
Frank

Title: Re: why is my code not working?
Post by: xellos on April 26, 2011, 10:09:44 AM
thank you it works