0% found this document useful (0 votes)
287 views25 pages

Lecture 03

The document describes the 68000 instruction set and Easy68K text input/output functions. It discusses assembling 68000 assembly code using EASy68K, which produces list and hex files. The hex file format follows Motorola S-records format. It also details various text I/O tasks that can be performed using TRAP #15, including displaying/reading strings and numbers, cursor positioning, and keyboard input handling.

Uploaded by

Faisal Mahmood
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
287 views25 pages

Lecture 03

The document describes the 68000 instruction set and Easy68K text input/output functions. It discusses assembling 68000 assembly code using EASy68K, which produces list and hex files. The hex file format follows Motorola S-records format. It also details various text I/O tasks that can be performed using TRAP #15, including displaying/reading strings and numbers, cursor positioning, and keyboard input handling.

Uploaded by

Faisal Mahmood
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 25

ECE252 Microprocessors

Spring 2011

Lecture 03: 68000 Instruction Set

Jie Hu
http://web.njit.edu/~jhu/ece252/102

ECE252 L03-68000 ISA.1 Jie Hu, ECE/NJIT, Spring 2011


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
ECE252 L03-68000 ISA.2 Jie Hu, ECE/NJIT, Spring 2011
Block Diagram of Macintosh 512K Motherboard
Mouse Keyboard Modem Printer Disk drive

Real-
Processor I/O Interface Serial I/O Floppy disk
time
68000 6522 8530 controller
clock

System bus

System RAM buffers PAL


ROM and Mux decoders

Control
signals
Dynamic Sound Video
RAM logic logic
512KB
Video
Speaker
display
ECE252 L03-68000 ISA.3 Jie Hu, ECE/NJIT, Spring 2011
Today’s Lecture
 Assembly Language Programming

 Understanding Motorola S-Record File Format

 Easy68K Text I/O

 68000 Instruction Set & 68000 Instruction Description


Format

ECE252 L03-68000 ISA.4 Jie Hu, ECE/NJIT, Spring 2011


Assembly Language Programming
 Windows based EASy68K
Source file
HELLO.X68

68K Assembler

List file Hex (S-records) file

HELLO.L68 HELLO.S68

Sim68K Simulator

ECE252 L03-68000 ISA.5 Jie Hu, ECE/NJIT, Spring 2011


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

ECE252 L03-68000 ISA.6 Jie Hu, ECE/NJIT, Spring 2011


HELLO Program
 68000 assembly code (Hello.X68)

ECE252 L03-68000 ISA.7 Jie Hu, ECE/NJIT, Spring 2011


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)

ECE252 L03-68000 ISA.8 Jie Hu, ECE/NJIT, Spring 2011


HELLO Program
 68000 List File (Hello.L68)

ECE252 L03-68000 ISA.9 Jie Hu, ECE/NJIT, Spring 2011


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

ECE252 L03-68000 ISA.10 Jie Hu, ECE/NJIT, Spring 2011


Motorola HEX (S-records) File Format

Type Count Address Data chksum

 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.

ECE252 L03-68000 ISA.11 Jie Hu, ECE/NJIT, Spring 2011


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 11CREATED BY EASY68K”
6D  check byte used to obtain check sum as follows:

ECE252 L03-68000 ISA.12


21+00+00+36+38+4B+52+4F+…+36+36+4B+6D=FF
Jie Hu, ECE/NJIT, Spring 2011
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:
ECE252 L03-68000 ISA.13 0A+80+00+48+65+6C+6C+6F+21+00+60=FF Jie Hu, ECE/NJIT, Spring 2011
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
ECE252 L03-68000 ISA.14 Jie Hu, ECE/NJIT, Spring 2011
EASy68K TEXT I/O: task #0 - #10 (different from book)

 TRAP #15 is used for I/O.  Put the task number in D0.
 Display string at (A1), D1.W bytes long (max 255) with carriage return and line
 0
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. 
 Set D1.B to 1 if keyboard input is pending, otherwise set to 0.
 7
 Use code 5 to read pending key.
 8  Return time in hundredths of a second since midnight in D1.L.
 9  Terminate the program.
 Print the NULL terminated string at (A1) to the default printer. (Not Teesside
 10 compatible.)
 Always send a Form Feed character to end printing. (See below.)
ECE252 L03-68000 ISA.15 Jie Hu, ECE/NJIT, Spring 2011
EASy68K TEXT I/O: task #11 - #15

 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).
 11
    0,0 is top left 79,31 is the bottom right. 
    Out of range coordinates are ignored. 
 Clear Screen : Set D1.W to $FF00.
 Keyboard Echo.
    D1.B = 0 to turn off keyboard echo.
 12
    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.
 Display the unsigned number in D1.L converted to number base (2 through
36) contained in D2.B.
 15
    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.

ECE252 L03-68000 ISA.16 Jie Hu, ECE/NJIT, Spring 2011


EASy68K TEXT I/O: task #16 - #20
 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
 16 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.
 Combination of Trap codes 14 & 3.
 17  Display the NULL terminated string at (A1) without CR, LF then
 Display the decimal number in D1.L.
 Combination of Trap codes 14 & 4.
 18  Display the NULL terminated string at (A1) without CR, LF then
 Read a number from the keyboard into D1.L.
 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.
 19            $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.
ECE252 L03-68000 ISA.17 Jie Hu, ECE/NJIT, Spring 2011
Programming Exercise 1.2
 Write a program that display your first and last name.

ECE252 L03-68000 ISA.18 Jie Hu, ECE/NJIT, Spring 2011


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

ECE252 L03-68000 ISA.19 Jie Hu, ECE/NJIT, Spring 2011


Motorola’s Instruction Description – Appendix B

ECE252 L03-68000 ISA.20 Jie Hu, ECE/NJIT, Spring 2011


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

ECE252 L03-68000 ISA.21 Jie Hu, ECE/NJIT, Spring 2011


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

ECE252 L03-68000 ISA.22 Jie Hu, ECE/NJIT, Spring 2011


Motorola’s Instruction Description (cont’d)

 The binary format of the instruction

 The two bits specify the ADDI instruction’s data size

ECE252 L03-68000 ISA.23 Jie Hu, ECE/NJIT, Spring 2011


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

ECE252 L03-68000 ISA.24 Jie Hu, ECE/NJIT, Spring 2011


Next Lecture and Reminders
 Next Lecture: 68000 Addressing Modes

 Reading: BK 27-31, 40-47

ECE252 L03-68000 ISA.25 Jie Hu, ECE/NJIT, Spring 2011

You might also like