Bitwise operations: Difference between revisions

m (→‎{{header|6502 Assembly}}: fixed typos from copy-pasting)
Line 6,234:
XOR = 00000101
NOT 6 = 11111001</pre>
 
=={{header|Z80 Assembly}}==
;AND
<lang z80>LD A,&05
AND &1F ;0x05 & 0x1F</lang>
 
;OR
<lang z80>LD A,&05
OR &1F ;0x05 | 0x1F</lang>
 
;XOR
<lang z80>LD A,&05
XOR &1F ;0x05 ^ 0x1F</lang>
 
;NOT
<lang z80>LD A,&05
CPL</lang>
 
;Left Shift (Z80 can only shift by one at a time.)
<lang z80>LD A,&05
SLA A</lang>
 
;Right Shift
<lang z80>LD A,&05
SRL A</lang>
 
;Arithmetic Right Shift
<lang z80>LD A,&05
SRA A</lang>
 
Z80 has two different types of bit rotates.
* <code>RL/RR</code> rotates through the carry. The state of the carry before the rotate gets rotated in, and the bit that rotates out is put into the carry.
* <code>RLC/RRC</code> copies the bit "pushed out" to the carry but the old carry isn't rotated in.
 
<lang z80>LD A,&05
RLA
 
LD A,&05
RRA
 
LD A,&05
RLCA
 
LD A,&05
RRCA</lang>
 
 
 
=={{header|zkl}}==
1,489

edits