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>
This commit is contained in:
52
tests/test_interrupts.asm
Normal file
52
tests/test_interrupts.asm
Normal file
@@ -0,0 +1,52 @@
|
||||
.section code $0x0 {
|
||||
main:
|
||||
; Test divide by zero interrupts
|
||||
|
||||
; div
|
||||
mov %status, $1
|
||||
mov %r0, $1
|
||||
div %r0, $0
|
||||
cmpeq (count), $1
|
||||
jz end
|
||||
|
||||
; idiv
|
||||
mov %status, $2
|
||||
idiv %r0, $0
|
||||
cmpeq (count), $2
|
||||
jz end
|
||||
|
||||
mov %status, $0
|
||||
end:
|
||||
halt
|
||||
|
||||
.align u64
|
||||
divide_by_zero:
|
||||
add (count), $1
|
||||
iret
|
||||
|
||||
.export main
|
||||
.export divide_by_zero
|
||||
}
|
||||
|
||||
.section ivt $0x1000 {
|
||||
ivt:
|
||||
.interrupt $1, divide_by_zero
|
||||
.export ivt
|
||||
}
|
||||
|
||||
.section shared $0x2000 {
|
||||
count: .u64 $0
|
||||
.export count
|
||||
}
|
||||
|
||||
.section stack $0x4000 .. $0x5000 {
|
||||
stack_base:
|
||||
.export stack_base
|
||||
}
|
||||
|
||||
.meta {
|
||||
ip: main
|
||||
flags: $0b100
|
||||
sp: stack_base
|
||||
ivt: ivt
|
||||
}
|
||||
Reference in New Issue
Block a user