It is currently Fri Jun 05, 2020 4:54 pm

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Oct 22, 2013 3:37 am 

Joined: Tue Oct 22, 2013 3:27 am
Posts: 1
I need to convert a user input date in the format MM/DD/YYYY and transform the month into words.

For example: User typed in: 1/1/2013.
Output needs to be: "You entered: January 1, 2013."

I cannot use loop or branching.

Please help me how to start this assignment, currently we only learned about basic instructions like move, add, lea, lineout, linein, cvta2, etc.

How can I point a month number from user into a pre-defined memory location that has its word equivalent?

PostPosted: Tue Jan 21, 2014 10:30 am 

Joined: Tue Nov 15, 2005 7:58 am
Posts: 129
Location: Oregon, USA
Well, to be picky, you're going to be using loops and branches in the emulator I/O code, just ones written by somebody else...

I don't recognize "lineout, linein, cvta2" as EASy68K assembly instructions. Where are you getting them from?

About the only way to avoid branches is to use math and/or indexing instead. As this is obviously a homework assignment, I'm only going to point you in the right direction, then see what you can come up with on your own. I wrote and tested the code, but it's just one way, not the only way. I'm going to "hide" most of the actual instructions and declarations, so you'll have to study the instruction set for yourself, which is part of the point of the homework. But I'll show my comments, which should suffice.

      ORG    $1000
START:                  ; first instruction of program

*  ... your code to get month number goes here ...
*  Assume at this point that D3 contains the month number (1=Jan, 12=Dec)
    XXXQ     #1,D3           ; Convert to 0=Jan, 11=Dec
    XXXU     #10,D3          ; Convert month number to index into array of 10-byte strings
    LXX      Months,A0       ; Point A0 to array
    XXX      0(A0,D3),XX     ; Point A1 to byte at A0+D3 (start of month name)
*  ... next we do the actual output.  If you're not using EASy68K, you may have to do it a different way ...
    XXXXX    XXX,XX          ; Task 14,  Display the NULL terminated string at (A1) without CR, LF.
    TXXX     XXX             ; Execute task
*   ... your code to print day and year goes here ...

    SIMHALT             ; halt simulator

* Put variables and constants here
    ORG      $2000
    XX.B    'January',0,0,0         ; Pad to length of longest month name, plus a zero byte as string terminator
* ... you do the rest of the months ...

    END    START        ; last line of source

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