EASy68K  
It is currently Sun Apr 23, 2017 5:34 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Formating Output
PostPosted: Fri Feb 12, 2016 3:08 pm 
Offline

Joined: Fri Feb 12, 2016 3:03 pm
Posts: 2
Hello everyone, I have a small question from which I can not find the answer to.

I'm looking to format the output of my program for my class. When I print the data registers, it pushes everything together like:
21-24000
But, I would like them to have a space between or even on another line. Like this:
21 -24000
I'm using "trap #15" currently to display the answers I am calculating. Thanks!


Top
 Profile  
 
 Post subject: Re: Formating Output
PostPosted: Sat Feb 13, 2016 1:28 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1036
Location: Monroe County Community College, Monroe Michigan, U.S.A.
This demo I did in my lecture might help.
Code:
*-----------------------------------------------------------
* Title      : Demo_2_8_2016
* Written by : Charles Kelly
* Date       : Feb. 8th, 2016
* Description: Demo from lecture. Prompt for two numbers,
*              get user input, multiply them and display
*              the product.
*-----------------------------------------------------------
    ORG    $1000
START:                  ; first instruction of program

* int num1, num2
* cout << "Enter num1: ";
    MOVE.B  #14,D0
    LEA     Prompt1,A1
    TRAP    #15
* cin >> num1;
    MOVE.B  #4,D0       ; Read number into D1
    TRAP    #15
    MOVE.L  D1,num1
* cout << "Enter num2: ";
    MOVE.B  #14,D0
    LEA     Prompt2,A1
    TRAP    #15
* cin >> num2;
    MOVE.B  #4,D0       ; Read number into D1
    TRAP    #15
    MOVE.L  D1,num2
* num3 = num1 * num2
    MULS    num1+2,D1
    MOVE.L  D1,D7       ; save D1 to D7
* cout << "n1 * n2 = "
    MOVE.L  num1,D1     ; display num1
    MOVE.B  #3,D0
    TRAP    #15
    MOVE.B  #14,D0      ; display ' * '
    LEA     Mult,A1
    TRAP    #15
    MOVE.L  num2,D1     ; display num2
    MOVE.B  #3,D0
    TRAP    #15
    MOVE.B  #14,D0      ; display ' = '
    LEA     Equal,A1
    TRAP    #15
* cout << product
    MOVE.L  D7,D1       ; restore product to D1
    MOVE.B  #3,D0
    TRAP    #15
   
    SIMHALT             ; halt simulator

* Put variables and constants here
num1    DS.L    1
num2    DS.L    1

Prompt1 DC.B    'Enter num1: ',0    ; NULL terminated string
Prompt2 DC.B    'Enter num2: ',0    ; NULL terminated string
Mult    DC.B    ' * ',0    ; NULL terminated string
Equal   DC.B    ' = ',0    ; NULL terminated string
    END    START        ; last line of source

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject: Re: Formating Output
PostPosted: Sat Feb 13, 2016 11:03 pm 
Offline

Joined: Fri Feb 12, 2016 3:03 pm
Posts: 2
Awesome! Thank you so much! That helped me out! :mrgreen:


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot], MSNbot Media and 2 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