EASy68K  
It is currently Thu Sep 19, 2019 5:11 am

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Sat Apr 23, 2011 5:35 pm 
Offline

Joined: Thu Apr 21, 2011 4:26 pm
Posts: 9
Location: BRIGHTON
.A

_________________
ANIKET
BRIGHTON,UK


Last edited by lokmanwar on Sun Apr 24, 2011 4:13 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 23, 2011 5:59 pm 
Offline

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
Between outputting the numbers you need to output something, such as a newline or space, to separate them.

Also, the code to stop the simulator should be at the end of the program, not at the end of the page.

Lee.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 23, 2011 6:13 pm 
Offline

Joined: Thu Apr 21, 2011 4:26 pm
Posts: 9
Location: BRIGHTON
lee wrote:
Between outputting the numbers you need to output something, such as a newline or space, to separate them.

Also, the code to stop the simulator should be at the end of the program, not at the end of the page.

Lee.


M TRYING TO PUT A NEW LINE BUT "CR,LF" DONT WORK IN MIDDLE OF THE PROGRAMME

_________________
ANIKET
BRIGHTON,UK


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 23, 2011 7:56 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
Code:
CR      EQU     $0D             *ASCII code for carriage return

LF      EQU     $0A             *ASCII code for line feed


        ORG     $1000           *The program will load into address $1000

START:

*INPUT SIX NUMBERS FROM KEYBOARD

        LEA     MESSAGE1,A1     *Loads message into address register A1
        MOVE.B  #14,D0          *Moves number 14 into data regiter D0
        TRAP    #15             *Displays Message

        BSR     get_num         *Branch to subroutine to get Number1

        MOVE.W  D1,-(SP)        *Push d1 on SP

        BSR     get_num         *Branch to subroutine to get Number2

        MOVE.W  D1,-(SP)        *Push d1 on stack

        BSR     get_num         *Branch to subroutine to get Number3

        MOVE.W  D1,-(SP)        *Push d1 on SP

        BSR     get_num         *Branch to subroutine to get Number4

        MOVE.W  D1,-(SP)        *Push d1 on stack

        BSR     get_num         *Branch to subroutine to get Number5

        MOVE.W  D1,-(SP)        *Push d1 on SP

        BSR     get_num         *Branch to subroutine to get Number6

        MOVE.W  D1,-(SP)        *Push d1 on stack

*DISPLAY REVERSED ORDER OF THE SIX NUMBERS

        LEA     MESSAGE2,A1     *Loads message into address register A1
        MOVE.B  #14,D0          *Moves number 14 into data regiter D0
        TRAP    #15             *Displays Message

        MOVE.W  (SP)+,D1        *Recover value from stack

        BSR     put_num         *Display the Number6

        MOVE.W  (SP)+,D1        *Recover value from stack

        BSR     put_num         *Display the Number5

        MOVE.W  (SP)+,D1        *Recover value from stack

        BSR     put_num         *Display the Number4

        MOVE.W  (SP)+,D1        *Recover value from stack

        BSR     put_num         *Display the Number3

        MOVE.W  (SP)+,D1        *Recover value from stack

        BSR     put_num         *Display the Number2

        MOVE.W  (SP)+,D1        *Recover value from stack

        BSR     put_num         *Display the Number1

        MOVE.B  #9,D0
        TRAP    #15             ; halt simulator

*--------------------------------------------------------------------

*Subroutine to get number from the keyboard

get_num MOVE.B  #4,D0           *Select number input
        TRAP    #15             *Move number to D1
        RTS                     *Return from subroutine to programme

*--------------------------------------------------------------------

*Subroutine to output number to screen, and CR,LF

put_num MOVE.B  #3,D0           *Select number output
        TRAP    #15

*--------------------------------------------------------------------

crlf    LEA     MSG_CRLF,A1     *Loads message into address register A1
        MOVE.B  #14,D0          *Moves number 14 into data regiter D0
        TRAP    #15             *Displays Message
        RTS

*--------------------------------------------------------------------

MESSAGE1 DC.B   'ENTER SIX NUMBERS:',CR,LF,0

MESSAGE2 DC.B   'REVERSE ORDER IS:'

MSG_CRLF DC.B   CR,LF, 0

*---------------------------------------------------------------------

        END    START      ; last line of source


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 23, 2011 8:01 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1102
Notice in Clive's example the put_num subroutine does NOT have an RTS at the end so it falls through into the crlf subroutine and runs that also.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 24, 2011 6:08 pm 
Offline

Joined: Thu Apr 21, 2011 4:26 pm
Posts: 9
Location: BRIGHTON
@.

_________________
ANIKET
BRIGHTON,UK


Last edited by lokmanwar on Mon Apr 25, 2011 11:20 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 24, 2011 8:12 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
lokmanwar wrote:
thank you clieve for solving my problems but can you please remove the codes from your post

If submitting my code as the answer to your assignment without citation is problematic, Caveat emptor.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 25, 2011 5:06 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
An alternate solution using looping.
Code:
CR      EQU     $0D             *ASCII code for carriage return

LF      EQU     $0A             *ASCII code for line feed

        ORG     $1000           *The program will load into address $1000

START:

*INPUT SIX NUMBERS FROM KEYBOARD

        LEA     MESSAGE1,A1     *Loads message into address register A1
        MOVE.B  #14,D0          *Moves number 14 into data regiter D0
        TRAP    #15             *Displays Message

        MOVE.W  #6-1,D4         *Get 6 numbers

get_loop
        BSR     get_num         *Branch to subroutine to get number

        MOVE.W  D1,-(SP)        *Push D1 on SP/stack

        DBRA    D4,get_loop     *Iterate

*DISPLAY REVERSED ORDER OF THE SIX NUMBERS

        LEA     MESSAGE2,A1     *Loads message into address register A1
        MOVE.B  #14,D0          *Moves number 14 into data regiter D0
        TRAP    #15             *Displays Message

        MOVE.W  #6-1,D4         *Put 6 numbers

put_loop
        MOVE.W  (SP)+,D1        *Recover value from SP/stack to D1

        BSR     put_num         *Display the Number

        DBRA    D4,put_loop     *Iterate

*DONE

        MOVE.B  #9,D0
        TRAP    #15             ; halt simulator

*--------------------------------------------------------------------

*Subroutine to get number from the keyboard

get_num MOVE.B  #4,D0           *Select number input
        TRAP    #15             *Move number to D1
        RTS                     *Return from subroutine to programme

*--------------------------------------------------------------------

*Subroutine to output number to screen, and CR,LF

put_num MOVE.B  #3,D0           *Select number output
        TRAP    #15

*--------------------------------------------------------------------

crlf    LEA     MSG_CRLF,A1     *Loads message into address register A1
        MOVE.B  #14,D0          *Moves number 14 into data regiter D0
        TRAP    #15             *Displays Message
        RTS

*--------------------------------------------------------------------

MESSAGE1 DC.B   'ENTER SIX NUMBERS:',CR,LF,0

MESSAGE2 DC.B   'REVERSE ORDER IS:'

MSG_CRLF DC.B   CR,LF, 0

*---------------------------------------------------------------------

        END    START      ; last line of source

BEng (Hons), Electrical and Electronic Engineering, University of Portsmouth (Portsmouth Polytechnic), UK


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] 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:  
Powered by phpBB® Forum Software © phpBB Group