flat assembler
Message board for the users of flat assembler.
Index
> Main > best way of handling bits |
Author |
|
revolution 31 Jan 2011, 03:44
"Best" in what way? "Best" for what purpose?
You have to define your goals before you can know what is best to meet those goals. If your goal is to use the smallest amount of memory possible then best for that would be very different from a goal to compute answers as fast as possible. It all depends upon what you want to achieve. |
|||
31 Jan 2011, 03:44 |
|
edfed 10 Mar 2011, 00:27
(re)found the answer right now.
i never focused on bitfields before to do the translation of the BT instruciton (BTC, BTS, BTR are derivates) and now, i can say that there is an instruction (a set of instrucitons) to act directlly on bits, one by one, exactlly as if they were bytes. just look at this little test code: Code: org 100h push 0b800h pop es mov cx,256*8-1 mov di,0 mov ah,4fh @@: bt [bitfield],cx mov al,'0' adc al,0 stosw loop @b ret bitfield: times 256 db %-1 and see the result: BT wrote:
then, what is appearing? BT op1,op2 if op1 is mémory, and op2 is register, the adress of the bit is picked from the register, the high part is used to locate the byte, and the low part used to locate the bit in the byte. then, what is cool with this instruciton, it just needs few operands, and the bit index can be directlly taken from a zero based value. in fact, i never saw a clear explanation of this fact before to dive more in instrucitons set. and i want to share this with you. before, i believed BT was just used to scan a bit in a single data, and just remembered a little some lecture about the total adressing of any bit in the range of many bits. if op2 is a 32 bit register, and op1 is memory, you can scan up to 256 MB ram with just a loop. this instruction will be very interresting for something i planned about file system. scan sector map to find first available disk zone. and no matter the time it takes, my computer spend a lot of time doing nothing, and doing it bad because it is win98. |
|||
10 Mar 2011, 00:27 |
|
Teehee 10 Mar 2011, 01:16
hey ed, do you think i can use that in my font issue?
also, whats does that mean: times 256 db %-1 _________________ Sorry if bad english. |
|||
10 Mar 2011, 01:16 |
|
edfed 10 Mar 2011, 11:07
|
|||
10 Mar 2011, 11:07 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.