lecture 4: software details of the 68000

34
Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI Unless otherwise specified, all materials and diagrams are adapted from the following sources: 1. Antonakos J.L., The 68000 Microprocessor , Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design , 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 1/94 Lecture 4: Software Details of the 68000 - Assembly Language Programming - The ASM68K Compiler & EMU68K Emulator - Assembler Directives - The 68000’s Addressing Modes - The 68000’s Condition Codes Register - The 68000’s Instruction Set - * Trap Exceptions

Upload: others

Post on 12-Feb-2022

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 1/94

Lecture 4: Software Details of the 68000 - Assembly Language Programming

- The ASM68K Compiler & EMU68K Emulator

- Assembler Directives

- The 68000’s Addressing Modes

- The 68000’s Condition Codes Register

- The 68000’s Instruction Set

- * Trap Exceptions

Page 2: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 2/94

Assembly Language Programming

Machine Language vs. Assembly Language:

- Human language: Words and phrases - machine code: 1s and 0s. - For example:

ADD.B D2, D3

- ADD: arithmetic operation of addition - D2 & D3: Data Register 2 & Data Register 3. - Operation: Adds contents of D2 and D3, stores result in D3.

Page 3: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 3/94

The Assembler:

- Assembler: converts source file to object file. o single-line assemblers: translates one line at a time. o cross-assemblers: translates from high level languages to assembly language/

machine code. Source Program Assembly:

Figure 3.1: Source program assembly (pg37) [1]

Page 4: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 4/94

- Source file: Contains the program in assembly language. - Object file: Contains the program in binary codes.

o Contains additional info concerning program relocation & external references o 2 Files:

§ Even bytes § Odd Bytes

- List file: Program in both assembly and machine code. - Hex file: Machine code in hex.

Page 5: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 5/94

Example Program (List File):

D6 02 ADD.B D2, D3 ; add the lower byte of D2 to D3, result in D3 96 42 SUB.W D2, D3 ; subtract one word in D2 from D3, result in D3 C6 82 AND.L D2, D3 ; D3 equals ‘D2 logical AND with D3’ 42 02 CLR.B D2 ; clear lower byte of D2 52 03 ADDI.B #1, D3 ; add 1 to D3 36 02 MOVE.W D2, D3 ; put copy of D2 into D3

Page 6: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 6/94

Assembly Language Program Structure Example Program (Source File):

ORG $8000 TOTAL CLR.W D0 ;clear result

MOVE.B #16, D1 ;init loop counter MOVEA.L #DATA, A0 ;init data pointer

LOOP ADD.B (A0)+, D0 ;add data value to result SUBI.B #1, D1 ;decrement loop counter BNE LOOP MOVEA.L #SUM, A1 ;point to result storage MOVE.W DO, (A1) ;save sum RTS ;and return SUM DC.W 0 ;save room for result DATA DS.B 16 ;save room for 16 data bytes END

o Label (optional) o Instruction o Comment (optional)

Page 7: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 7/94

Example Program (List File):

008000 1 ORG $8000 008000 4240 2 TOTAL CLR.W D0 008002 123C 0010 3 MOVE.B #16, D1 008006 207C 0000 801E 4 MOVEA.L #DATA, A0 00800C D018 5 LOOP ADD.B (A0)+, D0 00800E 5301 6 SUBI.B #1, D1 008010 66FA 7 BNE LOOP 008012 227C 0000 801C 8 MOVEA.L #SUM, A1 008018 3280 9 MOVE.W D0, (A1) 00801A 4E75 10 RTS 00801C 0000 11 SUM DC.W 0 00801E ?? 12 DATA DS.B 16 00802E 13 END

Page 8: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 8/94

o ORG $8000: o TOTAL: o LOOP: o SUM, DATA: o MOVEA.L: o END:

Page 9: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 9/94

Revised Example Program (Source File): ORG $8000

SUM DC.W 0 ;save room for result DATA DS.B 16 ;save room for 16 data bytes ORG $8100 TOTAL CLR.W D0 ;clear result

MOVE.B #16, D1 ;init loop counter MOVEA.L #DATA, A0 ;init data pointer

LOOP ADD.B (A0)+, D0 ;add data value to result SUBI.B #1, D1 ;decrement loop counter BNE LOOP MOVEA.L #SUM, A1 ;point to result storage MOVE.W DO, (A1) ;save sum RTS ;and return END

Page 10: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 10/94

Figure 3.2: Memory Map (pg42) [1]

