flat assembler
Message board for the users of flat assembler.
Index
> Windows > LOWORD HIWORD method |
Author |
|
revolution 27 Aug 2008, 02:20
How are you defining "best"? Best in what way? Easiest to understand? Least typing? Lowest CPU cycles used? Smallest code generated? Other?
|
|||
27 Aug 2008, 02:20 |
|
LocoDelAssembly 27 Aug 2008, 02:50
Code: mov eax, [lparam] movzx edx, ax shr eax, 16 mov [g_width], edx ; LOWORD(lParam) mov [g_height], eax ; HIWORD(lParam) But it is just another way, it doesn't mean that it is better nor worse. |
|||
27 Aug 2008, 02:50 |
|
bitshifter 27 Aug 2008, 03:02
revolution wrote: How are you defining "best"? Best in what way? Easiest to understand? Least typing? Lowest CPU cycles used? Smallest code generated? Other? Yes, all of those... LocoDelAssembly: Very nice! |
|||
27 Aug 2008, 03:02 |
|
bitshifter 27 Aug 2008, 06:23
And now i need some help on how to divide those two numbers...
psuedo C code: float g_aspect = (float)g_width / (float)g_height In the manual it references using fild and fdiv with st0 and st1 but when i try to implement a solution i just end up crashing my program. "cry..." I tested for a divide by zero but thats not whats causing problems, its just that i never fooled with FPU before. Can someone convert my psuedo code to 32bit assembly? |
|||
27 Aug 2008, 06:23 |
|
Madis731 27 Aug 2008, 07:08
Code: fild [g_width] ;Maybe you forgot FILD!? fild [g_height] fdiv fstp Something like that... haven't done float coding that much I can give you SSE though Code: movd xmm0,edx ;before saving to g_width cvtdq2ps xmm0,xmm0 movd xmm1,eax ;before saving to g_height cvtdq2ps xmm1,xmm1 divps xmm0,xmm1 cvtps2dq xmm0,xmm0 movd eax,xmm0 ;Save back to eax Really simple and unoptimized!!! |
|||
27 Aug 2008, 07:08 |
|
vid 27 Aug 2008, 07:28
back to first question: what is wrong with obvious solution?
Code: mov ax, word [somewhere] ;loword mov bx, word [somewhere+2] ;hiword |
|||
27 Aug 2008, 07:28 |
|
revolution 27 Aug 2008, 07:43
bitshifter wrote:
|
|||
27 Aug 2008, 07:43 |
|
sinsi 27 Aug 2008, 08:22
vid wrote: back to first question: what is wrong with obvious solution? Code: movzx eax,word[lparam] movzx edx,word[lparam+2] ;possible access violation here (1 in a 1000000) As for the float, do you want the answer as a float or an integer? |
|||
27 Aug 2008, 08:22 |
|
bitshifter 27 Aug 2008, 08:23
vid wrote: back to first question: what is wrong with obvious solution? Yes, i had played with similar method also. Code: proc WindowProc hwnd,umsg,wparam,lparam ... movzx eax,word[esp+16] ; LOWORD(lparam) mov [g_width],eax movzx eax,word[esp+18] ; HIWORD(lparam) mov [g_height],eax Looks like you can skin this cat in many ways. I am just learning so some of these options are unclear. |
|||
27 Aug 2008, 08:23 |
|
Pinecone_ 04 Nov 2008, 14:31
how is
Code: movzx edx,word[lparam+2] |
|||
04 Nov 2008, 14:31 |
|
vid 04 Nov 2008, 15:03
it's not.
|
|||
04 Nov 2008, 15:03 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.