><><><><>Heeeeeeeeeeeeeeelp on INT 14!><><><><><> 
Author Message
 ><><><><>Heeeeeeeeeeeeeeelp on INT 14!><><><><><>

Hey peon's (smile),

How does one set or clear bits in a register? I went through it before,
but I never botherd to re-check it out... so now I'm stuck here, using
int 14, where 'bit setting/clearing is so damn essential to initialize
the com-port! (INT 14 - func 00, 01, 02...)

Can anyone give me a 'quick' step though and maybe some source code?
(just briefly covering the subject...)

Thanks in advance!

Yoshix

www.users.dircon.co.uk/~god/dNET/index.htm



Wed, 16 Dec 1998 03:00:00 GMT  
 ><><><><>Heeeeeeeeeeeeeeelp on INT 14!><><><><><>

GO>How does one set or clear bits in a register? I went through it before,
GO>but I never botherd to re-check it out... so now I'm stuck here, using
GO>int 14, where 'bit setting/clearing is so damn essential to initialize
GO>the com-port! (INT 14 - func 00, 01, 02...)

Ok, first of all, interrupt 14h sucks. Second of all, this is how you
set bits:

Each bit is assigned a number. In order from bit #0 to bit #7 the values
are: 1, 2, 4, 8, 16, 32, 64, 128.

So to set bit #0 of the CX register: MOV CX,1
To set bit #6: MOV CX,64

To set more than one bit, add the two bit values. So to set bit #0 and
bit #7, you'd MOV CX,129 because 1+128 =129.

That's the quick simple explanation. I could go into depth but this is
probably good enough.



Wed, 16 Dec 1998 03:00:00 GMT  
 ><><><><>Heeeeeeeeeeeeeeelp on INT 14!><><><><><>

Quote:

>Ok, first of all, interrupt 14h sucks. Second of all, this is how you
>set bits:

>Each bit is assigned a number. In order from bit #0 to bit #7 the values
>are: 1, 2, 4, 8, 16, 32, 64, 128.

>So to set bit #0 of the CX register: MOV CX,1
>To set bit #6: MOV CX,64

>To set more than one bit, add the two bit values. So to set bit #0 and
>bit #7, you'd MOV CX,129 because 1+128 =129.

This doesn't just set bits, it explicitly clears all bits other than
the ones you're setting. This code is no use if you want to set bits
while leaving the rest of the register alone. The best way to
set/clear bits is to use logical operations, OR, AND, XOR.

to set bit 5:-

        or      ax, 00100000b

to clear the bit, you would do:

        and     ax,11011111b

to flip the state of the bit, you would do:

        xor     ax,00100000b

These all leave the other bits in the register in the same state as
they began, before the bit operation.

Additionally, xor'ing a register with itself sets it to zero, using
less code and executing faster than mov ax,0000.

HTH

                        Mike.



Thu, 17 Dec 1998 03:00:00 GMT  
 ><><><><>Heeeeeeeeeeeeeeelp on INT 14!><><><><><>

Quote:

> GO>How does one set or clear bits in a register? I went through it before,
> GO>but I never botherd to re-check it out... so now I'm stuck here, using
> GO>int 14, where 'bit setting/clearing is so damn essential to initialize
> GO>the com-port! (INT 14 - func 00, 01, 02...)

> Ok, first of all, interrupt 14h sucks. Second of all, this is how you
> set bits:

> Each bit is assigned a number. In order from bit #0 to bit #7 the values
> are: 1, 2, 4, 8, 16, 32, 64, 128.

> So to set bit #0 of the CX register: MOV CX,1
> To set bit #6: MOV CX,64

> To set more than one bit, add the two bit values. So to set bit #0 and
> bit #7, you'd MOV CX,129 because 1+128 =129.

> That's the quick simple explanation. I could go into depth but this is
> probably good enough.And, if you don't want to clear all the other bits while setting a bit in

CX, use OR:
  OR CX,129
If you want to clear bits without changing other bits, use AND with the
_inverse_ of the bits you want to clear, e.g.:
  AND CX,255-129
(To clear bits 0 and 7)

Hope this helps...
--
Warren E. Downs

http://moonbase.wwc.edu/homepages/downwa
ftp://rgh-downwa.wwc.edu



Fri, 18 Dec 1998 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. <<<<<YOU MUST CHECK THIS OUT >>>>>>>>>> 2103

2. <><><> FLOODFILL <><><>

3. ??? <<<<<<<<<<<<<<<<<<<< RGB 4 MMX >>>>>>>>>>>>>>>>>>>>>>>?

4. ??? <<<<<<<<<<<<<<<<<<<< RGB 4 MMX >>>>>>>>>>>>>>>>>>>>>>>?

5. >>>HELP, DECOMPILER<<<

6. <<<XXX Password>>>

7. <<<XXX Password>>>

8. <<<XXX Password>>>

9. >>>>>>>>>>>>>>>>>>>HEY!<<<<<<<<<<<<<<<<<<<<<<<

10. ------>>>>> REVERSING A STRING <<<<<-----

11. >>>>> ADA PROGRAMMERS NEEDED, GOOD PAY <<<<<

 

 
Powered by phpBB® Forum Software