Add bitwise tests, squash all arithmetic tests into test_arithmetic
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
80
tests/test_bitwise.asm
Normal file
80
tests/test_bitwise.asm
Normal file
@@ -0,0 +1,80 @@
|
||||
.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 {
|
||||
entry: main
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user