EASy68K
http://easy68k.com/EASy68Kforum/

Formating Output
http://easy68k.com/EASy68Kforum/viewtopic.php?f=6&t=1534
Page 1 of 1

Author:  Brian89 [ Fri Feb 12, 2016 3:08 pm ]
Post subject:  Formating Output

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!

Author:  profkelly [ Sat Feb 13, 2016 1:28 pm ]
Post subject:  Re: Formating Output

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

Author:  Brian89 [ Sat Feb 13, 2016 11:03 pm ]
Post subject:  Re: Formating Output

Awesome! Thank you so much! That helped me out! :mrgreen:

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/