Sieh dir mal die Befehle BITS und NBITS in der BASCOM-Hilfe an.
Für mega16 z.B.
Code:
Gicr = Gicr And Nbits(int1) -> Löscht Bit7 im Register GICR
Bascom macht daraus:
IN R16,0x3B In from I/O location
PUSH R16 Push register on stack
LDI R24,0x7F Load immediate
MOV R20,R24 Copy register
POP R16 Pop register from stack
AND R16,R20 Logical AND
OUT 0x3B,R16 Out to I/O location
Code:
Gicr = Gicr Or Bits(int1) -> Setzt Bit7 in Register GICR
Bascom macht daraus:
IN R16,0x3B In from I/O location
PUSH R16 Push register on stack
LDI R24,0x80 Load immediate
MOV R20,R24 Copy register
POP R16 Pop register from stack
OR R16,R20 Logical OR
OUT 0x3B,R16 Out to I/O location
Edit: Du kannst natürlich mehrere Bits auf einmal Setzen bzw. Löschen - sonst wärs ja witzlos. Also z.B.
GICR= GICR OR BITS(Int1, Int2, Int0)
Lesezeichen