EASy68K  
It is currently Thu Apr 09, 2020 7:59 am

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 
Offline

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:

Code:
*-----------------------------------------------------------
* 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
DSPLY:  LEA s, A1
        MOVE.B #14, D0
        TRAP #15
   

STAMPA: MOVE.L (A7)+, A0
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
RET:    RTS


END:    SIMHALT             ; halt simulator

* Put variables and constants here

    END    START        ; last line of source



I get the following error:

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


What is going wrong?

Thanks in advance,
--
Snoopy


Top
 Profile  
 
PostPosted: Sat Jan 18, 2014 1:35 am 
Offline

Joined: Tue Nov 15, 2005 7:58 am
Posts: 129
Location: Oregon, USA
Well, the first thing I notice is this:
Quote:
Code:
        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:
Code:
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:
Code:
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:
Code:
   ORG   $1000
START:
   NOT  Doors+1 *** Addressing error on this instruction ***
   SIMHALT      ; halt simulator

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

   END   START

Error is:
Quote:
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.


Top
 Profile  
 
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: No registered users and 4 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:  
cron
Powered by phpBB® Forum Software © phpBB Group