Files
rasp/tests/test_bitwise.asm

81 lines
1.5 KiB
NASM
Raw Normal View History

.section data $0x0 {
flags: .u8 $0b1001
main:
; Test bit and
mov %status, $1
mov %r0, $0b1000
and %r0, (flags)u8
cmpeq %r0, $0b1000
jz end
; Test shift right
mov %status, $2
shr %r0, $2
cmpeq %r0, $0b0010
jz end
; Test bit and
mov %status, $3
and %r0, (flags)u8
cmpeq %r0, $0
jz end
; Test bit or
mov %status, $4
or %r0, (flags)u8
cmpeq %r0, (flags)u8
jz end
; Test bit or
mov %status, $5
or %r0, $0b10
cmpeq %r0, $0b1011
jz end
; Test shift left
mov %status, $6
shl %r0, $1
cmpeq %r0, $0b10110
jz end
; Test xor
mov %status, $7
xor %r0, %r0
cmpeq %r0, $0
jz end
; Test xor
mov %status, $8
mov %r0, $0b1000
xor %r0, (flags)u8
cmpeq %r0, $1
jz end
; Test inv
mov %status, $9
; TODO : destination size - the line below inverts all 64 bits instead of the source 8 bits
; inv %r0, (flags)u8
inv (flags)u8, (flags)u8
cmpeq (flags)u8, $0b11110110
jz end
; Test inv again (reset flags to their previous value)
mov %status, $10
inv (flags)u8, (flags)u8
cmpeq (flags)u8, $0b00001001
jz end
mov %status, $0
end:
halt
.export main
}
.meta {
ip: main
}