Motorola M68000 Guide de l'utilisateur

Naviguer en ligne ou télécharger Guide de l'utilisateur pour Non Motorola M68000. Motorola M68000 User`s guide Manuel d'utilisatio

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 256
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs

Résumé du contenu

Page 1 - ^UcMttaL P. SizUuijeS i

GUAGE^UcMttaL P. SizUuijeS i

Page 2

vi il PrefaceOf special note is Appendix B, which provides program shells. These shells allow you to start programming with the Atari ST, t

Page 3 - THE 68000 FAMILY

86 Assembly Language Programming for the 68000 Family17. What are the general forms of the address register with index addressing mode?18. What r

Page 4

Addressing Modes 8714. A 16-bit signed number. This is —65,536 to +65,535.NAME:EQU0EMPNUM:EQU12SALARY:EQU16RECSIZ: EQU 1816. MOVE.W SALARY(A4)rD01

Page 6

CHAPTER 7THE STACKIn this chapter we will examine the hardware stack implementation on the 68000. A stack is a type of data structure. Computer scien

Page 7 - To my wife Linda

90 Assembly Language Programming for the 68000 FamilySP-HIGH ADDRESSLOU ADDRESSadded to the stack, the value of the stack pointer, SP, is decrement

Page 8

The 5tach 91would result in the following stack:SP1234HIGH ADDRESSLOW ADDRESSThe stack pointer always points to the top element on the stack. This

Page 9

92 Assembly Language Programming for the 68000 FamilyTo retrieve elements from the stack, we use a MOVE instruction with address register indirect

Page 10

The Stack 93the 68000 has no way of knowing how many valid elements are on the stack, it just obtains the element pointed to by the stack pointer. If

Page 11 - CONTENTS

94 Assembly Language Programming for the 68000 Familymore than once, which would wipe out the previous value before it was restored. This problem do

Page 12 - CHAPTER 8: Subroutines 99

The Stack 95They can be popped with:MOVEM.L (SP)+fD0-D5/A3-A6Just remember to make sure that the register lists match for the push and pop. If the w

Page 13 - Contents xl

CONTENTSINTRODUCTION 1CHAPTER 1: Number Systems 5Decimal 5Binary 6Conversions 6Hexadecimal 8Arithmetic in Binary and Hexadecimal 9Bits, Bytes

Page 14

96 Assembly Language Programming for the 68000 FamilyWhat happens if we do use a character code that appears in the string? When we try to reverse

Page 15 - INTRODUCTION

PEA COUNTMOVE.W #9,DOMOVE.L #1,D1NEXT: MOVE.L Dl,-(SP)ADDQ.L #1,D1DBRA DO,NEXTLOOP COUNT INITIAL DATA VALUE PUSH DATA ONTO STACK INCREMENT DATA

Page 17 - Introduction 3

CHAPTER 8SUBROUTINESWe often find that we are repeating the same sequence of instructions in several different parts of the program we are w

Page 18

100 Assembly Language Programming for the 68000 FamilyEach time we wished to perform this operation, we would have to repeat the above six instructi

Page 19 - NUMBER SYSTEMS

Subroutines 101JSR BIGEST JSR BIGESTEach time the JSR instruction is executed, the instructions of the subroutine BIGEST are executed. How does th

Page 20 - Conversions

102 Assembly Language Programming for the 68000 FamilyThe BSR instruction operates identically to the JSR instruction except that it has the same li

Page 21 - Number Systems 7

Subroutines 103different registers. This was also the case with BIGEST. For subroutines with a small number of parameters, the use of the registers i

Page 22 - Hexadecimal

104 Assembly Language Programming for the 68000 FamilyAO, one for the compare and possibly one for the move. If we postincrement on the compare, we

Page 23 - 2 gives us:

Subroutines 105ARG3: DS.L 1 ARG4: DS.L 1The MOVEA.L (A0),A1 instruction obtains each argument pointer in turn. Note also that the parameters ARG1

Page 24

x ContentsCHAPTER 4: Getting Started 41Data Movement 41Addition and Subtraction 44Input and Output 47The Program Shell 49Looping 50Putting It

Page 25 - Representing Negative Values

106 Assembly Language Programming for the 68000 Familyregisters must be popped in the reverse order from the pushes. The caller would save and resto

Page 26 - ASCII Character Codes

Subroutines 107HIGH RDDRESSLOW ADDRESSof course, SP. After the call, SP is pointing at the 32-bit return address value. The first parameter is loca

Page 27

108 Assembly Language Programming for the 68000 Familyreference. With call by reference, the address of the parameter is passed on the stack. This al

Page 28

Subroutines 109A unique method that you might come across is to use the LEA instruction:LEA 12(SP),SPThis method is reported to execute somewhat fa

Page 29 - 21. binary

110 Assembly Language Programming for the 68000 Familyoffsets will also change. What is needed is a method of anchoring our position in the stack

Page 30

Subroutines 111HOVEA.L A6,SP RTSAll of these operations are made simpler by using the LINK and UNLK instructions. These have the added

Page 31 - CHAPTER 2

112 Assembly Language Programming for the 68000 FamilyGAMMA: LINK A6,#-100MOVEM.L <regs>,-(sp)MOVEM.L (SP)+,<regs>UNLK A6RTSThe on

Page 32

Subroutines 1138. Write a subroutine called SUM that adds DO and Dl and returns the result in DO.9. Write a subroutine and its call that adds

Page 33

