News:

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

Main Menu

Win32 My First Window

Started by tda0626, April 24, 2024, 11:05:19 AM

Previous topic - Next topic

zedd151

Quote from: tda0626 on May 13, 2024, 04:56:10 AMI came across this site that writes code to what you specify in x86 assembly and had it create a program like sysmets3.
Okay, fantastic!  :biggrin:


QuoteThere were a crap ton of errors when assembling the code but I finally did get it to assemble and link but it doesn't work.
:undecided:  Sorry to hear that, but not unexpected either. You could possibly post the AI generated code, to see if someone here can help you debug it (to find out why it is not working).

NoCforMe

Wellll, my advice is, don't trust that AI much farther than you can throw it.
Really. It just ain't ready for prime time.
Besides, for you it's much better not to rely on a cheating tool like that, if your goal is to actually learn x86 assembly.
Otherwise, if all you want is a cheap and easy way to convert stuff without having to understand it (or without even necessarily producing valid code), go for it.
Assembly language programming should be fun. That's why I do it.

tda0626

Quote from: NoCforMe on May 13, 2024, 06:26:41 AMOtherwise, if all you want is a cheap and easy way to convert stuff without having to understand it (or without even necessarily producing valid code), go for it.


Just wanted to see what it would do when faced with the same problem. It is ok, I still plan on learning the old fashioned way if that makes you feel better.  :cool:

AI is a tool just like a calculator is a tool but is not a substitute for learning, which I am well aware of. Taking Calc 2 in college back in the day, I did everything on paper even though it took me hours to do like 6 problems and several sheets of paper despite having a calculator in reach that would solve those equations in a split second. Instead, I used the calculator to check my math to see if it was right. Granted, what the calculator gave as an answer and what answer I had was not necessarily in the same format, which made it a little difficult to check my homework sometimes. But yea, I get it.





Quote:undecided:  Sorry to hear that, but not unexpected either. You could possibly post the AI generated code, to see if someone here can help you debug it (to find out why it is not working).

If you want to take a look at the source code it generated, it is attached. I had to modify some of it to get it to assemble but 95% is the AI code.

NoCforMe

Well, this is wrong right off the bat:
    .elseif uMsg == WM_PAINT
        invoke BeginPaint, hwnd, offset ps
        invoke DrawSystemMetrics, hDC
        invoke EndPaint, hwnd, offset ps
        xor eax, eax
        ret
I'll leave it to you to tell me what's wrong there.
Hint: DrawSystemMetrics() takes one parameter, hDC.
Assembly language programming should be fun. That's why I do it.

tda0626

The return value from BeginPaint, handle to device context, needs to be passed to the DrawSystemMetrics.


NoCforMe

Bingo!

Extra credit exercise:
There are two ways you can do that. One involves an extra instruction, while the other one doesn't, just a change to a parameter: what are they?
Assembly language programming should be fun. That's why I do it.

tda0626

Removed hDC and just added eax since it already had the value so no need to do something like mov hDC, eax.

NoCforMe

#232
Yep, that's the easier way. Good job.

I hope you don't think I'm being patronizing: I really do think you're doing pretty well here in asm-land.
Assembly language programming should be fun. That's why I do it.