how to use easy68k
TRANSCRIPT
-
8/19/2019 How to Use Easy68k
1/52
Assembly Language
-
8/19/2019 How to Use Easy68k
2/52
Introduction
Computers only understand binary code:
Machine language.
Everything is 0’s and 1’s. Instructions.
Data.
Control signals.Hard for humans to understand.
-
8/19/2019 How to Use Easy68k
3/52
Try and translate this:
00110000001111000000000000010010
-
8/19/2019 How to Use Easy68k
4/52
Try and translate this:
00110000001111000000000000010010
MOVE.W #$12,D0
00 11 000000 111 100 0000 0000 0001 0010
(Data register directaddressing mode, D0)
-
8/19/2019 How to Use Easy68k
5/52
Assembly Language
We can represent machine code in AssemblyLanguage:
Easier to understand, program. Simple, low-level programming language.
Using mnemonics (ADD, MOVE, MULU).
Close to human language.
Code generated is machine-specific:
Each µP has own assembly language.
-
8/19/2019 How to Use Easy68k
6/52
Assembly Language
Assembler to generate machine code.
Object file (Motorola: S-file).
Contains machine code.
Linker sometimes used for big projects:
Links together multiple S-files.
Creates single S-file from combined files.
-
8/19/2019 How to Use Easy68k
7/52
The Assembler
Machine Language:
001100000011110000110010001111000000000000110100
Assembly Language:
MOVE.W #$12,D0
MOVE.W #$34,D1
MULU D1,D0
Assembler
-
8/19/2019 How to Use Easy68k
8/52
AssemblyFile #1
AssemblyFile #2
AssemblyFile #3
AssemblyFile #4
ASSEMBLER
ObjectFile #1
ObjectFile #2
ObjectFile #3
ObjectFile #4
LINKER
Final ObjectFile
Listing File
-
8/19/2019 How to Use Easy68k
9/52
Source Code (X68)
-
8/19/2019 How to Use Easy68k
10/52
Object File (S-File)
-
8/19/2019 How to Use Easy68k
11/52
Listing File
-
8/19/2019 How to Use Easy68k
12/52
Data Representation
Methods
-
8/19/2019 How to Use Easy68k
13/52
Data Sizes
Bit:Most basic representation.Contains either 0 or 1. Can be grouped together to represent more meaning.
Nibble: 4 bits.Can represent 16 values (24). Not recognized in M68k.
Need to write special program to handle. Byte: 8 bits.
Indicated by “.B” notation. Can hold value up to 256 (28).
-
8/19/2019 How to Use Easy68k
14/52
Data Sizes
Word: 16 bits.Length of most instructions in M68k.
Can hold value up to 65,535 (216). Indicated by “.W” notation.
Long: 32 bits.
Length of data registers in M68k.Can hold value up to 4,294,967,296 (232).
Indicated by “.L” notation.
-
8/19/2019 How to Use Easy68k
15/52
Bit (1)
Nibble (4)
D3 D0
Byte (8)D7 D0
D15 D0
Word (16)
Long (32)
D31 D0
Data Sizes
-
8/19/2019 How to Use Easy68k
16/52
Data Representation Method
M68k can accept many types of data:
Binary
Octal
Hexadecimal
Decimal
Character
-
8/19/2019 How to Use Easy68k
17/52
Binary
Binary: start with %
Example:
Move binary value 10010101 to D0.
MOVE.B #%10010101,D0
D0 = 0 0 0 0 0 0 9 5
10010101B = 95H
-
8/19/2019 How to Use Easy68k
18/52
Octal
Octal: start with @
Example:
Move octal value 45 to D0.
MOVE.B #@45,D0
D0 = 0 0 0 0 0 0 2 5
45O = 25H
-
8/19/2019 How to Use Easy68k
19/52
-
8/19/2019 How to Use Easy68k
20/52
Decimal
Decimal: no need to put any symbols.
Example:
Move decimal value 10 to D0.
MOVE.B #10,D0
D0 = 0 0 0 0 0 0 0 A
10D = 0AH
-
8/19/2019 How to Use Easy68k
21/52
ASCII Characters
Characters: Enclose character in singlequotes (‘ ’).
Example:Move ASCII character ‘A’ to D0.
MOVE.B #’A’,D0
D0 = 0 0 0 0 0 0 4 1
A = 41H
-
8/19/2019 How to Use Easy68k
22/52
Easy68k
-
8/19/2019 How to Use Easy68k
23/52
Easy68k
Designed by Prof. C. Kelly, MonroeCounty Community College.
Freeware.
Installer: http://www.easy68k.com/index.html
Easy68k Quick-Ref:http://www.easy68k.com/QuickStart/LoadPageFrames.htmhttp://www.easy68k.com/files/EASy68KQuickRef.pdf
http://www.easy68k.com/QuickStart/LoadPageFrames.htmhttp://www.easy68k.com/files/EASy68KQuickRef.pdfhttp://www.easy68k.com/files/EASy68KQuickRef.pdfhttp://www.easy68k.com/QuickStart/LoadPageFrames.htm
-
8/19/2019 How to Use Easy68k
24/52
Easy68k Interface
LABEL
INSTRUCTION
VARIABLES/PARAMETERS
ANYTHING PAST THIS ISIGNORED, TREATED AS COMMENT.
PROGRAM DESCRIPTION
-
8/19/2019 How to Use Easy68k
25/52
Programming in Easy 68k
Easy68k divides program into columns: Label:
Marks memory locations using characters.
Easy reference. Instruction:
What instruction to execute.
Variables/Parameters: Usually specifies source & destination.
May specify parameters as well. Comment:
Used to describe flow of program,
-
8/19/2019 How to Use Easy68k
26/52
Simulation Window
Shows status of internalM68k registers.
Memory addresswhere instructionis stored.
Machine code generatedby assembler.
Press here to executeprograms step-by-step.
Press here to restartprogram execution.
-
8/19/2019 How to Use Easy68k
27/52
MOVE.B #9,D0 instruction:
Is on line 11 in M68k source file.Is stored in memory address $1000.Its machine code is $103C0009 (00010000001111000000000000001001).
-
8/19/2019 How to Use Easy68k
28/52
Specify Start/End of Program
M68k needs to know where to startexecuting instructions, where to stop.
Specified using ORG (Origin), END (End). Value of ORG loaded into PC, execution
starts there.
-
8/19/2019 How to Use Easy68k
29/52
Format: Start/End Program
ORG $1000
END $1000
Program Instructions
PC loaded with $1000,starts executing from here.
END specifies ending of program.
-
8/19/2019 How to Use Easy68k
30/52
Format: Start/End Program
START ORG $1000
END START
Program Instructions
PC loaded with $1000,starts executing from here.
END specifies ending of program.
-
8/19/2019 How to Use Easy68k
31/52
Use Labels
Any memory location may be given labels.
Easier to refer to specific locations:Useful in for loops, subroutines, branch
commands.
-
8/19/2019 How to Use Easy68k
32/52
Using Labels - Example
START ORG $1000
MOVE.B #$2000,A0
MOVE.B #$10, D1CLR.B D0
LABEL1 ADD.B (A0)+, D0SUB.B #1, D1
BNE LABEL1
END START
-
8/19/2019 How to Use Easy68k
33/52
Flowchart
-
8/19/2019 How to Use Easy68k
34/52
Flowchart
Graphical method to plan flow of ourprograms.
Shows program’s step-by-step operation. Easy to understand and analyze.
Can be used to write organized programs.
-
8/19/2019 How to Use Easy68k
35/52
Flowchart Basic shapes:
Terminator.
Process.
Decision.
Input/Output.
Connectors.
A = A + B
D0 = 3?
TRUE FALSE
Input D0
-
8/19/2019 How to Use Easy68k
36/52
Basic Shapes – Terminator
Indicates beginning and end of flowchart.
Once at beginning, once at end.
Examples:
START FINISH
-
8/19/2019 How to Use Easy68k
37/52
Basic Shapes - Process
Describes actions to be done.
Represented as rectangles.
Short description of process in rectangle.
Example:
A = A + B Reset Ports Clear D0
-
8/19/2019 How to Use Easy68k
38/52
Basic Shapes - Decision
Shows alternative program flow based oncondition.
Represented as diamond shape. Should have 2 arrows, representing
TRUE and FALSE program flows.
Can be used in “if…else”, “while”, and “for”situations.
-
8/19/2019 How to Use Easy68k
39/52
Basic Shapes - Decision
Examples:
D0 = 3?
TRUE FALSE
Port is active?TRUE
FALSE
-
8/19/2019 How to Use Easy68k
40/52
Basic Shapes – Input/Output
Shows the process of inputting oroutputting data.
Represented using rhombus. Examples:
Input D0 Show calculationresults
-
8/19/2019 How to Use Easy68k
41/52
Basic Shapes - Connectors
Used to link large process flows together.
Represented using circles, with numbers
inside. Numbers indicate connection.
Examples:
1 3
-
8/19/2019 How to Use Easy68k
42/52
-
8/19/2019 How to Use Easy68k
43/52
Writing the Program
Once flowchart is complete, write code toimplement program.
Follow program flow closely. Check and fix problems if necessary.
-
8/19/2019 How to Use Easy68k
44/52
Example: Calculate Area of
RectangleB
L
START
Input L
Input B
1
Area = L xB
1
FINISH
-
8/19/2019 How to Use Easy68k
45/52
Translation to Assembly
START
Input D0
Input D1
D0 = D0 x D1
FINISH
ORG $1000
MOVE.W #$12,D0
MOVE.W #$34,D1
MULU D1,D0
END
-
8/19/2019 How to Use Easy68k
46/52
Complete Program
START ORG $1000
MOVE.W #$12,D0
MOVE.W #$34,D1
MULU D1,D0
END START
-
8/19/2019 How to Use Easy68k
47/52
Example: Add 10 Numbers
Together START
Input numbersinto memory
locations.
D0 = 10
Load startingaddress into A0
Clear D1
FINISH
D0 = 0?
D1 = D1 + (A0)
FALSE
Go to nextmemory location
D0 = D0 - 1
TRUE
-
8/19/2019 How to Use Easy68k
48/52
START
Input numbersinto memory
locations.
Load startingaddress into A0
ORG $1000
MOVE.W #$11,$1100MOVE.W #$22,$1102
MOVE.W #$33,$1104MOVE.W #$44,$1106MOVE.W #$55,$1108MOVE.W #$66,$110AMOVE.W #$77,$110CMOVE.W #$88,$110E
MOVE.W #$99,$1110MOVE.W #$11,$1112
MOVEA.L #$1100,A0
-
8/19/2019 How to Use Easy68k
49/52
D0 = 10
Clear D1
D0 = 0?
D1 = D1 + (A0)
FALSE
D0 = D0 - 1
MOVE.B #10,D0
CLR.B D1
Go to nextmemory location
LOOP…BNE LOOP, CMP.B #$0,D0
ADD.W (A0),D1
ADDA.L #$2,A0
FINISH
SUB.B #$1,D0
END
-
8/19/2019 How to Use Easy68k
50/52
Complete Program
START ORG $1000
MOVE.W #$11,$1100MOVE.W #$22,$1102MOVE.W #$33,$1104MOVE.W #$44,$1106MOVE.W #$55,$1108MOVE.W #$66,$110AMOVE.W #$77,$110CMOVE.W #$88,$110EMOVE.W #$99,$1110MOVE.W #$11,$1112
MOVEA.L #$1100,A0MOVE.B #10,D0
CLR.B D1
LOOP ADD.W (A0),D1ADDA.L #$2,A0SUB.B #$1,D0CMP.B #$0,D0BNE LOOP
END START
-
8/19/2019 How to Use Easy68k
51/52
Conclusion
-
8/19/2019 How to Use Easy68k
52/52
Conclusion
Assembly language:
Mnemonics instead of binary.
Needs assembler to convert to machine code.
Easy68k organizes code in columns.
Flowcharts simplify program design:
Organize program flow.
Easier to manage and debug.