Hello, I'm having another problem with assembly. I'm writing a Fibonacci sequence in assembly and I think I got all my stuff set up, but after I try to convert from .m to .s using gm4, I'm getting this here:
NONE:0: gm4: ERROR: EOF in argument list
Can anyone tell me what I'm doing wrong here? Please let me know about this. Thanks.
Here is my code:
!Data section
.section ".data"
input: .word 0 !User input
yesNo: .byte 0 !Stores the characters of yes and no
nl: .asciz "\n" !Does a new line of input
intro: .asciz "\nThis program prints the Fibonacci sequence:"
enter: .asciz "\nEnter a limit on the largest number to be displayed:"
again: .asciz "\nDo you want to print a different sequence (Y/N):"
odd: .asciz "\nThe last number in this sequence is an odd number"
even: .asciz "\nThe last number in this sequence is an even number"
format: .asciz "%d %c" !Specify a decimal number and a character
format1: .asciz "%c %c" !Specify two characters
myString: .asciz "%d" !Displays the values of the sequence
!Variable
define(x_r,l0)
define(y_r,l1)
define(z_r,l2)
define(a_r,l3)
define((b_t,l5)
define(c_t,l6)
.align 4
.section ".text"
.global main
main:
save %sp, -96, %sp
mov 1, %x_r !x = 1
mov 0, %y_r !y = 0
do:
set enter, %o0 !Prompts the user for input
call printf
nop
set format, %o0 !Specify the input
set input, %o1 !Sets the location of the input
set nl, %o2
call scanf
nop
set input, %o1
ld[%o1], %b_t
while:
cmp %x_r, %b_t
bge false
nop
set myString, %o0
call printf
mov %x_r, %o1
mov %y_r, %a_r !temp(a) = y
mov %x_r, %y_r !y = x
add %y_r,%a_r,%x_r !x = y + a
ba while
nop
false:
sub %x_r, %a_r, %x_r !x = x - a
andcc %x_r, 0x01, %c_t !Tells if it is even or odd
bne done2
set even, %o0
call printf
nop
ba done
done2:
set odd,, %o0
call printf
nop
done:
mov 0,%y_r !y = 0
mov 1, %x_r ! x = 1
set again, %o0 !Repeats the Yes/No
call printf
nop
set format1, %o0 ! What kind of data it will get
set yesNo, %o1
set nl, %o2
call scanf
nop
set yesNo, %o1 !Gets the address of the Yes/No in the memory
ldub[%o1], %o0 !Gets the Yes/No response
cmp %o0, 'y'
be do
nop
cmp %o0, 'Y' !Does a "Yes"
be do
nop
mov 1, %g1
ta 0
ret
restore