Files
rasp/tests/test_bitwise.asm
Alek Ratzloff 551bd2c3f4 Add initial register states to meta section; remove entry directive
It makes sense to allow users to set the initial register values. This
allows someone to e.g. enable interrupts once the VM has started, or set
the initial stack pointer value.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-03-10 12:18:31 -04:00

81 lines
1.5 KiB
NASM

.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
}