Page 11: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 11/94

Multiple Object Files:

Figure 3.3: Linking multiple object files (pg43) [1]

- Linker: combines multiple object files (modules/libraries). - Loader: loads the combined program into memory. - Link-Loader: combination of Linker & Loader.

Page 12: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 12/94

The ASM68K Compiler & EMU68K Emulator

- The ASM68K Compiler and EMU68K Emulator will be used as a learning tool for the Microprocessor Class.

- The compiler and emulator is provided with the adopted textbook for the course. - The two programs allow you to assemble and execute 68K programs on any IBM-

compatible personal computer.

Page 13: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 13/94

Instructions for using ASM68K Compiler & EMU68K Emulator

- Download the files from the web and store them on an IBM-compatible PC (Example: Save the files in “C:\MP”)

- Open a DOS command prompt window and change to the directory where the

compiler and emulator files are saved. (Example: Use the drive command “c:” to change to the C drive and then use the change directory command “cd mp” to change to the C:\MP directory)

Page 14: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 14/94

- Once you are in the same directory as the compiler, launch a text editor to type

your source file. Your source file must have the *.asm extension for the compiler to recognize it.

(Example: To use the edit command to create a file name called demo.asm, enter the command “edit demo.asm”. You will be directed into the DOS editor. Once you have completed typing your source file, you can save the file by going to the File Menu and selecting Save. The File Menu can be invoked by selecting the keys “Alt-F”, and the save command can then be selected by entering the “S” key or selecting the save command by using the up or down arrow keys. Once you have saved your file, you can exit the editor by selecting the exit command from the file menu)

Page 15: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 15/94

- Once you have created a source file, you can then compile it by using the compiler.

(Example: To compile the file “demo.asm”, at the DOS prompt enter the command “asm68k demo” and the compiler will search for a file named “demo.asm”. If there are no errors, then the compiler will create the list file “demo.lst”, the hex file “demo.hex”, and the object file “demo.obj”)

- After the file has been compiled, you can now launch the emulator program to

load the compiled source file. (For example, to run the compiled “demo.hex” source file, at the command prompt enter “emu68k demo”, and the emulator will search for a file named “demo.hex”. If the file exists, it will be loaded, else, the emulator will run without a file and you will need to load a file within the emulator. For example, to load the demo source file again, enter “L demo” at the emulator prompt.)

Page 16: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 16/94

- Once the file has by loaded, the emulator can then run the compiled source file and provide useful information such as the register map. For a complete list of instructions within the emulator, type “?”.

Author A Breakpoint B number (1-4) address (0 to disable) Dump D [address] [lines] Fill F start-address stop-address pattern-byte Enter E [address] (use <cr> to skip over a byte and any illegal key to exit) Go G [address] Help ? Hex H number1 number2 Load L filename Quit Q Register R [register] Trace T [address] , [lines] Example: T 400 (begin trace at $400) Example: T 400,5 (trace 5 inst. starting at $400) Example: T ,5 (trace next 5 inst. starting at PC) Unassemble U [address] , [lines]

Page 17: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 17/94

General ASM File:

- The program to be run by the EMU68K must contain the TRAP #9 instruction to return the control of the process to the emulator program.

- Without the TRAP #9 instruction, the program will no return the control to the emulator program and a fatal error might occur.

- Below is a sample of how the source file should begin and end to avoid the fatal error:

ORG $8500 ; For data storage … … …

ORG $8000 ; For program routine START … … … … … TRAP #9 END START

Page 18: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 18/94

Demo Program File:

- Let’s say we want to create the simple “Hello World” program in assembly language and run it on the emulator.

- Below is the content of the *.ASM source file. ORG $8000 MSG DC.B 'Hello World' DC.B 0 ORG $8100 START MOVEA.L #MSG, A3 TRAP #3 TRAP #9 END START

Page 19: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 19/94

- After compilation, the *.LST list file would contain the below: 008000 ORG $8000 008000 4865 6C6C 6F20 MSG DC.B 'Hello World' 008006 576F 726C 64 00800B 00 DC.B 0 008100 ORG $8100 008100 267C 0000 8000 START MOVEA.L #MSG, A3 008106 4E43 TRAP #3 008108 4E49 TRAP #9 00810A END START

- The first column is the set of memory locations where the instructions are stored.

The second column is the group of machine language bytes or words that represent the actual 68K instructions.

- Once the *.hex file has been loaded by the emulator, we can then enter “G $8100”

