flat assembler
Message board for the users of flat assembler.
Index
> Windows > Fasm x64 pe64 win32 program |
Author |
|
B.Dubious 09 Apr 2020, 18:00
I've been trying to learn some assembly using fasm and windows. I've currently hit a wall, I've spent hours trying to debug this problem, I've gone off and studied some more and come back to it and still I can't figure it out. As far as I can see I'm giving it all the right things, and while before it was returning an error 6 using GetLastError I fixed the problem with the DC. I'm trying to use StretchDIBits but although it runs without error it returns zero, and the desired behaviour isn't achieved. I've tried stepping through the code again and again and again, I've checked all my parameters several times, but I just can't find the problem. It's truly driving me crazy. I've checked the sizes of the arguments and everything seems to be correct. Please advise...
|
|||||||||||||||||||||
09 Apr 2020, 18:00 |
|
B.Dubious 09 Apr 2020, 18:07
Wait, I see what's probably my mistake... I'm using a bitmapinfoheader not a bitmapinfo... eejit. I'll try checking if that's the problem.
|
|||
09 Apr 2020, 18:07 |
|
revolution 09 Apr 2020, 18:08
Since your code is very short, you can make it more accessible for people by pasting it directly into your message inside code tags.
|
|||
09 Apr 2020, 18:08 |
|
revolution 09 Apr 2020, 20:45
In assembly to zero out any memory buffer there is rep stosq. Set RAX=0, RCX the qword count, and RDI the destination. This is what many HLL libraries use to do the job, but they generally hide that from you.
|
|||
09 Apr 2020, 20:45 |
|
B.Dubious 09 Apr 2020, 20:58
That's a cool tip, I can definitely make use of that. I think I've seen it before on godbolt or in the disassembly of some c/c++ when using a for loop to zero out a buffer, though I don't really look at it closely enough that I learned what that was until just now!
I don't think I can use that in the .data section though, in the .data section is everything zeroed by default? Like with static in c/c++ ? If you set rax=n would that repeat the operation and initialize every quadword to n? |
|||
09 Apr 2020, 20:58 |
|
revolution 09 Apr 2020, 21:12
If your .data section is writeable then you can zero it out at any time. Windows will initialise all undefined data as zero at startup, but there can be times when you need to re-zero things at runtime. This is assembly you can do whatever you want.
Setting RAX to some data pattern is fine. Usually zero is the most convenient, but you are free to set it to any value. The CPU won't care what you set it to, it just follows your instructions. |
|||
09 Apr 2020, 21:12 |
|
B.Dubious 09 Apr 2020, 21:21
I see, cool! I just wish I knew how to make it do the things I want it to do, haha
When setting struc's I'm a little confused. I can do something like the following: struct v2i x dd ? y dd ? ends then if i had another struct that was two v2i fields, i can do this: my_instance twovecs 0,0 but is there some short hand to set those structs? my_instance twovecs {0,0}, {0,0} or something along those lines, or do I have to define two separate v2i and then set those that way like: my_instance twovecs v1, v2 |
|||
09 Apr 2020, 21:21 |
|
revolution 09 Apr 2020, 21:29
Let's be clear here. struct with a final "t" is a macro in the fasm package. But struc without the find "t" is the raw structure that uses curly brackets {} to define it. They operate differently.
Also, if you are allocating the structure at runtime then you need to set the values in your code. But if you are instantiating the structure at assembly time then the initial values can be set in the structure. So we need to differentiate those situations to know how to write the code. |
|||
09 Apr 2020, 21:29 |
|
B.Dubious 10 Apr 2020, 17:14
Sorry about using them interchangeably! I'm using the struct/ends to define the windows types, but for my own side of things I'm using a struc{} to define a draw_buffer, which has dimensions, a pointer to the pixel buffer, and a pointer to the BITMAPINFO struct/ends that is just a copy paste of the BITMAPINFOHEADER from the fasm includes with four additional bytes I intend to leave zeroed. I was wanting to defined the struct/ends to have another struct/ends as a field, then have a pointer to that in my struc{}
I call an Init proc early on at runtime, but I'd like to know how to initialise at assembly time cleanly too. I was hoping to know how to do something of the sort: struct v2i x dd ? y dd ? ends struct bounds upperLeft v2i ? lowerRight v2i ? ends when initialising bounds in the .data section I can do mybounds bounds 0,0 but I don't know how to set the fields of the v2i's Other than the use of ? and the names and . what are the differences between struc{} and struct/ends |
|||
10 Apr 2020, 17:14 |
|
Ali.Z 10 Apr 2020, 23:32
_________________ Asm For Wise Humans |
|||
10 Apr 2020, 23:32 |
|
revolution 10 Apr 2020, 23:49
For defined data in an initialised section you can do this:
Code: struct v2i x dd ? y dd ? ends struct bounds upperLeft v2i ? lowerRight v2i ? ends mybounds bounds <0xa5a5a5a5,0x5a5a5a5a>,<0xc3c3c3c3,0xb1b1b1b1> |
|||
10 Apr 2020, 23:49 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.