114 Assembly Language Programming for the 68000 FamilyAnswers1. Yes, but they are not exactly the same as the subroutines and procedures of high-le

Page 34

Subroutines 115ADDQ.LMOVEA.LADD.WMOVEM.LRTS#4/AO (AO),A1 (Al)/DO (SP)+/A0-A1-> 2ND. ARG RESTORE REGS121314.15.ARGLST :DC.L ADC.L BA: DC.WIB;DC.W

Page 35 - ADDRESS MEMORY

Contents xlSaving and Restoring the Registers 105Passing Parameters on the Stack 106Stack Frames 109Exercises 112Answers 114CHAPTER 9: Linked

Page 36

116 Assembly Language Programming for the 68000 Family20. A stack frame is an area of the stack used to pass parameters to a subroutine, save the

Page 37 - User and Supervisor Modes

CHAPTER 9LINKED LISTS— A PROGRAMMING EXAMPLEYou now have a considerable number of useful 68000 instructions in your repertoire, it would be nice to

Page 38 - The CPU Registers

118 Assembly Language Programming for the 68000 Familyin the correct location. There are many ways to obtain the storage for a node. One way is to

Page 39 - User Programmer's Model

Linked Lists—A Programming Example 119This subroutine merely uses the address contained in the head pointer FLIST as a pointer to the the node

Page 40 - Input/Output

120 Assembly Language Programming for the 68000 FamilyTST.B - 1 (AO) HAVE WE HIT A NULL?BNE STRCMP1 NOW MORE BYTES LEFTSTRRET: MOVEM.L (SP)+,A0

Page 41

Llnhed Lists—A Programming Example 121INSR: JSR NEWLINECLR.B (AO)CMP.B #CR,D0BNE INSR1CLR.B -1(AO)INSR1: MOVEM.L (SP)+,A0/D0-D1 RTSOUTPUT A N

Page 42

122 Assembly Language Programming for the 68000 FamilyINSAO: MOVEA.LA1,A2A2 -> PREVIOUS NODE LINKMOVE.L (Al),A1Al -> NEXT NODE LINKCMPA.L#0,A

Page 43 - ASSEMBLER SOURCE FORMAT

Linked Lists—A Programming Example 125eliminate the additions and subtractions used to obtain pointers to the data?To delete a node, we must kn

Page 44 - The Label Field

124 Assembly Language Programming for the 68000 Familyfigure 12 Deletion of a node.This is accomplished by the subroutine PLIST:********************

Page 45

Linked Lists—A Programming Example 125* COMPARE THE INPUT CHARACTER WITH ALL POSSIBLE SINGLE* CHARACTER COMMANDS AND BRANCH TO THE PROPER COMMAND*

Page 46 - The Operand Field

xli ContentsChapter 14: The 68020185Instruction Caching186Additional Addressing Modes188Instruction Extensions190New Instructions193Bit Field Instru

Page 47 - The Comment Field

126 Assembly Language Programming for the 68000 Family************************************************************* PROGRAM DATA******************

Page 48 - Constants

Linked Lists—A Programming Example 127INSERT, PRINT, DELETE, QUIT? I ENTER: CINSERT, PRINT, DELETE, QUIT? I ENTER: DINSERT, PRINT, DELET

Page 50 - Data-Defining Directives

CHAPTER 10LOGICAL, SHIFT AND ROTATE INSTRUCTIONSIn this chapter we will examine a group of instructions that can manipulate the individual bits of a

Page 51 - Symbol Equates

150 Assembly Language Programming for the 68000 FamilyOperand 1Operand 20100010 1ANDOR results in a 1 if either of the operand bits are a 1.Operan

Page 52 - The END Directive

Logical, Shift and Rotate Instructions 151AND[.<size>] ANDI.<size>] ANDII.<size>] OR I.<size>] 0R[.<size>] ORIt.<siz

Page 53 - Assembler Source Format 39

132 Assembly Language Programming for the 68000 FamilyEOR has the most interesting property in its use with a mask. Each bit set to 1 in the mask co

Page 54

Logical, Shift and Rotate Instructions 133for a right shift, orfor a left shift.You are probably wondering what happens to the bit that falls off th

Page 55 - Data Movement

154 Assembly Language Programming for the 68000 FamilyThe purpose of the arithmetic shift is to preserve the sign bit. You will recall that the sign

Page 56

Logical, Shift and Rotate Instructions 155will shift DO left by 10 bits. This will shift in 10 zeros, and the value in DO after the shift will

Page 57 - Getting Started 43

INTRODUCTIONWhy learn assembly language? Most people do so out of a need to perform programming tasks that are not easy, or not possible, with other

Page 58 - Addition and Subtraction

156 Assembly Language Programming for the 68000 Familywe always went through the loop 32 times. Also note that this routine does not check for ov

Page 59 - Getting 5tarted 45

Logical, Shift and Rotate Instructions 157The rotate instructions have the same format as the shift instructions.<rotate>[.<size>] Dx,Dy

Page 60

158 Assembly Language Programming for the 68000 Family<bitop> Dn,<ea><bitop> #<data>,<ea><bitop> = BTSTr BSET,

Page 61 - Input and Output

Logical, Shift and Rotate Instructions 15912. Write an instruction to perform a logical shift right by one bit of the DO register.13. Write the in

Page 62

140 Assembly Language Programming for the 68000 Family7. a) 7 b) 15 c) 318. Into the carry bit.9. The logical shift right shifts a zero in

