News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Ramblings...

Started by sinsi, April 04, 2025, 02:56:26 PM

Previous topic - Next topic

sinsi

In VB you could have code like this
  If FunctionThatReturnsAnInteger(arg) then
    DoSomethingWhenTrue
  Else
    DoAnotherThingWhenFalse
  End If
The missing code is implied If FunctionThatReturnsAnInteger(arg) <> 0

False = 0
True = non-zero

But we also have to take into account the size of what we're testing. For example, RegisterClassEx returns an ATOM (16-bit unsigned) but how many of use this code to check for success?
  test eax,eax ;should be test ax,ax ?
  jz failed
How does C/C++ test for failure with this function?


sinsi

Quote from: daydreamer on April 09, 2025, 02:25:36 AMdoes that mean always when being accused of post ramblings anywhere in forum,Stoo needs to move the rambling posts here ?:)
Get off my lawn!

daydreamer

Quote from: sinsi on April 09, 2025, 02:49:18 AM
Quote from: daydreamer on April 09, 2025, 02:25:36 AMdoes that mean always when being accused of post ramblings anywhere in forum,Stoo needs to move the rambling posts here ?:)
Get off my lawn!

reminds me off old dos game "Red Neck Rampage" enemies walks around -"get off my lawn!" :)
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

sinsi

Quote from: daydreamer on April 09, 2025, 03:05:06 AMreminds me off old dos game "Red Neck Rampage" enemies walks around -"get off my lawn!" :)
Ah yes, the cheerleaders in the school bus complaining how "nipply" the weather was  :biggrin:


sinsi


TimoVJL

test ax, ax
00000071  8D45D0                  lea eax, [ebp-30h]
00000074  50                      push eax
00000075  FF1500000000            call dword ptr [__imp__RegisterClassExA@4]
0000007B  6685C0                  test ax, ax
0000007E  7507                    jnz L_87
00000080  31C0                    xor eax, eax
00000082  E98B000000              jmp L_112
000000AF  488D8C2490000000         lea rcx, [rsp+90h]
000000B7  FF1500000000             call qword ptr [__imp_RegisterClassExA]
000000BD  6685C0                   test ax, ax
000000C0  7507                     jnz L_C9
000000C2  31C0                     xor eax, eax
000000C4  E9C8000000               jmp L_191
May the source be with you

sinsi

Excellent TimoVJL, cheers :thumbsup:

Fun fact, you can use the returned atom in CreateWindowEx
QuotelpClassName If a class atom created by a previous call to RegisterClass or RegisterClassEx, it must be converted using the macro MAKEINTATOM. (The atom must be in the low-order word of lpClassName; the high-order word must be zero.)

jj2007

Quote from: sinsi on April 09, 2025, 04:24:30 AMFun fact, you can use the returned atom in CreateWindowEx

Oh no....! Once more we need to rewrite our templates ;-)

  invoke CreateWindowEx, WS_EX_ACCEPTFILES, rv(RegisterClassEx, addr wc), chr$("Hello World"),
     WS_OVERLAPPEDWINDOW or WS_VISIBLE,
     600, 150, 750, 400, ; window position: x, y, width, height
     NULL, NULL, wc.hInstance, NULL

NoCforMe

Quote from: sinsi on April 09, 2025, 02:48:09 AMIn VB you could have code like this
  If FunctionThatReturnsAnInteger(arg) then
    DoSomethingWhenTrue
  Else
    DoAnotherThingWhenFalse
  End If
The missing code is implied If FunctionThatReturnsAnInteger(arg) <> 0

False = 0
True = non-zero

But we also have to take into account the size of what we're testing. For example, RegisterClassEx returns an ATOM (16-bit unsigned) but how many of use this code to check for success?
  test eax,eax ;should be test ax,ax ?
  jz failed
How does C/C++ test for failure with this function?
Butbutbut ... even if we do get an ATOM returned (unsigned WORD), it's still going to be non-zero if successful (test eax, eax will evaluate to non-zero), so what's the problem?
After all, AX is half of EAX.
Assembly language programming should be fun. That's why I do it.

jj2007

Theoretically, RegisterClassEx could return BAAD0000h...

daydreamer

About atoms in Windows
Atom=atom+atom ; fusion
Atom=atom/2 ; fission  :tongue:
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

sinsi

CS_BYTEALIGNCLIENT
0x1000
Aligns the window's client area on a byte boundary (in the x direction).
This style affects the width of the window and its horizontal placement on the display.

CS_BYTEALIGNWINDOW
0x2000
Aligns the window on a byte boundary (in the x direction).
This style affects the width of the window and its horizontal placement on the display.
I see those class flags still used today  :badgrin: