flat assembler
Message board for the users of flat assembler.
Index
> Main > Hello, I have a few questions... |
Author |
|
vador 27 Jul 2007, 13:55
About div
Example: to divide a 64-bit number by a 32-bit number: Code: mov eax,65536 ; 65536 is the low-order dword of the dividend mov edx,0 ; 0 is the high-order dword of the dividend mov ecx,1024 ; 1024 is the divider div ecx ; divide what is in edx:eax with ecx ;and now you have the result in eax Last edited by vador on 27 Jul 2007, 14:25; edited 1 time in total |
|||
27 Jul 2007, 13:55 |
|
vador 27 Jul 2007, 14:10
search MSDN for the function wsprintf
when you use this function, all %d's are replaced with dword's, and %s's are replaced with strings, and so on... a little example: in the data section: Quote:
in the code section: Quote:
After that, szDestString will be: "1+1=2". As you see, the %d was replaced by the value of eax |
|||
27 Jul 2007, 14:10 |
|
vador 27 Jul 2007, 14:24
Labels starting with a dot (.) are called 'local labels'. They are associated with the previous non-local label.
So you can write: Code: label1: ;non-local label ;some code .local_label ;some code jmp .local_label label2: ;some code .local_label ;some code jmp .local_label label3: but you cannot do: Code: label1: ;non-local label ;some code .local_label1 ;some code jmp .local_label2 ;<=== this gives an error label2: ;some code .local_label2 ;some code jmp .local_label2 label3: because .local_label2 is only accessible within the area between label2 and label3. To access .local_label2 from elsewere in the code, you must write: Code: label1: ;non-local label ;some code .local_label1 ;some code jmp label2.local_label2 ;<=== this works! label2: ;some code .local_label2 ;some code jmp .local_label2 label3: |
|||
27 Jul 2007, 14:24 |
|
Hobo 28 Jul 2007, 09:38
Hey, thanks for you're replies Vador, everything explained nicely and i understand it now
|
|||
28 Jul 2007, 09:38 |
|
vador 28 Jul 2007, 16:22
i didnt' know i could explain something nicely in english...
|
|||
28 Jul 2007, 16:22 |
|
Hobo 29 Jul 2007, 00:54
Haha lol well you managed i couldn't even tell english wasn't your first language
I have another question now lol (Should go in Windows section, but i figured i wouldn't make another topic just for something that im sure can be simply solved) I've been trying to set cursor for a particular control within my main window, I'm pretty sure it can be done by subclassing the WM_SETCURSOR notification (http://msdn2.microsoft.com/en-us/library/ms648382.aspx) but i haven't been able to do it... If you run the code below, you'll be able to see more clearly what i want to be done... ( it shows a window which explains exactly what i want ) Code: FORMAT PE GUI 4.0 Entry _Main include '%fasminc%\Win32A.inc' section '.data' data readable writeable _Window.Class db 'Pinecone', 0 _Window.Text db 'Change cursor on the box', 0 _LabelText db 'I want to change the cursor on the box to the left to IDC_CROSS...', 0 _StaticClass db 'Static', 0 _ErrorMessage db 'Startup Failed.', 0 _FontName db 'Microsoft Sans Serif', 0 WC WNDCLASS 0, WindowProc, 0, 0, NULL, NULL, NULL, COLOR_BTNFACE + 1, 0, _Window.Class Msg MSG _FontObject dd ? section '.code' code readable executable _Main: invoke GetModuleHandle, 0 mov [WC.hInstance], eax invoke LoadIcon, IDI_APPLICATION mov [WC.hIcon], eax invoke LoadCursor, IDC_ARROW, 0 mov [WC.hCursor], eax invoke RegisterClass, WC test eax, eax jz .Error invoke CreateWindowEx, NULL, _Window.Class, _Window.Text, WS_VISIBLE + WS_CAPTION + WS_SYSMENU,150, 150, 220, 120, HWND_DESKTOP, 0, [WC.hInstance], NULL test eax, eax jz .Error .MessageLoop: invoke GetMessage, Msg, NULL, 0, 0 cmp eax, 1 jb .ExitProcess jne .MessageLoop invoke TranslateMessage, Msg invoke DispatchMessage, Msg jmp .MessageLoop .ExitProcess: invoke ExitProcess, 0 .Error: invoke MessageBox, HWND_DESKTOP, _ErrorMessage, NULL, MB_ICONERROR + MB_OK jmp .ExitProcess proc WindowProc hWnd, wMsg, wParam, lParam push ebx esi edi cmp [wMsg], WM_DESTROY je .WM_DESTROY cmp [wMsg], WM_CREATE je .WM_CREATE .DefWindowProc: invoke DefWindowProc, [hWnd], [wMsg], [wParam], [lParam] jmp .Return .WM_CREATE: invoke CreateFont, 16, 0, 0, 0, 0, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_RASTER_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FIXED_PITCH + FF_DONTCARE, _FontName mov [_FontObject], eax invoke CreateWindowEx, WS_EX_CLIENTEDGE, _StaticClass, NULL, WS_VISIBLE + WS_CHILD + SS_BLACKRECT, 10, 10, 80, 70, [hWnd], 0, [WC.hInstance], NULL invoke CreateWindowEx, NULL, _StaticClass, _LabelText, WS_VISIBLE + WS_CHILD + SS_CENTER , 100, 10, 100, 70, [hWnd], 0, [WC.hInstance], NULL invoke SendMessage, eax, WM_SETFONT, [_FontObject], FALSE jmp .Handled .WM_DESTROY: invoke DeleteObject, _FontObject invoke PostQuitMessage, 0 .Handled: xor eax, eax .Return: pop edi esi ebx ret endp section '.idata' import data readable writeable library Kernel, 'Kernel32.dll',\ User, 'User32.dll',\ GDI, 'GDI32.dll' import Kernel,\ GetModuleHandle, 'GetModuleHandleA',\ ExitProcess, 'ExitProcess' import User,\ CreateWindowEx, CreateWindowExA',\ RegisterClass, RegisterClassA',\ GetMessage, 'GetMessageA',\ TranslateMessage, TranslateMessage',\ DispatchMessage, 'DispatchMessageA',\ DefWindowProc, 'DefWindowProcA',\ PostQuitMessage, 'PostQuitMessage',\ LoadIcon, 'LoadIconA',\ LoadCursor, 'LoadCursorA',\ MessageBox, 'MessageBoxA',\ SendMessage, 'SendMessageA' import GDI,\ CreateFont, 'CreateFontA',\ DeleteObject, 'DeleteObject' Thanks again for any help |
|||
29 Jul 2007, 00:54 |
|
Yardman 29 Jul 2007, 08:16
[ Post removed by author. ]
Last edited by Yardman on 04 Apr 2012, 02:29; edited 1 time in total |
|||
29 Jul 2007, 08:16 |
|
Hobo 29 Jul 2007, 08:46
Yes, thanks for that, it's exactly what i wanted.
|
|||
29 Jul 2007, 08:46 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.