HOW TO IMPLEMENT ''OR'' WITH ST6© by Vittorio Crapella - i2viu

#### Therefore OR of A and B (where A and B can be registers or variables) will be:

```
or  com    a    ;"a"register complement(the same as NOT on all bits of the byte)
ld     x,a  ;save "a" reg. in "x" reg.
ld     a,b	;put in  "a" the value of B
com    a    ;complements  "a"
and    a,x  ;executes AND of
com    a	;in "a" there is the OR  of   A and B
```

## SET/RESET THE BIT No. OF A BYTE

#### Where Nr. is a register or a variable. The ST6 instruction SET supports the SET and RESET of No. bit, of the "a register" or "a variable" but only in the immediate mode, that is N has to be on EQU value or a value given in the software as a digit comprised between 0 and 7.

``` Exemple:  SET  2,variable   ;bit 2 of the variable is = 1
RES  0,variabile  ;bit 0 of the variable is = 0
```

## SET:

#### The a register gives the number of the bit to be set, while the b variable indicates the byte in which the bit has to be set.

```
Set_  ld   x,a	 ;in "x" the number of the bit to be set
ldi  a,255 ;a = 11111111b
com  a	 ;carry = 1 and  a = 0
rcla  rcl  a	 ;move carry in the bit 0 and b7 in to carry
dec  x	 ;count number of times
jrnz rcla	 ;with No. bit=5 you will have a = 00010000b
or    com  a	 ;a = 11101111b
ld   x,a	 ;save "a" in "x"
ld   a,b	 ;a = byte b where the bit 5 is to be set (ex: b=10001101b)
com  a	 ;complement a = 01110010b
and  a,x	 ;a = 01100010b
com  a	 ;a = 10011101b
ld   b,a	 ;in the byte "b" after the operation you will have b=10011101

```

## RESET:

#### The "a" register gives the number of the bit to be reset, while the "b" variable indicates the byte in which the bit has to be reset.

```
Res_  ld   x,a	 ;in "x" the number of the bit to be reset
clr  a	 ;carry = 0 and a=0
ldi  a,255 ;a=11111111b
rcla  rcl  a	 ;move carry in the bit 0 and  b7 in to carry
dec  x	 ;cont namber of times
jrnz rcla	 ;with No. bit= 4 is a= 11110111b
ld   x,a	 ;save "a" in "x"
ld   a,b	 ;a = byte "b" where the bit 4 is to be reset (ex: b=10001101b)
and  a,x	 ;a = 10000101b
ld   b,a	 ;in the byte "b" after the operation you will have b= 10000101b

```