flat assembler
Message board for the users of flat assembler.
Index
> Windows > Relapse |
Author |
|
revolution 27 Nov 2010, 07:56
Your code goes in WindowProc.
The message loop will dispatch relevant messages to your WindowProc procedure. Inside WindowProc you check wmsg to what you need to do. |
|||
27 Nov 2010, 07:56 |
|
keantoken 27 Nov 2010, 08:23
Okay, the "uses" operator in the WindowProc statement determine which registers are used to call the function. does this mean I can write the statement differently and cause it to use different registers?
Thanks, - keantoken |
|||
27 Nov 2010, 08:23 |
|
revolution 27 Nov 2010, 08:34
See the MINIPAD example for a slightly more thorough use of WindowProc. And when you really feel confident see the FASMW source for a full program usage example.
The "uses" is only there to save and restore clobbered registers, you can't change it unless your code doesn't use a particular register. |
|||
27 Nov 2010, 08:34 |
|
keantoken 27 Nov 2010, 10:48
Oh, so it pushes them to the stack or some place out of sight so you don't risk sending garbage to windows?
I succeeded in creating a messagebox, but I broke the program too. 1: If I want to receive user input from the messagebox, do I need to give it a specific handle? 2: Where does the input from the MessageBox go? Is it put in [wmsg] or something like that? Google is stubborn. - keantoken |
|||
27 Nov 2010, 10:48 |
|
revolution 27 Nov 2010, 10:53
keantoken wrote: Oh, so it pushes them to the stack or some place out of sight so you don't risk sending garbage to windows? keantoken wrote: I succeeded in creating a messagebox, but I broke the program too. Instead of searching for wmsg (which is your internal variable name only) try searching for MessageBox to get the MS documentation page. |
|||
27 Nov 2010, 10:53 |
|
keantoken 27 Nov 2010, 11:24
I've been looking at this page all along, but it doesn't tell me where the return value ends up.
http://msdn.microsoft.com/en-us/library/ms645505%28VS.85%29.aspx - keantoken |
|||
27 Nov 2010, 11:24 |
|
revolution 27 Nov 2010, 11:30
The stdcall calling convention uses EAX for return value.
|
|||
27 Nov 2010, 11:30 |
|
keantoken 27 Nov 2010, 11:55
Okay, but I put
Code: cmp eax,1 je end_loop in a variety of places and clicking the OK button still doesn't exit. Instead the program just loops and creates another messagebox, and it's impossible to use the exit button to close the program. - keantoken |
|||
27 Nov 2010, 11:55 |
|
revolution 27 Nov 2010, 11:59
Show your code.
|
|||
27 Nov 2010, 11:59 |
|
keantoken 27 Nov 2010, 12:08
Nevermind, I figured out what I did wrong. Something really stupid.
Well, I've gotten a few lines of text further during this latter half of my day, tomorrow I want to do some kind of calculation and display it in the text box. Lol, I wrote a square root algorithm in assembly once. I'll have to look at it again to see if it's any good... To bed and thanks, - keantoken |
|||
27 Nov 2010, 12:08 |
|
keantoken 28 Nov 2010, 01:25
Okay, I want the messagebox to show up 4 seconds after the program start. What do I use to delay for 4 seconds?
I used SignalObjectAndWait,NULL,NULL,4000,FALSE but it doesn't appear to work past a few hundred mS. Or maybe I'm using it wrong. I think my first project will be to make a template for testing calculator algorithms and displaying finish times, and see how fast I can make them. Then I might make fast math macros or includes or whatever you do with those. So what do people usually do to measure the speed of code? - keantoken |
|||
28 Nov 2010, 01:25 |
|
keantoken 28 Nov 2010, 01:39
I found this:
http://msdn.microsoft.com/en-us/library/ms644905%28v=VS.85%29.aspx http://cplus.about.com/od/howtodothingsi2/a/timing.htm How do get the compiler to put the lpFrequency data somewhere where I can use it? I notice the GetMessage function uses msg, which is also in the data section, but using the same syntax to create a lpFrequency variable gives me a compiler error. - keantoken |
|||
28 Nov 2010, 01:39 |
|
drobole 28 Nov 2010, 21:34
To sleep for 4 seconds you can use the Sleep function from Windows API.
To do high resolution measuring you could try the QueryPerformanceCounter function. I don't have any assembly example of those but I know they are often used in C++. You should be able to find C++ examples of those functions online, and since the difference between assembly and C/C++ is all but cosmetic you should be able to apply them to fasm pretty easily. If you prefer to work with linux, like me, I don't think you should go through the wine libraries. Go native with either Xlib or XCB. Another option is to link your assembly to the fltk library, making your application cross platform friendly. If you need a debugger for linux you could look into fdbg or edb, which is GUI based. Just my opinion |
|||
28 Nov 2010, 21:34 |
|
bitRAKE 28 Nov 2010, 22:51
keantoken wrote: So what do people usually do to measure the speed of code? http://www.strchr.com/performance_measurements_with_rdtsc (...and comments.) Quote: Constant TSC behavior ensures that the duration of each clock tick is uniform and supports the use of the TSC as a wall clock timer even if the processor core changes frequency. This is the architectural behavior moving forward for all Intel processors. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
28 Nov 2010, 22:51 |
|
keantoken 04 Dec 2010, 19:19
Thanks everyone.
Haven't been at this for a few days, but... I still can't figure out how you create variables. I need to create a rewritable variable to store edx:eax in after the RDTSC function. I want to try: Code: xor eax,eax invoke CPUID invoke RDTSC mov [clcks],edx:eax But, do I need to state clcks as a variable beforehand? - keantoken |
|||
04 Dec 2010, 19:19 |
|
keantoken 04 Dec 2010, 21:05
Okay, that didn't work.
BUT I figured out that putting Code: clcks dd ? At the start didn't cause an error. So I've reverted to the QueryPerformanceCounter temporarily just to get something done. So far it compiles without error, which is a good sign. By chance does anyone know how to convert the counter return value to unicode so I can display it in the messagebox? And yes, I think I know how ridiculous this must look. It was also gruesome while I was (and still am) learning analog electronics at DIYAudio.com. However I am now a respected member of the community. - keantoken |
|||
04 Dec 2010, 21:05 |
|
keantoken 04 Dec 2010, 21:28
Here is the program currently.
Code: ; Template for program using standard Win32 headers format PE GUI 4.0 entry start include 'win32w.inc' section '.data' data readable writeable _class TCHAR 'FASMWIN32',0 _title TCHAR 'yeahyeahyeah',0 _error TCHAR 'Startup failed.',0 _die TCHAR 'DIED!',0 _bye TCHAR 'bye',0 clcks dd ? wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class msg MSG section '.text' code readable executable start: invoke GetModuleHandle,0 mov [wc.hInstance],eax invoke LoadIcon,0,IDI_APPLICATION mov [wc.hIcon],eax invoke LoadCursor,0,IDC_ARROW mov [wc.hCursor],eax invoke RegisterClass,wc test eax,eax jz error invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,800,192,NULL,NULL,[wc.hInstance],NULL test eax,eax jz error msg_loop: invoke GetMessage,msg,NULL,0,0 cmp eax,1 jb end_loop jne msg_loop invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop error: invoke MessageBox,NULL,_error,NULL,MB_ICONERROR+MB_OK end_loop: invoke ExitProcess,[msg.wParam] proc WindowProc uses eax ebx esi edi, hwnd,wmsg,wparam,lparam cmp [wmsg],WM_DESTROY je .wmdestroy xor eax,eax invoke QueryPerformanceFrequency,[clcks] invoke MessageBox,NULL,[clcks],_die,MB_OK+MB_ICONEXCLAMATION+MB_SYSTEMMODAL cmp eax,1 je end_loop .defwndproc: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp .finish .wmdestroy: invoke PostQuitMessage,0 xor eax,eax .finish: ret endp section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL' include 'api\kernel32.inc' include 'api\user32.inc' With this I tried to get the counter frequency in clcks and then used it in the messagebox call so that even if not the actual number, I could perhaps get a random ASCII character to show up. No such luck. It just reverts to one of the inbuilt icons or "ERROR". Hmmm. - keantoken |
|||
04 Dec 2010, 21:28 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.