You will write a program in Motorola 68000 assembler that will calculate the use
ID: 643827 • Letter: Y
Question
You will write a program in Motorola 68000 assembler that will calculate the user's age in 2015 given the user's date of birth.
First, the program will print the programming assignment number, your name, and your class account, all on one line. Then your program will prompt the user to enter his/her birthdate in the format MM/DD/YYYY. Your program will then calculate the user's age in 2015, and print the string "* In 2015 you will be XX years old. *". The XX should be replaced by the person's age in 2015. The age field may be 1-3 characters wide. You may not add extra spaces to the string. It must be printed all on one line. Additionally, the answer must be preceded and followed by a line of * characters exactly the same length as the answer line. Thus, you will have a box surrounding the answer.
EI:
*
WHAT I HAVE SO FAR:
start: initIO * Initialize (required for I/O)
setEVT * Error handling routines
* initF * For floating point macros only
lineout title
lineout prompt
linein buffer
cvta2 buffer+6,#4 * answer in D0
move.l #2015,D7
sub.l D0,D7 * age in 2015
move.l D7,D0
break * Terminate execution
*
*----------------------------------------------------------------------
* Storage declarations
title: dc.b 'Program #1, hidden adress, Name',0
prompt: dc.b 'Enter your date of birth MM/DD/YYYY:',0
buffer: ds.b 80
answer: dc.b '* In 2015 you will be '
age: ds.b 20
end
Explanation / Answer
ORG $0 DC.L $3000 * Stack pointer value after a reset DC.L start * Program counter value after a reset ORG $3000 * Start at location 3000 Hex * *---------------------------------------------------------------------- * #minclude /home/ma/cs237/bsvc/iomacs.s #minclude /home/ma/cs237/bsvc/evtmacs.s * *---------------------------------------------------------------------- * * Register use * D0 macro usage and holds 2012 for calculation * D1 holds user's date of birth year * A0 holds the address age * A1 holds address of stars+35 * *---------------------------------------------------------------------- * start: initIO * Initialize (required for I/O) setEVT * Error handling routines * initF * For floating point macros only lineout title * Prints contents at the address lineout skipln lineout prompt linein buffer * Stores user input from keyboard at this address cvta2 buffer+6,#4 * Takes first 4 bytes at address and converts to two's complement move.l D0,D1 move.l #2012,D0 sub.l D1,D0 * Subtracts 2012 - (User Entered Year) cvt2a age,#3 stripp age,#3 lea age,A0 adda.l D0,A0 * Increments A0 by amount in D0 move.b #' ',(A0)+ * Increments the address register to complete the string move.b #'y',(A0)+ move.b #'e',(A0)+ move.b #'a',(A0)+ move.b #'r',(A0)+ move.b #'s',(A0)+ move.b #' ',(A0)+ move.b #'o',(A0)+ move.b #'l',(A0)+ move.b #'d',(A0)+ move.b #'.',(A0)+ move.b #' ',(A0)+ move.b #'*',(A0)+ clr.b (A0) * Null terminates the string lea stars+35,A1 adda.l D0,A1 clr.b (A1) lineout stars lineout answer lineout stars move.b #'*',(A1) * Replaces '*' that gets null terminated break * Terminate execution * *---------------------------------------------------------------------- * Storage declarations buffer: ds.b 80 title: dc.b 'Program #1, Kyle Boyce, masc1370',0 skipln: dc.b 0 prompt: dc.b 'Enter your date of birth (MM/DD/YYYY):',0 answer: dc.b '* In 2015 you will be ' age: ds.b 20 stars: dcb.b 40,'*' end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.