You are on page 1of 6

A Quickie Introduction to the Windows Based 68K

Assembler EASy68K
You now have a number of options to assemble your code for your microcontroller. One
option, of course, is to assemble it by hand, using the byte by byte machine codes from
the programmers reference.
Ouch.
This might prove to be a little bit painful for you, though, so some thoughtful and
generous people have given of their time and made available assemblers that will make
your job far easier.
The most basic of these may be the dos command line assembler described in another
document on your class website. However, for those of you who dont like being all
command-line-y and would prefer something more windows like, another program called
EASy-68K may be more your speed. Its available for free download off the course
website or several others and is provided to the world under the gnu public license, so
feel free to install it on your home system if youd like to play with it there, too.
Heres a quickie intro to get you started.
From the start menu on any of the lab computers, open:
Start:Programs:EASy68K:Edit68k. It will give you a blank template.
As a starter, lets enter the test program from last weeks lab. Its about as humble as
programs can possibly be.

Enter the following code:


*----------------------------------------------------------* Program
: A basic loop program
* Written by : Joseph Bloe
* Date
: 3/14/16 (Pi Day, 2016)
* Description: A most basic program to use the editor
*----------------------------------------------------------START
ORG
$100
LOOP

nop
bra.s LOOP
END

START

When youre done, your screen should look like below:

Save it, then, time to simulate. Go to Project:Assemble Source. This brings up the
simulator. It should look similar to below.

This verifies your program assembly code from last week. Notice your memory
locations, along with the machine code, offsets, etc. all nicely calculated for you along
the left side. If you run it, youll see it loops just like you saw with your microcontroller
last week.
Heres a little more complicated example. A little more but not much
Go back to the editor, start a new file and enter the following code:
*----------------------------------------------------------* Program
: A basic loop program
* Written by : Joseph Bloe
* Date
: 3/14/16 (Pi Day, 2016)
* Description: A most basic program to use the editor
*----------------------------------------------------------START
ORG
$1000

LOOP

move.w #$1000,D0
move.w D0,D1
add.w #$0003,D0
bra.s LOOP
END
START

Your screen should look like this at this point:

This program is also brainlessly simple. Put an immediate value in D0, move D0 to D1
using register direct addressing. Add an immediate value to D0 And go back to LOOP.
Again, save and simulate, giving the following screen:

Notice you have all sorts of goodies to help you debug. You can see, most importantly for
us:
The Program Counter
Data Registers
Address Registers
Status Registers
Cycle Counts

Step through the program by clicking the Trace into button (6th button from the left
with the straight right arrow). Youll go step by step through the program. Notice a few
things.
-- The registers (data, address, program counter, etc) update as you step through the
program.
-- The cycles counter changes, but not by the same amount for each instruction. Different
opcodes require different numbers of cycles to execute.
Also, the blue line represents the current location of the program counter. Reset the
simulation by clicking the Reset Program button. Start stepping through the program.
When does the D0 register get updated? What is the Program counter value? The
registers are always a step behind the program counter -One final point: Your peripherals are primarily going to be memory mapped I/O devices.
The 68K controllers dont differentiate between memory and I/O space. So, one of the
easiest ways for your to watch outputs is simply to watch the memory locations assigned
to them. Do this using the memory utility View-Memory. Always keep in mind,
however, what your hardware is doing. In our case, remember, for example, that as of
lab 19 address $8000 is mapped to both the keypad output AND the displays. So you
much keep this in mind if you use a memory map to view input or output.
The hardware simulator portion of the assembler may be of use as well, but if you use it
do so with some caution. Be sure you understand how each of the parts works. The LED
displays, for example, are true 7 Segment LEDs, with an 8th bit as the decimal point.
Heres a short program you can play with to experiment with how they work. Set your
display address to $E000 and $F000 respectively. Enter it and try running it if you like.
*----------------------------------------------------------* Program
: 7 Segment Example with Rotate
* Written by : Joseph Bloe
* Date
: 3/14/16 (Pi Day, 2016)
* Description: A most basic program to use the editor
*----------------------------------------------------------START
ORG
$1000
* 7 Segment and LED Array Example
move.b #$0001,D0
LOOP

*
*
*
*

move.b D0,$E000
move.b D0,$F000
ROL.b #1,D0
bra.s LOOP

You should see the LEDS and march across the screen to the left
and around the 7 segment display
Since there's no pause, you should AutoTrace to slowly step
through the program.
END

START

Heres the hardware display. Again, be sure the addresses match what you expect in your
coding.

The 7 segment displays do not, youll note have the fancy decoding chip, latches, etc that
your displays for your address bus do. So while $FF will display as FF on your data or
address displays, it will display as 8. on these displays. Hardware is king be sure
you know what yours is doing. If you look at the memory map, the values should of
course, correspond.
There are many more things you can do with the simulator. See the help file for more
details. But this will get you started doing assembly programs.

You might also like