I have created an app that can create bitmasks and things like that in a very simple way. It's just to fill in the bits visually using 32 checkboxes. You can choose to copy the result as a hex value, unsigned decimal, signed decimal or in a binary form by clicking on the different labels. Full source code included (it's a mess though).


: fixed the preservation of esi,edi and ebx
Posted on 2003-03-02 04:45:28 by Delight
Your program crashed on win98 se.I have added uses edi esi ebx magic to your dlgproc and it works now.Thanks for this app quite educational.
Posted on 2003-03-02 05:55:15 by LaptoniC
Thanks for fixing that LaptoniC. I always forget it :)
Posted on 2003-03-02 06:09:49 by Delight
Delight,

Your application works fine on my Win XP.:alright:

Thanks for this tool,

Regards,

Vortex
Posted on 2003-03-02 09:15:46 by Vortex
Another 'tool' idea along the same vain would be to write a fast multiply tool:

You know that "shl eax, 2" is faster than "imul eax, 4".

But what about non-base 2 "primes", such as 6.

xor ecx, ecx
mov edx, number
mov eax, edx
shl eax, 2
add ecx, eax
mov eax, edx
shl eax, 1
add ecx, eax

now 'ecx = number * 6'.

This is done simply by evaluating the bits from each multiplier number given. Bit 2 + Bit 1 = 6. You could put check box options to generate a macro, as well as optionally provide push/pop code, and select what 3 registers should be used.

There is also room for optomization here, since the first result can be placed with a mov to ecx, not add. And the last result can be applied to the data in EDX and save the move to eax first.

Just an idea.
:alright:
NaN
Posted on 2003-03-02 09:50:54 by NaN
I was thinking that it would be cool to have this as an addin for RadASM so I modified your code a little to enable it as an Addin button on the toolbar. I hope you don't mind. I have attached the code, it's just a rough hack and I haven't touched your code (well I added Hex tags to the Hex output). I have called it BitMe2 just add BitMe2.dll to the AddIns section of RadASM.INI

Donkey
Posted on 2003-03-02 13:41:19 by donkey
Wow, that's great Donkey :alright: I was thinking of making a RadASM plugin of it but I didn't really know how and I'm too lazy to learn how to. By the way, I have created a 16x16 icon that looks much better on the toolbar.

: Hmm...strange. When I assemble the project the resulting dll is 6.5 kB while your attached zip includes a dll that is 24.5 kB. Why?
Posted on 2003-03-02 13:52:13 by Delight
16x16 pixels icon
Posted on 2003-03-02 14:13:45 by Delight
Uploaded the new file to my original post with the replaced icon

You should be able to change :

include c:\radasm\masm\inc\RadASM.inc

to :

include x:\radasm\masm\inc\RadASM.inc

in the BitMe2.ASM file to change the location for the RadASM.INI file.

Donkey
Posted on 2003-03-02 14:19:33 by donkey
I found the silly "bug" myself. It works great now, but your dll is still 24 kb and mine 6.5. What's added when you assemble it?
:stupid:
Posted on 2003-03-02 14:31:36 by Delight
Oh, I forgot to add /FILEALIGN:512 to the linker that I use when I compiled. I'll fix it.

uploaded the updated DLL to my original post, it's now 6.5 KB like yours. It's just a peculiarity in LINK Version 6. You have to specify the file alignment or you get huge programs. I had forgotten to modify my MASM.INI link defaults when I upgraded to 2.0.1.1 and don't think to edit my project options.

I added tooltip text for the button as well.

Donkey
Posted on 2003-03-02 14:36:20 by donkey
Hi,

a little gap between the nibbles of each byte would be helpfull too.

Bye Miracle
Posted on 2003-03-03 03:58:36 by miracle
NaN, for multiply by 6 I use:


shl eax,1
lea eax,[eax+eax*2]


using this approach, one can easily multiply with many fixed integers, in less than 5 cycles. I have seen, in fact, a table of such multiplications, but deleted it, thinking it'd be useless.
Posted on 2003-03-03 14:56:43 by Ultrano
Posted on 2003-03-03 15:08:41 by Delight

NaN, for multiply by 6 I use:


shl eax,1
lea eax,[eax+eax*2]


using this approach, one can easily multiply with many fixed integers, in less than 5 cycles. I have seen, in fact, a table of such multiplications, but deleted it, thinking it'd be useless.


Wouldn't add eax, eax be better than shl eax, 1?
Posted on 2003-03-03 16:22:55 by comrade
Good point Ultrano, my oversite. Im really not much of an opomization person. As well your solution does defeat the point a bit.

Thanks for the tip.
:alright:
NaN
Posted on 2003-03-04 00:25:28 by NaN
In hardware domain, it is easier to make the SHL than the ADD, and SHL is faster. 16 times, I suppose. Do not know about the stupid P6, but in K7 I think it's faster this way. Oh, there is a very stupid way of implementing the SHL with D-triggers / or JK triggers, I hope no cpu uses that.
Posted on 2003-03-04 01:08:32 by Ultrano