Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4330002
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:54:05+00:00 2026-05-21T09:54:05+00:00

Yesterday I posted a question about my Recursive Fibonacci program in Assembly. I’m now

  • 0

Yesterday I posted a question about my Recursive Fibonacci program in Assembly. I’m now getting the proper output, thanks to some help from the wonderful folks here, however immediately after the correct output is printed, my program crashes.

Here is the Sequence program that calls the Fibonacci program a given number of times (stored in L)

.386
.model Flat
public Sequence
extrn Fibonacci:proc
include iosmacros.inc
.code
Sequence proc
    MOV L, EAX
    XOR ECX, ECX ;start count at 0
    sequ:
    CMP ECX, L
        JA endseq ;if we have passed the given value (L), end
        putstr MsgOut1
        putint ECX ;number passed to Fibonacci
        putstr MsgOut2
        MOV count, ECX ;preserve count
        PUSH ECX
        CALL Fibonacci ;call Fibonacci
        putint ECX
        putch ' '
        MOV ECX, count ;restore count
        INC ECX ;increment the count
        JMP sequ ;again
    endseq:
        putint ecx
    ret
Sequence endp

.data
    MsgOut1 DB "Fib(", 0, 0 ;first half of output message
    MsgOut2 DB ") = ", 0, 0 ;second half of output message
    L DD, 0, 0 ;number of sequences to carry out
    count DD 0,0 ;for counting
end

And here is the code that calls the Sequence procedure:

.386
.model flat
extrn Sequence:proc
include Cs266.inc
.data
    Msg DB "Please input the number of sequences you would like carried out", 0Ah, 0 ;input request message
    err DB "reached end"

.code
include Rint.inc
    main:
        putstr Msg
        CALL Rint ;store int in EAX
        CALL Sequence
                putstr err
    ret

end

The Fibonacci code is as follows:

.386
.model Flat
public Fibonacci
include iosmacros.inc ;includes macros for outputting to the screen

.code
Fibonacci proc

    MOV ECX, [ESP+4]
    CMP ECX, 1
        JA Recurse
        MOV ECX, 1 ;return value in ECX
        JMP exit

Recurse:
    PUSH EBX ;preserve value of EBX
    DEC ECX
    PUSH ECX
    CALL Fibonacci
    MOV EBX, ECX ;EBX is preserved, so safe to use
    DEC [ESP] ;decrement the value already on the stack
    CALL Fibonacci
    ADD ECX, EBX ;return value in ECX
    ADD ESP, 4 ;remove value from stack
    POP EBX ;restore old value of EBX
exit:
ret
Fibonacci endp

.data
end

I’ve posted a bunch of code here, but it is just for your convenience in pointing me in the right direction. I BELIEVE the problem might be in Sequence, and my debugger does not help me.

EDIT: All I get in terms of an error is this:
https://i.stack.imgur.com/cqhcL.jpg
And if I do enable Visual Studio Just-In-Time debugging, it never helps.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T09:54:06+00:00Added an answer on May 21, 2026 at 9:54 am

    Hmm…in your Fibonacci, I see two pushes and only one pop. At least at first glance, that seems like a little bit of a problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

yesterday, I posted a question about Hom to change a DIV id with a
(hello dr.Nick) :) So I posted a question yesterday about a content loader plugin
Following on from a question I posted yesterday about GUIs, I have another problem
In another question I posted yesterday, I got very good advice on how a
I posted this question yesterday evening, which has led me to discover a huge
Yesterday I posted this question regarding using lambdas inside of a Join() method to
I've posted a question yesterday but I just realized that the answer doesn't seem
Yesterday, I posted an answer to a question that included several (unknown to me
this is a rephrasing of a question I posted yesterday. I got an answer
This is a followup to a question I posted yesterday. I thought everything was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.