Page 63 - The Program Shell

CHAPTER 11ADVANCED ARITHMETICIn Chapters 4 and 5 you learned the ADD, SUB, ADDQ, and SUBQ instructions. These instructions, along with the condition

Page 64

142 Assembly Language Programming for the 68000 Familysingle instruction. We can perform multiple precision operations by representing our numbers

Page 65 - Getting Started 51

Advanced Arithmetic 143the high-order longwords. The carry condition, C, is set/reset as a result of our first addition. All we have to do is somehow

Page 66

144 Assembly Language Programming for the 68000 FamilyMOVE.B A,Dl SUBX.B D1,D0 MOVE.B DO rCA: DC.B 3B : DC .B 3C: DC.B 3The use of a three-

Page 67 - Putting It All Together

Advanced Arithmetic 145ADDX.L -(A0),-(A1)RTSMoving the constant 4 into the CCR will clear all the bits except for the Z condition. Remember, when th

Page 68

2 Assembly Language Programming for the 68000 Familyform of text editor. It really doesn’t matter which editor you use as long as you can create a s

Page 69 - Getting 5tarted 55

146 Assembly Language Programming for the 68000 Familypair is used for signed values. Unlike addition and subtraction, signed and unsigned mul

Page 70 - 19. SUB.L D1,D0

Advanced Arithmetic 147The result is in Dl. The following instructions multiply word variables X and Y:MOVE.W X fD0 MULS Y,D0The result is in regis

Page 71 - CHAPTER 5

148 Assembly Language Programming for the 68000 FamilyWe can sign-extend a byte to a word, or a word to a longword, using the EXT instruction. The ge

Page 72 - The Carry Bit

Advanced Arithmetic 149Four bits are required to represent the digits 0 to 9. As you may recall, we can actually count up to 15 with four bits. That,

Page 73 - 110100000

150 Assembly Language Programming for the 68000 FamilyNotice that I cleared the extend bit and set the zero bit in the CCR prior to executing the BC

Page 74

Advanced Arithmetic 151JSR GETCGET A CHARCTERSOB.B # ' 0'/DOMAKE INTO DECIMALLSL.B #4,DOSHIFT INTO HIGH NIBBLEMOVE.L DO/-(SP) SAVE DOJSRGET

Page 75 - The Zero and negative Bits

152 Assembly Language Programming for the 68000 Familythe result is the nine’s complement. This instruction can also be thought of as subtracting the

Page 76 - Com parisons

Advanced Arithmetic 1537. What is the precision of the result of a multiplication?8. What is the sign of the remainder in signed division?9. Where

Page 77

154 Assembly Language Programming for the 68000 Family9. The remainder is located in the high-order word of the destination register.HOVE.BNUH1,D0E

Page 78 - BLE LABEL

C/MPTER 12EXCEPTION PROCESSING, SYSTEM CONTROL OPERATIONS, AND I/OIn this chapter we will cover a number of topics and instructions that d

Page 79

Introduction 3Step One. Text EditingStep Two. AssemblyFigure 1 Assembler Operation.In Chapter 11 will review number systems. If you are an experienc

Page 80 - ADDQ and SUBQ Instructions

156 Assembly Language Programming for the 68000 FamilyStatus Register15 13System Byte-10User Byte 4TS12 11 10CCRInterrupt Mask Supervisor State Trac

Page 81 - MOVE.L #100,DO

Exception Processing, System Control Operations, and I/O 157ANDI tXXX,CCR EORI #xxx,CCR ORI #XXX,CCRNotice that the MOVE from SR instruction is u

Page 82

158 Assembly Language Programming for the 68000 FamilyThere is one more instruction that should be mentioned before going on to exceptions. Recall fr

Page 83

Exception Processing, System Control Operations, and I/O 159VectorNumberls)DecAddressHex SpaceAssignment00 000SPReset: Initial SSP?14004SPReset: I

Page 84 - BGE LABEL

160 Assembly Language Programming for the 68000 FamilyS bit in the status register. The tracing bit, T, is negated to prevent tracing. If the excepti

Page 85 - ADDRESSING MODES

Exception Processing, System Control Operations, and I/O 161PC location. Normally this is to an area of read only memory (ROM) that contains a small

Page 86 - Im mediate Data

162 Assembly Language Programming for the 68000 Family1. Execution of the TRAP instruction will result in the CPU being placed into superv

Page 87 - Absolute Addressing

Exception Processing, System Control Operations, and I/O 163multi-user, it might not allow a user to do anything in supervisor mode. This is not a di

Page 88 - Address Register Indirect

164 Assembly Language Programming for the 68000 Familyserial and parallel refer to the methods used to transfer data from the input/output device t

Page 89 - Addressing Modes 75

Exception Processing, System Control Operations, and I/O 165count up the number of data bits that are ones. We include the parity bit, but not the st

Page 91 - Addressing Modes 77

166 Assembly Language Programming for the 68000 FamilyStatus RegisterIRQPE 0VRNFE CTS DCDTDRE RDRFL Recv. Data Reg. Full— Xmit. Data Reg. Empt

Page 92

Exception Processing, System Control Operations, and I/O 167errors. If RDRF is set to a one, we have an input character already to be picked up. This

Page 93 - Addressing Modes 79

168 Assembly Language Programming for the 68000 Familythe main program. Many textbooks on systems programming or operating system techniques descri

Page 94