to run the program starting at $8100.

Page 20: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 20/94

Assembler Directives

- Assembler: 2 types of statement o Executable instruction:

§ uP’s valid instruction § Translated into machine code by assembler.

o Assembler directives:

§ Link symbolic names to values § Allocate storage § Setup predefined constants § Controls assembly process § TTL, EQU, DC, DS, ORG, INCLUDE, & END

Page 21: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 21/94

TTL - Title: Allows a user defined name at the top of each printout - The syntax for TTL is:

TTL <expression>

- Example (if we are writing a random number generator): TTL Random Number Generator

Page 22: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 22/94

EQU - Equates: Links a name (symbol) to a value.

- The syntax for EQU is: <Label> EQU <Operand>

- Example (if we want to assign CR the value of $0D):

CR EQU $0D

- Example: Much better to equate the name CR (carriage return) to $0D and use this name in a program than to write $0D and leave it to the reader to figure out that $0D is the ASCII value for carriage return.

Page 23: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 23/94

DC - Define Constant: Permit constants to be loaded into memory before the program is

executed. - Quantified by .B, .W, or .L

- The syntax for DC is:

<Label> DC.B <Operand(s)> <Label> DC.W <Operand(s)> <Label> DC.L <Operand(s)>

- Example:

POINT1 DC.B 3 THERE DC.L 256

Page 24: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 24/94

Example Program:

Figure: Examples of define constant directive (pg16) [2]

The effect of the directives above can be illustrated by the memory map shown on the next slide.

Page 25: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 25/94

Figure 2.1: Use of DC directive (pg17) [2]

Page 26: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 26/94

- Word boundaries (defined for successive words)

- Symbolic value/expression

Example Program:

Figure: Example of employing symbols in define constant directive (pg16) [2]

Page 27: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 27/94

DS - Define Storage: Reserves storage locations. - Similar to that of DC, but with no values.

- Quantified by .B, .W, and .L.

- The syntax for DS is:

<Label> DS.B <Operand(s)> <Label> DS.W <Operand(s)> <Label> DS.L <Operand(s)>

Page 28: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 28/94

Example Program:

Figure: Examples of define storage directive (pg16) [2]

- Left-hand column equates label with 1st address DS.

Page 29: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 29/94

ORG - Origin: Defines starting address of program segment. - Can be located at any point in a program. - The syntax for ORG is: - ORG <Operand>

Page 30: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 30/94

Example Program illustrating ORG, DS, DC, and EQU:

Figure: Example utilizing ORG, DS, DC, and EQU directives (pg18) [2]

Page 31: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 31/94

Figure 2.2: Memory map demonstrating application of ORG, DS, DC, and EQU directives (pg19) [2]

Page 32: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 32/94

Note: - Assembler directives are not instructions, hence we can use the ‘+’ operation. - It is possible to write an expression at any point in the assembler where a numeric

value must be provided. - Not necessary to allocate separate regions of memory for data and instructions.

Example: PIA EQU ACIA + 4 causes the word PIA to be equated to the value ACIA + 4 (=$008000 + 4 = $008004).

Page 33: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 33/94

INCLUDE - Loads a separate file and insert it in the current assembly. - Full path name of the file must be specified. - The syntax for INCLUDE is:

INCLUDE <file name>

Example (to include a file containing IO memory addresses into the current file): INCLUDE IOEQU.INC

Where IOEQU.INC contains the following: PGCR EQU $A00001 ; port general control register PSRR EQU $A00003 ; port service request register PADDR EQU $A00005 ; port A data direction register PBDDR EQU $A00007 ; port B data direction register PCDDR EQU $A00009 ; port C data direction register

Page 34: Lecture 4: Software Details of the 68000

Microprocessor System School of Engineering Prepared by Mr. Gilbert Thio (2004) UCSI

Unless otherwise specified, all materials and diagrams are adapted from the following sources:

1. Antonakos J.L., The 68000 Microprocessor, Hardware and Software Principles and Applications, 1993, Prentice Hall, New Jersey. 2. Clements A., Microprocessor Systems Design, 68000 Hardware, Software, and Interfacing, 1992 PWS-KENT Publishing, Massachusetts. MPS Software 002: 34/94

END - Informs the assembler that the end of a program has been reached and there are no

further instructions or directives to be assembled. - Any source code following an END directive will be cause an error. - The use of END is optional, assembly continues to the end of the source file if

END is absent.