Sponsored Content
Homework and Emergencies Homework & Coursework Questions program to find and print a Fibonacci sequence of numbers. --Errors Post 302715097 by kenjiro310 on Saturday 13th of October 2012 09:20:32 PM
Old 10-13-2012
update

Code:
.file   "fu1.c"
        .global .rem
        .section        ".rodata"
        .align 8
.LLC0:
        .asciz  "\nThis program prints the Fibonacci sequence"
        .align 8
.LLC1:
        .asciz  "\nEnter a limit on the largest number to be displayed: "
        .align 8
.LLC2:
        .asciz  "%d"
        .align 8
.LLC3:
        .asciz  "\n%d "
        .align 8
.LLC4:
        .asciz  "%d "
        .align 8
.LLC5:
        .asciz  "\nThe last number %d is disvisible by %d.\n"
        .align 8
.LLC6:
        .asciz  "\nDo you want to print a different sequence (y/n):"
        .align 8
.LLC7:
        .asciz  " %c"
        .align 8
.LLC8:
        .asciz  "pause"
        .section        ".text"
        .align 4
        .global main
        .type   main, #function
        .proc   04
main:
        !#PROLOGUE# 0
        save    %sp, -152, %sp
        !#PROLOGUE# 1
.LL2:
        mov     1, %g1
        st      %g1, [%fp-32]
        mov     1, %g1
        st      %g1, [%fp-36]
        sethi   %hi(.LLC0), %g1
        or      %g1, %lo(.LLC0), %o0
        call    printf, 0
         nop
        sethi   %hi(.LLC1), %g1
        or      %g1, %lo(.LLC1), %o0
        call    printf, 0
         nop
        add     %fp, -20, %o5
        sethi   %hi(.LLC2), %g1
        or      %g1, %lo(.LLC2), %o0
        mov     %o5, %o1
        call    scanf, 0
         nop
        sethi   %hi(.LLC3), %g1
        or      %g1, %lo(.LLC3), %o0
        ld      [%fp-32], %o1
        call    printf, 0
         nop
.LL5:
        sethi   %hi(.LLC4), %g1
        or      %g1, %lo(.LLC4), %o0
        ld      [%fp-36], %o1
        call    printf, 0
         nop
        ld      [%fp-32], %o5
        ld      [%fp-36], %g1
        add     %o5, %g1, %g1
        st      %g1, [%fp-24]
        ld      [%fp-36], %g1
        st      %g1, [%fp-32]
        ld      [%fp-24], %g1
        st      %g1, [%fp-36]
        ld      [%fp-24], %o5
        ld      [%fp-20], %g1
        cmp     %o5, %g1
        bg      .LL6
        nop
        b       .LL5
         nop
.LL6:
        st      %g0, [%fp-44]
        ld      [%fp-32], %g1
        st      %g1, [%fp-48]
        mov     2, %g1
        st      %g1, [%fp-52]
        mov     1, %g1
        st      %g1, [%fp-40]
.LL8:
        ld      [%fp-48], %g1
        mov     %g1, %o0
        ld      [%fp-40], %o1
        call    .rem, 0
         nop
        mov     %o0, %g1
        cmp     %g1, 0
        bne     .LL9
        nop
        ld      [%fp-40], %o5
        ld      [%fp-48], %g1
        cmp     %o5, %g1
        bg      .LL9
        nop
        ld      [%fp-40], %g1
        st      %g1, [%fp-44]
        ld      [%fp-40], %g1
        add     %g1, %g1, %g1
        st      %g1, [%fp-40]
        b       .LL8
         nop
.LL9:
        sethi   %hi(.LLC5), %g1
        or      %g1, %lo(.LLC5), %o0
        ld      [%fp-48], %o1
        ld      [%fp-44], %o2
        call    printf, 0
         nop
        sethi   %hi(.LLC6), %g1
        or      %g1, %lo(.LLC6), %o0
        call    printf, 0
         nop
        add     %fp, -25, %o5
        sethi   %hi(.LLC7), %g1
        or      %g1, %lo(.LLC7), %o0
        mov     %o5, %o1
        call    scanf, 0
         nop
        ldub    [%fp-25], %g1
        sll     %g1, 24, %g1
        sra     %g1, 24, %g1
        cmp     %g1, 110
        be      .LL3
        nop
        b       .LL2
         nop