Exception Processing, System Control Operations, and I/O 16931 24Register Contents 23 1G 15 07 0hi-orderlow-orderContents of Memory15B 70hi-ord

Page 95 - Addressing Modes 81

170 Assembly Language Programming for the 68000 Familyset operation can be performed in an indivisible manner. In other words, only one CPU at a ti

Page 96

Exception Processing, System Control Operations, and I/O 17113. What exception vectors are associated with the TRAP instruction?14. Is an exception

Page 97 - Addressing Modes 83

172 Assembly Language Programming for the 68000 Family16. No, any memory reference instruction can be used, since the 68000 employs memory-mapped I

Page 98 - Addressing Mode Summary

C m P T f fl 15THE 68010The MC68010 is the next step up the ladder in the 68000 family. This microprocessor is not radically different from the 68000

Page 99

174 Assembly Language Programming for the 68000 Familygenerates a bus error on the destination operand, MEMLOC.MOVE.L (AO)+,MEMLOCIf we try to re-ex

Page 100

The 68010 175the tenth word in the virtual page corresponds to the tenth word in the physical page. Since the virtual address space is normally much

Page 101 - Addressing Modes 87

c m r r m 1NUMBER SYSTEMSThroughout history mankind has used a variety of methods to represent numerical quantities. Early man used piles of stones

Page 102

176 Assembly Language Programming for the 68000 FamilyVirtual Address SpacePhysical Memorypage framesFigure 15 Virtual memory mapping.addresses. T

Page 103 - Stack Instructions

The 68010 177MOVE SR,<ea>to examine the processor state. This instruction is not privileged on the 68000. The user could then tell that she wa

Page 104 - LOU ADDRESS

178 Assembly Language Programming for the 68000 Familyinstructions to be used in conjunction with the function class output lines. A source function

Page 105 - The 5tach 91

The 68010 179MOVE.L #$4000,DO M0VEC DO,VBRThe VBR can be used for many purposes. The implementation of a virtual machine is made much

Page 106 - LOW ADDRESS

I180 Assembly Language Programming for the 68000 Familythe speed of execution of an instruction. As I mentioned in Chapter2, a CPU requ

Page 107 - Stack Applications

The 68010 181You may recall that the DBcc instruction on the 68000 first checks the terminating condition. If it is true, execution continues w

Page 108

182 Assembly Language Programming for the 68000 Family3. In what way does the 68010 handle bus errors differently than the 68000?4. What is the p

Page 109 - The Stack 95

The 68010 18311. The SFC (source function code) register and the DFC (destination function code) register.12. MOVE.L #5, DO MOVEC DO ,SFC MOVE

Page 111 - PEA COUNT

CHAPTER 1 4THE 68020The MC68020 is a dramatically improved member of the 68000 family with a plethora of new features. Not only is the basic core per

Page 113 - CHAPTER 8

6 Assembly Language Programming for the 68000 FamilyBinaryVirtually all computers use 2 as the base for numerical quantities. The choice of 2

Page 114

186 Assembly Language Programming for the 68000 FamilyInstruction CachingBesides using full 32-bit operands both internally and via the data bus,

Page 115 - Subroutines 101

The 68020 187MC68020 Prefetch AddressFF FAA AA A AAAAAAA AA A A AAAA A A AAAC C C3 • •• 2 2 2 211111111 1 10 0 00 0 0 0 00 0210132109876543 21

Page 116 - Passing Param eters

188 Assembly Language Programming for the 68000 FamilyMOVE.L #1,D0 MOVEC DO/CACRdoes the job nicely. The other bits can be manipulated in a simila

Page 117 - Subroutines 103

The 68020 189For these two basic 68000 modes, the effective address is computed by taking the address register or program counter and adding the con

Page 118 - ARG2: DS.L

190 Assembly Language Programming for the 68000 Familyrect mode. The new 68020 modes make this operation a thing of the past. Figure 17 shows the c

Page 119 - Subroutines 105

The 68020 191Generation: EA = (bd + An) + Xn.SIZE*SCALE + odAssembler Syntax: ([bd,An],Xn.SIZE*SCALE,od)Mode:Base Displacement:Index Register: Scal

Page 120

192 Assembly Language Programming for the 68000 FamilyThe CMPI and TST instructions now allow all of the PC relative addressing modes. Ho

Page 121 - Subroutines 107

The 68020 193format that must be used. For example, to sign-extend the byte in DO, you would issue an EXTB.L DO instruction.The LINK instruction was

Page 122 - ADDA. L # 1 2 ,SP

194 Assembly Language Programming for the 68000 Familyon the data lines that is executed in place of the BKPT. If the external hardware is not prese

Page 123 - Stack Fram es

The 68020 19531 28 23 15 0Base- *+ $04+ $08+ $0C+ $10Figure 18 Module descriptor format (Courtesy of Motorola, Inc)immediate operand specifying

Page 124 - ID BYTES OF LOCALS

Number Systems 7We can look for the highest power of two that is not greater than the decimal number, place a 1 in the equivalent bit position, and t

Page 125 - Subroutines 111

196 Assembly Language Programming for the 68000 FamilySP —+ $08 + $0C + $10 + $14 + $1815Opt12Type Saved Access LevelCondition CodesArgument Coun

Page 126

The 68020 197MOVE.W SEM,DO LOOP: MOVE.W DO,Dl ADDQ.W #1,D1 CAS.W DO/DlfSEM BNE LOOPThe CAS2 instruction operates in a similar manner to the CAS

Page 127 - Subroutines 113

198 Assembly Language Programming for the 68000 Familyjunction with the main CPU chip to provide additional features not available on the main CPU.

Page 128

The 68020 199PACK -(AO),-(Al),#-$3030UNPK has the following identical general forms:UNPK -(Ax) ,-(Ay), #<adjustirent>UNPK Dx,Dy,#<adjusti

Page 129 - Subroutines 115

200 Assembly Language Programming for the 68000 Family4. Can word or longword data begin on an odd address boundary when using the 68020?5. What is

Page 130

The 68020 2016. 256 bytes.7. 32 bits.8. The cache control register, CACR, and the cache address register, CAAR.9. The cache must be cleared so

Page 132

CHAPTER 15THE 68030In the latter part of 1986 Motorola announced its latest member of the 68000 family, the MC68030. This new super chip should be

Page 133

204 Assembly Language Programming for the 68000 FamilyFigure 21 68030 Block diagram. (Courtesy of Motorola, Inc.)Instruction and Data C achesFigure

Page 134

The 68030 205ACCESS ADDRESSC C C 3 222 2 111111111 0 00 00 000 0 02 1 013210967654320 9 67 65 432 1 0TAGINDEXM10F18SELECTi rLONG WORD SELECTJ-----

Page 135

8 Assembly Language Programming for the 68000 FamilyHexadecimalHexadecimal, or base 16, uses positional values that are powers of 16. Each hex digit

Page 136

206 Assembly Language Programming for the 68000 FamilyPipelined ArchitecturePipelining is a technique used on high performance CPU’s such as main

Page 137

The 68030 207easy to take a binary logical address and partition it into a page number and an offset within the page.Logical Address (example)31 10

Page 138

208 Assembly Language Programming for the 68000 FamilyVFrame no.0 1231 1 122103 0-4 1 1235some thought is given to this process. First, if the page

Page 139 - * Q

The 68030 209tables, Motorola’s terms for the entries of a page table, translation descriptors, and for an individual table in the tree, de

Page 140

210 Assembly Language Programming for the 68000 FamilyB-level tablesFigure 23 Example address translation tree.non-existent table or page, the o

Page 141

The 68030 21116 15] A7 (ISP) tNTERRUPTSTACK POINTER16 15 0MASTERAT* (MSP) STACK POtNTER67 0(CCR) SR STATUS REGISTER0H VBR VECTOR BASE REGI

Page 142

212 Assembly Language Programming for the 68000 FamilyPLOAD Takes a virtual address and searches the translation tree for the correspondi

Page 143 - CHAPTER 10

The 68030 2133. Each cache is 256 bytes.4. A write-through is used. Whenever a data location is modified in the cache, it is also modified in the c

Page 145 - 01000100

cir012345678910111213141516171819202122232425262728293031APPENDIX AASCII CHARACTER CODESOctal HexASCIIDecimalOctalHex ASCII000 00NUL 3204020 SP001 01

Page 146

Mumber 5ystems 9To convert from hex to binary we merely write the equivalent of each hex digit in binary. To convert 6E3Cie to binary we would write:

Page 147 - LSL'ASL

216 Assembly Language Programming for the 68000 FamilyDecimalOctalHex ASCIIDecimalOctalHexASCII64100 40<S>96 140 60*65101 41 A97 14161 a66 102

Page 148

APPENDIX BPROGRAM SHELLS AND I/O SUBROUTINESShell foe the Atari ST computers.textYour program goes here <PROGRAM>Return to system.fini: move.w

Page 149

218 Assembly Language Programming for the 68000 Familymovem.l (sp)+,dl-d2 rtsrestore registers returnThe following subroutine to output a decimal n

Page 150

Appendix B 219**********************************************Amiga shell - This must run under the CLI Link with amiga.lib* You may have to modify the

Page 151 - Bit Manipulation

220 Assembly Language Programming for the 68000 Familyrtsputc: movem.l d0-d7/a0-a6,-(sp) move.b dO,buff move.l console/dl move.l #buff,d2 moveq.l

Page 152 - BTSTr BSET, BCLR, BCBG

Appendix B 221move.wd3,d0 get old remainder in low order wordswapdO fix up so result is full 32 bit quotientbraoutdecOdivide by ten again*we now o

Page 153 - Operand 2

222 Assembly Language Programming for the 68000 Family; Macintosh shell.;****************************************t; The following include files ac

Page 154

Appendix B 225Start: movem.l d0-d7/a0-a6,-(sp) pea -4(a5)_InitGraf _InitPonts _InitWindows _InitMenua clr.l -(sp)_InitDialogsJTEInit_InitCursorlea

Page 155 - CHAPTER 11

224 Assembly Language Programming for the 68000 Familymove.wmovemove_M0VET0movem.1rtsdO,(aO)#LMARG,-(sp) #TMARG,-(sp)(sp)+,d0-d2,a0-alFLASHTIME equ

Page 156

Appendix B 225bnecmpi.w beq leamove.w neg.w move.w move.w _MOVE move.w move.w add.w move.w sub.w sub.w move.w move.w move.1 move.1 _ERASERECTputcl IL

Page 157 - Advanced Arithmetic 143

10 Assembly Language Programming for the 68000 Familyor hexadecimal55P2- 4A630B8FHand calculations involving multiplication or division are rarely pe

Page 158

226 Assembly Language Programming for the 68000 Familyi performed to allow a full 32 bit number to be entered.;indec: movem.l clr.l indecO: jsrs

Page 159 - Multiplication and Division

Appendix B 227jsr putc move,l (sp)+,dO rtsend/restore <30 /return

Page 161 - Advanced Arithmetic 147

APPEHDIX C68000-68020 INSTRUCTION SUMMARYMnemonicAddr Modes: Src DestSizeAttributesCond. Codes X N Z V CDescriptionABCD DnDnBS 0 S 0 sAdd Decima

Page 162 - Decimal Arithmetic

230 Assembly Language Programming for the 68000 FamilyCLR<dea> Alterableb.w .l0 0 0 00Clear OperandCMP<ea>DnB.W.L*10 S S S SCompareC

Page 163 - Advanced Arithmetic 149

Appendix C 251MOVEQ#dDn L0 S S 0 0Move QuickMOVES RnDFC<mea> AltrblB.W.L*8 P 00000Move Addr SpaceSFC<mea> Altrbl RnB.W.L*8 P 0 0

Page 164

252 Assembly Language Programming for the 68000 FamilyTST <dea> AlterableUNLK AnUNPACK -(An),-(An),#<adjstmnt>UNPK Dn,Dn,#<adjstmn

Page 165 - 10000 0000

Appendix C 233Addressing Mode Descriptions:<ea> - effective address<rea> - register effective address<dea> - data effective address

Page 167 - Advanced Arithmetic 153

INDEX# , 43, 73 *, 34, 79 ABCD, 149absolute addressing, 73-74access rights, 194ACIA, 163-68ADD, 45ADDA, 46ADDI, 46addition, 44-46addition and subtract

Page 168

Humber 5ystems 11Representing Negative ValuesSo far in our discussion of number representations, we have only been dealing with positive nu

Page 169 - OPERATIONS, AND I/O

236 IndexBSET, 137 BSR, 99,102,190 BTST, 137 bus, 19 asynchronous, 19 error, 161,173-76 busy wait, 170 BVC, 61 BVS, 61 byte, 10, 21C language, 77,

Page 170

Index 237EXG, 44 EXT, 148,192 extend bit, 62 condition, 143fields, source statement, 29 FORTRAN, 37, 99 forward reference, 37, 84 framing, 164 func

Page 171 - OVERFLOW FLAG BYTE

238 IndexNBCD, 149,151 negative numbers, 11-12 NEGX, 143 NEWLINE, 48 nibble, 149 NOP, 168 NOT, 129-131object code, 2 one’s complement, 11 opcode,

Page 172 - Exception Processing

Index 239shift instructions, 129,133-36 used to multiply and divide, 135 sign bit, 11, 58 magnitude, 11 68000 family, 17-21 size, of operands, 41 SLE

Page 175 - TRAP #<vector>

COMPUTERSFor 68000 series chip u s a ^h ere ’s the fast, easy way to learn assembly lcU|^^feprogramming skills.ASSEPSGUAGEIfcLG^ U a m a i P.This

Page 176 - CHK <ea>,Dn

12 Assembly Language Programming for the 68000 Family10011100 + 0000000110011101Let’s convert 8910 to —8910 using two’s complement. First we mus

Page 177 - Serial I/O

Mumber Systems 13terminals. The IBM PC, which does not use the 68000, makes extensive use of such an extended character set. You should be aware that

Page 178 - I I I I I I I I I I

14 Assembly Language Programming for the 68000 Family20. Hexadecimal numbers use what number base?21. What number base is used internally by the 68

Page 179

fiumber Systems 1519. decimal, binary and hexadecimal20. 1621. binary22.a) 110010002; C816b) 1012; 5„c) lllllOllllOlOOOj; FDE81623. a) 213 b

Page 180

A55EMBLY LANGUAGE PROGRAMMING TOR THE 68000 FAMILY

Page 182 - Miscellaneous Instructions

CHAPTER 2MICROCOMPUTER ARCHITECTUREBefore we begin to discuss assembly language, we should take time to explore the world of the microcomputer. Just w

Page 183

18 Assembly Language Programming for the 68000 FamilyFigure 2 Organization of a simple microcomputer system.the M6800 family. The MC6800 is strictly

Page 184

Microcomputer Architecture 19be modified by hand to allow for the differences in architectures. This scheme did have the advantage that it allowed so

Page 185 - 8. l e a u s t a c k ,a o

20 Assembly Language Programming for the 68000 Familynal rate at which operations are performed. The basic interval between clock pulses is the cycle

Page 186

Microcomputer Architecture 21operations allow manipulation of the individual bits of the data. You will soon see how logical operations can be very u

Page 187 - C m P T f fl 15

22 Assembly Language Programming for the 68000 Familymer from having to worry about the exact representation of instructions and data in memory. Ho

Page 188 - MOVE.L (AO)+,MEMLOC

Microcomputer Architecture 23instruction is. Many instructions are actually represented by several different opcodes, each specifying a different ve

Page 189 - Virtual Machines

24 Assembly Language Programming for the 68000 Familyuser/supervisor mode information on every reference to memory. If the system is so designed, ce

Page 190 - Physical Memory

Microcomputer Architecture 25memory. If an instruction causes a branch to a part of the program other than the next sequential instruction, the PC wi

Page 191 - Reference Classifications

Related Titles of Interest from John Wiley & SonsPROGRAMMING WITH MACINTOSH PASCAL, SwanEXCEL: A POWER USER’S GUIDE, HodgkinsJAZZ AT WORK, Venit &

Page 192 - The Vector Base Register

26 Assembly Language Programming for the 68000 FamilyInput/OutputIt may come as a surprise to you that the 68000 does not have any input

Page 193 - RTD and Loop Mode

Microcomputer Architecture 27Answers1. CPU, memory, and I/O.2. The MC68000 transfers two bytes of data to and from memory, while the MC68008 only t

Page 195 - Summ ary

CHAPTER 3ASSEMBLER SOURCE FORMATThere are many assemblers available for the 68000 family. They differ from each other in minor ways. It would be virtu

Page 196 - PC0, FC1, and FC2

30 Assembly Language Programming for the 68000 Familyas a field separator; most assemblers also recognize the tab character as a field separator, and

Page 197 - The 68010 183

Assembler 5ource Format 31★PROGRAM TO ECHO A LINETEXTS T A R T : LEABUFFER,AOINITIALIZE BUFFER POINTERLOOP:JSR GETCGET A CHARACTERM O V E .BD

Page 198

52 Assembly Language Programming for the 68000 FamilyA symbol in the label field can be made to equal a numeric constant. Anywhere this symbol appear

Page 199 - CHAPTER 1 4

Assembler Source Format 33are allowed by all assemblers. The characters +, —, and / are interpreted as addition, subtraction, multiplication, and

Page 200 - Instruction Caching

34 Assembly Language Programming for the 68000 Familyline, you must use an asterisk in column 1. You can see the comments in Figure 6.On Choosing Sym

Page 201 - The 68020 187

Assembler Source Format 35we can use are:Indicator Base% 2 @ 8 [none] 10 $ 16A binary constant would naturally consist of a percent sign followe

Page 202 - Additional Addressing Modes

ASSEMBLY LANGUAGE PROGRAMMING FOR TNE 68000 FAMILYThomas P. SkinnerJohn Wiley & Sons, Inc.New York • Chichester • Brisbane • Toronto • Sin

Page 203 - MOVE.L (0,A0,D0.W*4),D1

36 Assembly Language Programming for the 68000 FamilyData-Defining DirectivesBefore we cover the specific instructions of the 68000, it is important

Page 204 - Instruction Extensions

Assembler Source Format 37Sometimes we desire to reserve a location in memory for some data whose value is not known at assembly time. Rather than pl

Page 205 - The 68020 191

58 Assembly Language Programming for the 68000 Family<exp> is any legal expression as long as it does not contain any undefined symbols. Symbo

Page 206

Assembler Source Format 3915. Indicate which of the following are legal constants:12345 $ABCD @F00 $345 @77716. What is the character string co

Page 208

CHAPTER 4GETTING STARTEDIn order to write a program in assembly language, you must develop a familiarity with the machine instructions of the 68000. T

Page 209 - The 68020 195

42 Assembly Language Programming for the 68000 Familywithout having to remember different mnemonics for all these instructions.The general form of

Page 210 - CAS Dc,Du,<ea>

Getting Started 43of subtle errors that are hard to debug. If you must perform a move between two data elements of different lengths, there a

Page 211 - The 68020 197

44 Assembly Language Programming for the 68000 FamilyUnfortunately these two instructions do not accomplish the desired result. The first MOVE instr

Page 212

