I started learning SPARC, and wrote some simple instructions.
fmt2: .asciz " 100 - 15 = %dn"
fmt3: .asciz " 100 * 15 = %dn"
fmt4: .asciz " 100 / 15 = %dn"
.align 4
.global main
main: save %sp, -96, %sp
mov 100, %l4 !l4=0
mov 15, %l5 !l4=100, l5=0
!printf(" 100 - 15 = %dn, minus);
set fmt2, %o0
sub %l4, %l5, %o1
call printf
nop
mov %l4, %o0
mov %l5, %o1
call .mul
nop
mov %o0, %o1
set fmt3, %o0
call printf
nop
mov %l4, %o0
mov %l5, %o1
call .div
nop
mov %o0, %o1
set fmt4, %o0
call printf
nop
ret
restore
There was an example code on the lecture and I just copied it.
It spewed all the text out and ended with a code 01
, and so did the example code.
So I tried inspecting every %o0
and %o1
values with gdb compiler, but failed to understand how pipelining works.
mov %o0, %o1
and set fmt3, %o3
obviously creates a hazard but still works fine.
Is that the cause of the exit code 01
?
New contributor
aDeadBird is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1