Assignment
- Print the Sim68K Text I/O sheet (Start > EASy68K > Help > Simulator I/O >
Text/Time/Terminate) and read it.
• Open the EASy68K editor and type the following program:
Assemble the file by starting the assembler in the usual way and print out the .L86
file.
• Examine the Symbol Table at the bottom of the .L68 file.
• Print out the .S68 file and examine the five lines that begin with the characters
“S1”. What do these lines contain?
• Start the simulator.
• Initialize the program counter to $1500 (not $1000).
• Run your program without turning on the single-step mode. Observe what the
program displays on the screen.
• If you wish to rerun your program, first reset the simulator by clicking the Rewind
button (or typing Ctrl+F2) and then pressing the Run button (or typing F9).
Write an MC68000 program that will print out the smaller of two numbers inputted from
the terminal. The program should prompt the user to input the numbers and then output
the result after a statement indicating the result.
The initial prompts can be “Please input the first number:” and “Please input the second
number:”. The output statement can be “The smaller of the two numbers is:”.
Solution
*———————————————————–
* Title :
* Written by :
* Date :
* Description:
*———————————————————–
ORG $1000
FIRST: DC.B ‘Please input the first number: ‘
DC.B 0
DS.W 0
SECOND: DC.B ‘Please input the second number: ‘
DC.B 0
DS.W 0
OUTPUT: DC.B ‘The smaller of the two numbers is: ‘
DC.B 0
DS.W 0
ORG $1500
START: ; first instruction of program
MOVEA.L #FIRST,A1 ; prompt the user for the first number
MOVE.L #13,D0
TRAP #15
MOVE.L #4,D0 ; read a number from the user into D1.L
TRAP #15
MOVE.L D1,D2 ; save read number in D2 to use it later
MOVEA.L #SECOND,A1 ; prompt the user for the second number
MOVE.L #13,D0
TRAP #15
MOVE.L #4,D0 ; read another number from the user into D1.L
TRAP #15
MOVEA.L #OUTPUT,A1 ; print the output statement
MOVE.L #13,D0
TRAP #15
CMP.L D2,D1 ; compare the first number with the last one read
BLT D1SMALL ; if D1 is smaller, go to print D1
D2SMALL: ; else, D2 is smaller, print it
MOVE.L D2,D1 ; move D2 to D1 for printing it
MOVE.L #3,D0 ; print the number in D1.L using trap 15
TRAP #15
BRA EXIT ; exit the program
D1SMALL:
MOVE.L #3,D0 ; print the number in D1.L using trap 15
TRAP #15
EXIT:
MOVE.B #9,D0
TRAP #15 ; halt simulator
END START ; last line of source
*~Font name~Courier New~
*~Font size~10~
*~Tab type~1~
*~Tab size~4~