Getting 5tarted 45actually perform meaningful tasks. The general form of the add and subtract instructions are:[<label>] ADD[.<si

Page 213

Intel is a trademark oflntel Corporation.Amiga is a trademark of Commodore International.Apple and Macintosh are trademarks of Apple Computer, Inc.Ata

Page 214

46 Assembly Language Programming for the 68000 Familytion; in this case the destination operand is only a single byte. However, if a one-byte constan

Page 215 - The 68020 201

Getting Started 47MOVE DO,AOthe assembler would use the MOVEA form of the instruction. Check your assembler manual to be sure you can do this. Even

Page 216

48 Assembly Language Programming for the 68000 Familyterminal. Normally, some degree of hardware independence is provided by the operating system be

Page 217 - CHAPTER 15

Getting Started 495. PUTC—Output a single character to the screen. The character is taken from the low-order eight bits of register DO.In orde

Page 218 - Instruction and Data C aches

50 Assembly Language Programming for the 68000 Familytion, STOP, but if this instruction is used to terminate your program, the microprocessor will

Page 219 - The 68030 205

Getting Started 51Any number of instructions can be contained within the loop. Here is a simple program that will obtain a number from the terminal,

Page 220 - Paged Memory Management

52 Assembly Language Programming for the 68000 Familyinitializing Dn to —1 results in repeating the loop the maximum number of times—65,536, to be ex

Page 221 - requires 10 bits, leaving

Getting Started 53SPA CE: EQU$2 0*MOVE•W# 3 0 ,D1MLOOP:MOVE•LEXP,DOJS ROUTDECADDQ.L# 1 ,E X PMOVE•B# SPACE,DOJS RPUTCMOVE•LPOWER,DOJS ROUTDECAD D.L D

Page 222

54 Assembly Language Programming for the 68000 Family1 22 43 84 165 326 647 1288 2569 51210 102411 204812 409613 819214 1638415 32768

Page 223 - The 68030 209

Getting 5tarted 55Answers1. HOVE.L D0/D12. HOVE.B DO,SAMPLE3. No, a constant can’t be a destination operand.4. No, the constant is larger than a

Page 224 - B-level tables

*To my wife Linda

Page 225 - 68030 Instructions

56 Assembly Language Programming for the 68000 Family17.NEXT:CLR.LMOVE.LMOVE.WADD.LADD.LDBRAJSRJSRDO#1,D1 #99,D2 D1 / DO #1 ,D1 D2,NEXT OUTDEC NEWLI

Page 226

CHAPTER 5CONDITIONAL AND ARITHMETIC INSTRUCTIONSIn Chapter 4 you learned a small number of 68000 instructions. These were enough to write some very si

Page 227 - The 68030 213

58 Assembly Language Programming for the 68000 Familyway as the other registers. We don’t treat the contents of the CCR as a numeric quantity. Inst

Page 228

Conditional and Arithmetic Instructions 59destination register. For example, the addition of the following unsigned 8-bit binary numbers results in

Page 229 - ASCII CHARACTER CODES

60 Assembly Language Programming for the 68000 Familyhave the JMP instruction actually jump to the target label. Here's how it’s done.BCS CLO

Page 230

Conditional and Arithmetic Instructions 61The Overflow BitWhat if we were adding signed numbers? A carry out of the high-order bit is not necessaril

Page 231 - I/O SUBROUTINES

62 Assembly Language Programming for the 68000 FamilyMOVE.L #10,DO NEXT: JSR OUTDEC JSR NEWLINE SUB.L #1,D0 BNE NEXTThe programmer may also wa

Page 232 - ! tSt.l dO

Conditional and Arithmetic Instructions 63values such as ASCII characters. One way to perform a comparison would be to subtract the two numbers and

Page 233 - Appendix B 219

64 Assembly Language Programming for the 68000 Familynot equal, it is sometimes difficult to remember which value should be the source and which valu

Page 234

Conditional and Arithmetic Instructions 65FINI: MOVE.L Dl,D0 JSR OUTDEC JSR NEWLINEMOVE•L D0,D1 BRA NEXTYES, SAVE AS NEW VAL BACK FOR NEXT VA

Page 236 - ;plain style

66 Assembly Language Programming for the 68000 FamilyMany assemblers will allow the use of the CMP mnemonic for all variations of the CMP ins

Page 237 - Appendix B 225

Conditional and Arithmetic Instructions 67referencing an address register. However, only word and longword forms of the instruction can be used wit

Page 238 - ; return;

68 Assembly Language Programming for the 68000 FamilyExercisesAssume longword operands unless otherwise specified.1. What CCR bit is used to

Page 239

Conditional and Arithmetic Instructions 6920. Can MOVEQ be used to load only the low-order byte of a data register?Answers1. The carry

Page 240

70 Assembly Language Programming for the 68000 Family17. SUB.W tlrDO ASSUME COUNT IN DO BGE LABEL18. The extend bit is used for multiple preci

Page 241 - Appendix B 227

a 1APTER 6ADDRESSING MODESThe majority of 68000 instructions have one or more operands. An operand is used either as a source operand or a destin

Page 242

72 Assembly Language Programming for the 68000 FamilyThe 68000 has a total of 12 different addressing modes. This may seem like a lot, but n

Page 243 - 68000-68020

Addressing Modes 73least one word of memory. If we have an immediate operand, this immediate constant data is placed in one or two succ

Page 244 - 0 S 0 S

74 Assembly Language Programming for the 68000 Familyword. This is similar to the technique used with immediate addressing, but these words are an

Page 245

Addressing Modes 75this memory address at program execution time, we could reference data using this address value rather than a symbol. Thi

Page 246 - 00000 UnPack BCD

>PREFACEThis book deals specifically with the Motorola 68000 family of microprocessors. It is primarily about assembly language programmi

Page 247 - Appendix C 233

76 Assembly Language Programming for the 68000 FamilyThe LEA instruction takes the address of COUNT, not the value at location COUNT, and

Page 248

Addressing Modes 77Address Register Indirect With Postincrem entThis addressing mode works exactly the same way as address register indirect except

Page 249

78 Assembly Language Programming for the 68000 FamilyLOOPsPINILEA MOVE.B BEQ JSR BRASTR,A0(A0)+,D0PINIPUTCLOOPGET ADDRESS OF STRING GET NEXT CHARACT

Page 250 - 236 Index

Addressing Modes 79the second string is the same length as the first. If it is not, then the first string would be a substring of the second and the

Page 251 - Index 237

80 Assembly Language Programming for the 68000 FamilyLEA BLOCK,AOADDQ.L §2,AO ADJUST BY ONE WORDMOVE.W -(AO),DO GETS DATA ELEMENT INTO DODS.W

Page 252 - 238 Index

Addressing Modes 81not a label used on a memory location. Although some assemblers may allow you to assemble the following:MOVE.L ARRAY(AO),DOARRAY:

Page 253 - Index 239

82 Assembly Language Programming for the 68000 FamilyADDA.L #RECSIZ,A0 GET NEXT RECORDBRA LOOP BACK FOR MOREFINI:Notice that the age is not add

Page 254

Addressing Modes 83of the data item. In order to determine the address of the row, a value must be added to the address of the array that is equal to

Page 255

84 Assembly Language Programming for the 68000 Familyfact, we can let the assembler do the work for us. By specifying a label for the displacement, t

Page 256 - ^ U a m a i P

Addressing Modes 85Data Register DirectAddress Register DirectAddress Register IndirectAddress Register Indirect with PostincrementAddress Regi

Commentaires sur ces manuels

Pas de commentaire