.LL3:
        sethi   %hi(.LLC8), %g1
        or      %g1, %lo(.LLC8), %o0
        call    system, 0
         nop
        mov     0, %g1
        mov     %g1, %i0
        ret
        restore
        .size   main, .-main

Moderator's Comments:
Mod Comment Please use code tags

Thanks for the heads up. I am now trying to declare my variables in the assembly file so i wont need the *.c file and clues as to how i would do that. I tried using frame pointers to my own variables with no luck

Last edited by jim mcnamara; 10-13-2012 at 11:17 PM..
 

10 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

program to find the uncommon numbers between two files.

Hi, I need to extract the uncommon numbers from file1 and file2 For Example: File1 1 2 3 4 5 File2 1 2 3 4 5 6 (2 Replies)
Discussion started by: salaathi
2 Replies

2. Shell Programming and Scripting

Unix help to find blank lines in a file and print numbers on that line

Hi, I would like to know how to solve one of my problems using expert unix commands. I have a file with occasional blank lines; for example; dertu frthu fghtu frtty frtgy frgtui frgtu ghrye frhutp frjuf I need to edit the file so that the file looks like this; (10 Replies)
Discussion started by: Lucky Ali
10 Replies

3. Shell Programming and Scripting

Shell script to find the sum of first n Fibonacci numbers

pls give me the solution for this i need it for my exam pls pls pls Shell script to find the sum of first n Fibonacci numbers (1 Reply)
Discussion started by: Kshitija
1 Replies

4. Homework & Coursework Questions

Help with shell script to find sum of first n numbers of Fibonacci series

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Shell script to find sum of first n numbers of Fibonacci series 2. Relevant commands, code, scripts,... (0 Replies)
Discussion started by: Kshitija
0 Replies

5. UNIX for Dummies Questions & Answers

Why does fibonacci sequence script stop making sense at 92nd iteration?

So, Just for practice, I wrote a simple fibonacci sequence script in bash. (03:08:02\$ cat fib #!/usr/bin/bash ret () { echo -ne "\n" sleep .5 } a=1 b=2 echo -n $a #1 A ret echo -n $b #2 B ret (8 Replies)
Discussion started by: DeCoTwc
8 Replies

6. Shell Programming and Scripting

Need to find the gap in the sequence of numbers

Hi Guys, I have a file with numbers in sequence. The sequence have been broken somewhere.. I need to find out at which number the sequence has been broken... For an example, consider this sequence, it needs to give me output as 4 (as 5 is missing) and 6(as 7 is missing) Thanks for... (3 Replies)
Discussion started by: mac4rfree
3 Replies

7. Shell Programming and Scripting

How to find the matched numbers between 2 text file using perl program??

hi dudes, I nee you kind assistance, I have to find the matched numbers from 2 text files and output of matched numbers should be in another text file.. I do have text files like this , for example File 1 787 665*5-p 5454 545-p 445-p 5454*-p File 2 5455 787 445-p 4356 2445 144 ... (3 Replies)
Discussion started by: sureshraj
3 Replies

8. Shell Programming and Scripting

find common entries and match the number with long sequence and cut that sequence in output

Hi all, I have a file like this ID 3BP5L_HUMAN Reviewed; 393 AA. AC Q7L8J4; Q96FI5; Q9BQH8; Q9C0E3; DT 05-FEB-2008, integrated into UniProtKB/Swiss-Prot. DT 05-JUL-2004, sequence version 1. DT 05-SEP-2012, entry version 71. FT COILED 59 140 ... (1 Reply)
Discussion started by: manigrover
1 Replies

9. Shell Programming and Scripting

Find common numbers and print yes or no

Hi I have 2 files with following data First file, sp|Q676U5|A16L1_HUMAN, Autophagy-related protein 16-1 OS=Homo sapiens GN=ATG16L1 PE=1 SV=2, Maximum coiled-coil residue probability: 0.657 in position 163. Maximum dimeric residue probability: 0.288 in position 163. ... (1 Reply)
Discussion started by: manigrover
1 Replies

10. Programming

Program wont print prime numbers

The problem I'm having is that when you put in the two numbers the answer is just prime.... nothing. I cannot figure this out ive been working on this forever, can someone please god just tell me how to fix this without encrypted "hints". #include <iostream> #include <cmath> using... (3 Replies)
Discussion started by: c++newb
3 Replies
All times are GMT -4. The time now is 05:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy