Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
db (510 - ($ - first)) dup (0) ; first is the label of the first instruction (due to lack of $$)
dw 0aa55h
When I try to assemble in WinAsm, I get "error A2092: count must be positive or zero" on the dup line. The smallest value it will take is 532 instead of 510. Then it works exactly as expected, when I build it into a COM file. It has a length of 534 bytes.
When I build it with the last two lines commented out, it creates a file 352 bytes long, so the error is not not occurring because my bootloader is too large.
Does anyone have an explanation for this weird phenomenon?
kendfrey wrote:I am working on a bootloader in MASM, and I think I have worked out all the subtle quirks of MASM, except this one. At the end of my code I have:
db (510 - ($ - first)) dup (0) ; first is the label of the first instruction (due to lack of $$)
dw 0aa55h
When I try to assemble in WinAsm, I get "error A2092: count must be positive or zero" on the dup line. The smallest value it will take is 532 instead of 510. Then it works exactly as expected, when I build it into a COM file. It has a length of 534 bytes.
When I build it with the last two lines commented out, it creates a file 352 bytes long, so the error is not not occurring because my bootloader is too large.
Does anyone have an explanation for this weird phenomenon?
kendfrey wrote:BTW automatic dereferencing is one of my least favourite "features" of MASM.
Don't worry, I have got more than enough dislikes of my own when it comes to all things Linux.
It may not be elegant, but you could try assembling it to see how large the binary is, and then manually put in however many bytes are necessary to bring it up to 510.
If I can't get an answer here, then I will probably manually pad it. I just want to get it done automatically to avoid bugs. Still, I think that type of bug will be the least of my worries.
.model tiny
.code
first:
jmp Main
Main:
cli
hlt
db (12 - ($ - first)) dup (0) ; lowest value that does work
end
The first example fails with error A2092. The second example works exactly as expected.
Now if someone knows where a good place is for MASM bug reports, I could report it.
kendfrey wrote:When I try to assemble in WinAsm, I get "error A2092: count must be positive or zero" on the dup line. The smallest value it will take is 532 instead of 510.
No bug in MASM, your code is already 532 bytes, which is 22 bytes too big.
You can take a look at the example I gave of working vs non-working code. That is the simplest example I could get. That code was in a DosCom project in WinAsm, compiled with MASM32.