It is currently Fri Jun 05, 2020 5:03 pm

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Cannot do BSR properly
PostPosted: Thu Jan 16, 2014 7:08 pm 

Joined: Thu Jan 16, 2014 6:43 pm
Posts: 1
Hey guys, really sorry for bothering, but I just can't get this code to run properly:

* Title      : Convert a string from lowercase to uppercase
* Written by :
* Date       : JAN 3, 2014
* Description:

        ORG    $1000

s:      DC.B    'Today is an awesome day',0

        ORG    $2000
        MOVE.L #$8000, A7  ; STACK SETUP
START:                  ; first instruction of program
        PEA s
        BSR STAMPA
        MOVE.B #14, D0
        TRAP #15

BGIN:   MOVE.B (A0), D0
        BEQ RET
        CMP #'a', D0
        BLT NEXT
        CMP #'z', D0
        BGT NEXT
        SUB #32, D0
        MOVE.B D0, (A0)
NEXT:   ADD #1, A0
        BRA BGIN

END:    SIMHALT             ; halt simulator

* Put variables and constants here

    END    START        ; last line of source

I get the following error:

PC=0000200A Code=6100 BSR
Address Error: Instruction at 106d accessing address 106d

What is going wrong?

Thanks in advance,

PostPosted: Sat Jan 18, 2014 1:35 am 

Joined: Tue Nov 15, 2005 7:58 am
Posts: 129
Location: Oregon, USA
Well, the first thing I notice is this:
        ORG    $2000
        MOVE.L #$8000, A7  ; STACK SETUP
START:                  ; first instruction of program

This MOVE.L instruction will never be executed, because you're declaring the first instruction to be after it. Therefore the stack won't be where you expect. In this case, it doesn't matter. On real hardware, it would.

The second thing I notice is the lack of comments telling what you intend your code to be doing. Example:
STAMPA: MOVE.L (A7)+, A0   Pop passed address of string

Next, when your error message refers to a specific address, I'd be nice to be able to see what's at that address, perhaps by including part of the list file:
0000200A  6100 000C                 18          BSR STAMPA

Moving on, I think the error message may be misleading you. The fatal error you get is a consequence of the way you're using the stack. Open the stack window, step through the program and observe the stack upon entering STAMPA, and what A0 is after the first instruction of STAMPA.

As far as this specific error message, I get the same error on this code fragment:
   ORG   $1000
   NOT  Doors+1 *** Addressing error on this instruction ***
   SIMHALT      ; halt simulator

Doors   DCB.B   100,0   ;Reserve 100 bytes, prefilled with zeros


Error is:
Address Error: Instruction at 1000 accessing address 100b

Here the problem seems to be accessing memory declared as bytes as a word; using NOT.B works. This is not the same as your error, but it's related. You're using (accessing) memory in an unexpected fashion.

I have not checked for any other errors.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: Google Adsense [Bot] and 9 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group