I'm attempting to revisit assembly after several years of not having used it at all, and I'm having a bit of trouble with simple I/O. My program is designed to read a number from the user and spit it right back out. The "%c" is simply to remove the newline character (enter) from the buffer. This seems simple enough, and I can get it to work with strings, but for some reason I get a "Bus Error" after I input a number.
My code is as follows:
.section ".data" informat: .asciz "%d%c" outformat: .asciz "The number was: %d\n" input: .word returnkey: .byte .section ".text" .global main .align 4 main: save %sp, -96, %sp set informat, %o0 set input, %o1 set returnkey, %o2 call scanf nop set outformat, %o0 set input, %o1 call printf nop ret restore
In case my description of the problem doesn't make sense, my terminal window looks like the following:
#> gcc test.s
This is on a Solaris 10 box. Any idea what I'm doing wrong?
Thanks in advance!