You are on page 1of 4

Laboratory #1: 68000 Microprocessor Software Development

Introduction
The purpose of this experiment is to show the method used to develop and test
68000 microprocessor assembly language programs.
Procedure
1. First, go to the author's web site and download the newest versions of ASM68K
and EMU68K. The web site is located at
http://web.sunybroome.edu/~antonakos_j/68ktoc.html
Note: Save the files in a directory or folder specified by the instructor.
2. Place a copy of the program HELLO.ASM into the software folder from step 1.
HELLO.ASM is located on the companion CD in the ch01 folder.
3. Open a DOS window and navigate to the software directory from step 1.
4. Enter the following command at the DOS prompt:
edit hello.asm
You should see the following code:
ORG
DC.B
DC.B
ORG
START MOVEA.L
TRAP
TRAP
END
HMSG

$8000
'Hello!'
0
$8100
#HMSG,A3
#3
#9
START

;starting address of data


;message characters
;end-of-message marker
;starting address of program
;load A3 with message address
;output message
;return to command processor
;end of source file

5. Press Alt, then F, then X to exit the edit program.


6. Enter this DOS command:
asm68k hello

7. The ASM68K assembler will create HELLO.LST,


HELLO.HEX. The screen should look like this:

HELLO.OBJ,

and

ASM68K Version 4.0, 8/17/03


8 lines processed.
0 warnings.
0 fatals.

8. Enter the following DOS command to view the list file:


edit hello.lst
You should see something similar to the following:
008000
008000
008006
008100
008100
008106
008108
00810A

4865 6C6C 6F21


00

HMSG

267C 0000 8000


4E43
4E49

START

ORG
DC.B
DC.B
ORG
MOVEA.L
TRAP
TRAP
END

$8000
'Hello!'
0
$8100
#HMSG,A3
#3
#9
START

;starting address of data


;message characters
;end-of-message marker
;starting address of program
;load A3 with message address
;output message
;return to command processor
;end of source file

Note that the ASM68K assembler has determined all the addresses and opcodes for
the source instructions.
9. Exit the editor by pressing Alt, then F, then X.
10. Simulate the execution of the HELLO code by loading it into the EMU68K
emulator with the following DOS command:
emu68k hello
You should see something like this:
68000 Emulator V4.1, 8/12/03
54984 (0xD6C8) bytes allocated for emulator memory.
S008000068656C6C6FE3
S10A800048656C6C6F210060
S10D8100267C000080004E434E4927
S90381007B
Starting address: 8100
hello.hex loaded into emulator memory.
Enter '?' for help
-

The four lines of text beginning with S are the Motorola S-records that represent the
68000 machine code and data for the HELLO program. The program is
automatically loaded into the correct memory locations for emulation.
11. Simulate the program by entering g at the EMU68K command prompt:
-g
Hello!Program exit at address 00008108

12. Quit the emulator by entering q at the command prompt.


13. Steps 4 through 12 are used multiple times when developing a new 68000
program. Use them to enter and debug the following program.
SHOWDECI

DODIGIT

ORG
MOVE.W
MOVE.W
MOVE.W
BSR
MOV.W
BSR
MOVE.W
BSR
MOVE.W
BSR
MOVE.B
ADDI.B
TRAP
RTS

$8100
#54321,D7
D7,D6
#10000,D5
DODIGIT
#1000,D5
DODIGIT
#100,D5
DODIGIT
#10,D5
DODIIT
D6,D1
#$30,D1
#1

ANDI.L
DIVU
MOVE.B
ADDI.B
TRAP
SWAP
RTS

#$FFFF,D6
D5,D6
D6,D1
#$30,D1
#1
D6

END

SHOWDECI

;init D7 to 54321
;make copy of input number
;do 10,000's digit
;do 1,000's digit
;do 100's digit
;do 10's digit
;load 1's digit
;add ASCII bias
;and display
;clear upper word of D6
divide D6 by D5
;load result digit
;add ASCII bias
;display digit
;get remainder

Note: Enter the program exactly as shown here. There are deliberate errors within
the source statements that will need correction after their errors are reported by the
ASM68K assembler. When the program assembles without errors, use EMU68K to
simulate it. You should see the correct output of '54321' displayed, followed by an
error message. What is the error message? Can you explain the reason for the error?

14. Change the RTS instruction at the end of the SHOWDECI code to TRAP #9.
15. Reassemble the program and simulate it. Has the error gone away?
A Little Deeper
16. Compare the information found in HELLO.HEX with the address/opcode
information contained in HELLO.LST. What can you discover about the Motorola Srecords?
S008000068656C6C6FE3
S10A800048656C6C6F210060
S10D8100267C000080004E434E4927
S90381007B

You might also like