LDS# $E00 .EQU PUT_NUM, $E00 .EQU GET_NUM, $E01 JSR GET_NUM STA N N: .BLKW 1 LDA N CMA# 1 JEQ end1 LDA N CMA# 2 JEQ end1 LDA# 1 STA fibprev fibprev: .BLKW 1 LDA# 1 STA fib fib: .BLKW 1 LDA# 2 STA cur cur: .BLKW 1 JMP LOOP LOOP: LDA fib STA temp temp: .BLKW 1 LDA fibprev ADA fib STA fib LDA temp STA fibprev INC cur LDA cur CMA N JLT LOOP JGE END END: LDA fib JSR PUT_NUM HLT end1: LDA# 1 JSR PUT_NUM HLT

## 3 Replies - 1213 Views - Last Post: 25 January 2010 - 08:04 AM

### #1

# Non-existant memory location...

Posted 24 January 2010 - 03:10 AM

Hi All. I'm working on a code in assembly (ChASM) that is supposed to calculate the Fibonacci value of a given number. I've pretty much completed my code, and it successfully computes the Fib. value of 23, but when I try to have it compute the Fib. value of 24, it says "Execution terminated: Indirection Fault trying to access non-existant memory location $61DD4A." I simply can't figure it out, any help would be appreciated. Thanks.

##
**Replies To:** Non-existant memory location...

### #2

## Re: Non-existant memory location...

Posted 24 January 2010 - 01:49 PM

As a rough guess, I suspect that as the Fibonacci value for 23 is 28657 which can be easily accomodated as a positive 16 bit signed value and the Fibonacci value for 24 is 46368 which would be considered a negative value may have something to do with the problem.

Hope this helps

Hope this helps

### #3

## Re: Non-existant memory location...

Posted 24 January 2010 - 03:36 PM

Thanks for the reply. That would make sense. Another possibility is something about overflow - the assembler may be indicating to me that an overflow occured with a signed operation. Unfortunately, either way, I have no idea what to change. Any ideas?

### #4

## Re: Non-existant memory location...

Posted 25 January 2010 - 08:04 AM

You need to increase the width of the input, output and summation fields to 32-bit from 16-bit. This will give a much better range of Fibonacci values. However, remember once you have reached 31 bits for the result, you will end up with the same problem as you have now.

Page 1 of 1