EASy68K  
It is currently Thu Dec 05, 2019 6:07 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: JSR problem
PostPosted: Mon Dec 02, 2019 8:14 am 
Offline

Joined: Mon Dec 02, 2019 8:04 am
Posts: 1
Hello guys, i'm learning assembly, but i i don't understand some things.
I write a program with subroutine and i call it by jsr name of subroutinne.
When i debug program, the debugger stop on this istruction, or don't jump
on subrouting, but it continues on mai program.
My Examples are:
Code:
*-----------------------------------------------------------
    ORG    $1000
N1  EQU 0
N2  EQU 4
N3  EQU 8
RIS EQU 12
SOMMA
    MOVE.L SOMMA(A0),D0
    ADD.L  N1(A0),D0
    ADD.L  N2(A0),D0
    ADD.L  N3(A0),D0
    MOVE.L D0,RIS(A0)
    RTS
START:                  ; first instruction of program
    LEA.L PARAM,A0
    MOVE.L A,N1(A0)
    MOVE.L B,N2(A0)
    MOVE.L C,N3(A0)
    JSR SOMMA
    MOVE.L RIS(A0),D1
    STOP #$8000
    ORG $8500
A   DC.L    1
B   DC.L    2
C   DC.L    7
PARAM   DS.L    4
    END    START        ; last line of source

or another more complex

Code:
*-----------------------------------------------------------
* Title      : Scrivere un programma che calcoli la media di
*            : un array di N elementi facendo uso dello stack
* Written by : Giuseppe Sportelli
* Date       :  1/12/2019
* Description: Calcola la media di un array di N valori
*-----------------------------------------------------------
    ORG     $8800   
N   DC.L     10
VET    DC.L     3,2,5,1,20,21,32,1,0,1
S      DS.L     1
M      DS.L     1
    ORG $8100
START:                 ; first instruction of program
    MOVE.L #VET,A0
    MOVE.L N,D1
    MOVE.L S,D2
    MOVE.L M,D3
    MOVE.L D1,-(SP)
    MOVE.L A0,-(SP)
    SUBQ.L #8,SP
    JSR     MEDIA     
    MOVE.L MED(SP),D2
    MOVE.L SUM(SP),D1
    MOVE.L D2,M
    MOVE.L D1,S
    STOP #$3000
    ORG $8400
SIZE   EQU      0
MED    EQU      4
SUM    EQU      8
ARRAY  EQU      12
MEDIA
    MOVEM.L D0-D2/A0,-(SP)
    SUBQ.L   #8,SP
    MOVE.L  ARRAY(SP),A0
    MOVE.L  SIZE(SP),D1
    SUBQ.L  #1,D1
CICLO:
    MOVE.L  (A0)+,D3
    ADD.L   D3,SUM(SP)
    DBRA    D1, CICLO
    MOVE.L  SUM(SP),D4
    DIVU    SIZE(SP),D4
    MOVE.L  D4,MED(SP)
    ADDQ.L  #8,SP
    MOVEM.L (SP)+,D0-D2/A0
    RTS
    END START

I'm sure that somethings are wrong.
Can i help me ?
Thank you


Top
 Profile  
 
 Post subject: Re: JSR problem
PostPosted: Tue Dec 03, 2019 11:39 am 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1107
Put an END START line at the end of your code where START is a label at the first instruction of the program. EASy68K will load the start address into the program counter in the simulator.


Code:
*-----------------------------------------------------------
    ORG    $1000
N1  EQU 0
N2  EQU 4
N3  EQU 8
RIS EQU 12
SOMMA
    MOVE.L SOMMA(A0),D0
    ADD.L  N1(A0),D0
    ADD.L  N2(A0),D0
    ADD.L  N3(A0),D0
    MOVE.L D0,RIS(A0)
    RTS
START:                  ; first instruction of program
    LEA.L PARAM,A0
    MOVE.L A,N1(A0)
    MOVE.L B,N2(A0)
    MOVE.L C,N3(A0)
    JSR SOMMA
    MOVE.L RIS(A0),D1
    STOP #$8000
    ORG $8500
A   DC.L    1
B   DC.L    2
C   DC.L    7
PARAM   DS.L    4
    END     START

_________________
Prof. Kelly


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 3 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