Jie Hu, ECE/NJIT, Spring 2011 ECE252 L03-68000 ISA.1 ECE252 Microprocessors Spring 2011 Lecture 03: 68000 Instruction Set Jie Hu http://web.njit.edu/~jhu/ece252/10 2
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.1
ECE252 MicroprocessorsSpring 2011
Lecture 03: 68000 Instruction Set
Jie Hu
http://web.njit.edu/~jhu/ece252/102
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.2
Review of Last Lecture
Functional Description of the 68000 68000 64-pin package, pin layout, pin input/output signals
Programming Model of the 68000 8 32-bit data registers: D0 – D7 8 (+1) 32-bit address registers: A0 – A7 24-bit program counter: PC 16-bit status register: SR
Endianness: byte ordering of .W/.L in memory space big endian (higher byte lower address): 68000, Sparc, … little endian (lower byte lower address): Intel 80x86, Alpha, …
Number Systems and Base Conversion decimal, binary, octal, hexadecimal
Signed Binary Representations 2’ complement: 1 00000002 = (?)10
ASCII Code Table
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.3
Block Diagram of Macintosh 512K Motherboard
Processor68000
I/O Interface6522
Real-timeclock
Serial I/O8530
Floppy diskcontroller
SystemROM
RAM buffersand Mux
PALdecoders
DynamicRAM
512KB
Soundlogic
Videologic
Speaker Video display
Controlsignals
Modem PrinterMouse Keyboard
System bus
Disk drive
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.4
Today’s Lecture
Assembly Language Programming
Understanding Motorola S-Record File Format
Easy68K Text I/O
68000 Instruction Set & 68000 Instruction Description Format
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.5
Assembly Language Programming
Windows based EASy68K
Source file
HELLO.X68
68K Assembler
List file
HELLO.L68
Hex (S-records) file
HELLO.S68
Sim68K Simulator
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.6
Assembly Language Programming (EASy68K)
Source file (.X68) A set of assembly instructions (codes) in the format of
[Label] OPCODE operands [; comments] Comments shall follow either “;” or “*” Each instruction starts a NEW line The program code shall start with “[Start label] OPCODE …” The main file should end with “END [Start Label]”
* A label is a user created name and is used to identify a location in a program or a memory location by name
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.7
HELLO Program
68000 assembly code (Hello.X68)
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.8
Assembly Language Programming (EASy68K)
List file (.L68) Created by the assembler Contains the original source file text, and Generated machine binaries for program code and data, along
with their memory addresses, and Symbol table: entries in format of “Label Value”, and Messages concerning this assembling task (Note: if you couldn’t
pass assembling the source file, check the error/warning message in this list file)
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.9
HELLO Program
68000 List File (Hello.L68)
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.10
Assembly Language Programming
Hex file (.S68): called S-records file by Motorola Contains the printable object code in a text format, created by
the assembler Used by Sim68K for simulation, and Useful for downloading over serial lines to SBC
An S-record file consists of a sequence of specially formatted ASCII character strings.
An S-record will be less than or equal to 78 bytes in length. The order of S-records within a file is of no significance and no particular order may be assumed.
The general format of an S-record follows:
Type Count Address Data chksum
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.11
Motorola HEX (S-records) File Format
type -- A char[2] field, type of record (S0, S1, S2, S3, S5, S7, S8, or S9).
count -- A char[2] field, the count of remaining character pairs (in hexadecimal value) in the record.
address -- A char[4,6, or 8] field, interpreted as a hexadecimal value, display the address (in 16-bit, 24-bit, or 32-bit) at which the data field is to be loaded into memory.
data -- A char [0-64] field, interpreted as hexadecimal values represent the memory loadable data or descriptive information.
checksum -- A char[2] field, interpreted as a hexadecimal value display the odd parity coding of the pairs of characters making up the count, the address, and the data fields.
Type Count Address Data chksum
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.12
Motorola HEX (S-records) File
Hello.S68
S0 21 0000 36384B50524F47202020313143524541544544204259204541535936384B 6D
S0 this is a header line
21 there are 33 bytes that follow (Right after 21)
0000 no meaning in the header
36384B50524F47202020313143524541544544204259204541535936384B ASCII byte codes for “6 8 K P R O G 1 1 C R E A T E D B Y E A S Y 6 8 K ”
6D check byte used to obtain check sum as follows:
21+00+00+36+38+4B+52+4F+…+36+36+4B+6D=FF
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.13
Motorola HEX File
Hello.S68
S1 0A 8000 48656C6C6F2100 60
S1 this line contains data/code and a 16-bit load address (if S2, then 24-bit address; if S3, then 32-bit address)
0A there are 10 bytes (a 2 byte address, 7 byte data, and 1 byte checksum) that follow
8000 starting memory address of the 7 byte data
48656C6C6F2100 7 bytes to be loaded
60 check byte used to obtain check sum as follows:
0A+80+00+48+65+6C+6C+6F+21+00+60=FF
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.14
Motorola .HEX File
Hello.S68
S8 04 008100 7A
S8 this is a file-terminating footer-line with a 24-bit (3 byte) program entry address (if S9, then 16-bit address; if S7, then 32-bit address)
04 there are 4 bytes that follow
008100 program entry address
7A check byte used to obtain check sum as follows:
04+00+00+81+00+7A=FF
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.15
EASy68K TEXT I/O: task #0 - #10 (different from book)
TRAP #15 is used for I/O. Put the task number in D0.
0 Display string at (A1), D1.W bytes long (max 255) with carriage return and line feed (CR, LF).
1 Display string at (A1), D1.W bytes long (max 255) without CR, LF.
2 Read string from keyboard and store at (A1), length retuned in D1.W (max 80)
3 Display signed number in D1.L in decimal in smallest field. (see also task 15 & 20)
4 Read a number from the keyboard into D1.L.
5 Read single character from the keyboard into D1.B.
6 Display single character in D1.B.
7 Set D1.B to 1 if keyboard input is pending, otherwise set to 0. Use code 5 to read pending key.
8 Return time in hundredths of a second since midnight in D1.L.
9 Terminate the program.
10 Print the NULL terminated string at (A1) to the default printer. (Not Teesside compatible.) Always send a Form Feed character to end printing. (See below.)
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.16
EASy68K TEXT I/O: task #11 - #15
11
Position the cursor at ROW, COL. The high byte of D1.W holds the COL number (0-79), The low byte holds the ROW number (0-31). 0,0 is top left 79,31 is the bottom right. Out of range coordinates are ignored. Clear Screen : Set D1.W to $FF00.
12
Keyboard Echo. D1.B = 0 to turn off keyboard echo. D1.B = non zero to enable it (default). Echo is restored on 'Reset' or when a new file is loaded.
13 Display the NULL terminated string at (A1) with CR, LF.
14 Display the NULL terminated string at (A1) without CR, LF.
15
Display the unsigned number in D1.L converted to number base (2 through 36) contained in D2.B. For example, to display D1.L in base16 put 16 in D2.B Values of D2.B outside the range 2 to 36 inclusive are ignored.
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.17
EASy68K TEXT I/O: task #16 - #20
16
Adjust display properties D1.B = 0 to turn off the display of the input prompt. D1.B = 1 to turn on the display of the input prompt. (default) D1.B = 2 do not display a line feed when Enter pressed during Trap task #2 input D1.B = 3 display a line feed when Enter key pressed during Trap task #2 input (default) Other values of D1 reserved for future use. Input prompt display is enabled by default and by 'Reset' or when a new file is loaded.
17 Combination of Trap codes 14 & 3. Display the NULL terminated string at (A1) without CR, LF then Display the decimal number in D1.L.
18 Combination of Trap codes 14 & 4. Display the NULL terminated string at (A1) without CR, LF then Read a number from the keyboard into D1.L.
19
Returns current state of up to 4 specified keys or returns key scan code. Pre: D1.L = four 1-byte key codes Post: D1.L contains four 1-byte Booleans. $FF = corresponding key is pressed, $00 = corresponding key not pressed. Pre: D1.L = $00000000 Post: D1.B contains key code of last key pressed
20 Display signed number in D1.L in decimal in field D2.B columns wide.
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.18
Programming Exercise 1.2
Write a program that display your first and last name.
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.19
Overview of 68000 Instruction Set
Data transfer group (11) EXG, LEA, LINK, MOVE, MOVEA, MOVEM, MOVEP, MOVEQ, PEA, SWAP,
UNLK Arithmetic group (23)
ADD, ADDA, ADDI, ADDQ, CLR, CMP, CMPA, CMPI, CMPM, DIVS, DIVU, EXT, MULS, MULU, NEG, NEGX, SUB, SUBA, SUBI, SUBQ, SUBX, TAS, TST
Logical group (7) AND, ANDI, OR, ORI, EOR, EORI, NOT
Shift and rotate group (8) ASL, ASR, LSL, LSR, ROL, ROR, ROXL, ROXR
Bit manipulation group (4) BCHG, BCLR, BSET, BTST
Binary coded decimal (BCD) group (3) ABCD, NBCD, SBCE
Program control group (9) Bcc, DBcc, Scc, BRA, BSR, JMP, JSR, RTR, RTS
System control group (17) ANDI SR, ORI SR, EORI SR, MOVE SR, MOVE USP, RESET, RTE, STOP,
CHK, ILLEGAL, TRAP, TRAPV, ANDI CCR, ORI CCR, EORI CCR, MOVE CCR, NOP
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.20
Motorola’s Instruction Description – Appendix B
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.21
Motorola’s Instruction Description (cont’d)
The mnemonic of the instruction, with a brief description
The operations performed by the instruction
The required assembler syntax
The allowed data size are give here. ADDI supports .B, .W, and .L data sizes
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.22
Motorola’s Instruction Description (cont’d)
A more detailed description of what the processor does when executing the instruction
The effect of the instruction on five condition codes
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.23
Motorola’s Instruction Description (cont’d)
The binary format of the instruction
The two bits specify the ADDI instruction’s data size
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.24
Motorola’s Instruction Description (cont’d)
This table indicates what destination addressing modes are allowed. This table is very useful for debugging program code when an illegal addressing mode has been used with a particular instruction
Jie Hu, ECE/NJIT, Spring 2011ECE252 L03-68000 ISA.25
Next Lecture and Reminders
Next Lecture: 68000 Addressing Modes
Reading: BK 27-31, 40-47