GUAGE^UcMttaL P. SizUuijeS i
vi il PrefaceOf special note is Appendix B, which provides program shells. These shells allow you to start programming with the Atari ST, t
86 Assembly Language Programming for the 68000 Family17. What are the general forms of the address register with index addressing mode?18. What r
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
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
90 Assembly Language Programming for the 68000 FamilySP-HIGH ADDRESSLOU ADDRESSadded to the stack, the value of the stack pointer, SP, is decrement
The 5tach 91would result in the following stack:SP1234HIGH ADDRESSLOW ADDRESSThe stack pointer always points to the top element on the stack. This
92 Assembly Language Programming for the 68000 FamilyTo retrieve elements from the stack, we use a MOVE instruction with address register indirect
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
94 Assembly Language Programming for the 68000 Familymore than once, which would wipe out the previous value before it was restored. This problem do
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
CONTENTSINTRODUCTION 1CHAPTER 1: Number Systems 5Decimal 5Binary 6Conversions 6Hexadecimal 8Arithmetic in Binary and Hexadecimal 9Bits, Bytes
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
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
CHAPTER 8SUBROUTINESWe often find that we are repeating the same sequence of instructions in several different parts of the program we are w
100 Assembly Language Programming for the 68000 FamilyEach time we wished to perform this operation, we would have to repeat the above six instructi
Subroutines 101JSR BIGEST JSR BIGESTEach time the JSR instruction is executed, the instructions of the subroutine BIGEST are executed. How does th
102 Assembly Language Programming for the 68000 FamilyThe BSR instruction operates identically to the JSR instruction except that it has the same li
Subroutines 103different registers. This was also the case with BIGEST. For subroutines with a small number of parameters, the use of the registers i
104 Assembly Language Programming for the 68000 FamilyAO, one for the compare and possibly one for the move. If we postincrement on the compare, we
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
x ContentsCHAPTER 4: Getting Started 41Data Movement 41Addition and Subtraction 44Input and Output 47The Program Shell 49Looping 50Putting It
106 Assembly Language Programming for the 68000 Familyregisters must be popped in the reverse order from the pushes. The caller would save and resto
Subroutines 107HIGH RDDRESSLOW ADDRESSof course, SP. After the call, SP is pointing at the 32-bit return address value. The first parameter is loca
108 Assembly Language Programming for the 68000 Familyreference. With call by reference, the address of the parameter is passed on the stack. This al
Subroutines 109A unique method that you might come across is to use the LEA instruction:LEA 12(SP),SPThis method is reported to execute somewhat fa
110 Assembly Language Programming for the 68000 Familyoffsets will also change. What is needed is a method of anchoring our position in the stack
Subroutines 111HOVEA.L A6,SP RTSAll of these operations are made simpler by using the LINK and UNLK instructions. These have the added
112 Assembly Language Programming for the 68000 FamilyGAMMA: LINK A6,#-100MOVEM.L <regs>,-(sp)MOVEM.L (SP)+,<regs>UNLK A6RTSThe on
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
114 Assembly Language Programming for the 68000 FamilyAnswers1. Yes, but they are not exactly the same as the subroutines and procedures of high-le
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
Contents xlSaving and Restoring the Registers 105Passing Parameters on the Stack 106Stack Frames 109Exercises 112Answers 114CHAPTER 9: Linked
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
CHAPTER 9LINKED LISTS— A PROGRAMMING EXAMPLEYou now have a considerable number of useful 68000 instructions in your repertoire, it would be nice to
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
Linked Lists—A Programming Example 119This subroutine merely uses the address contained in the head pointer FLIST as a pointer to the the node
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
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
122 Assembly Language Programming for the 68000 FamilyINSAO: MOVEA.LA1,A2A2 -> PREVIOUS NODE LINKMOVE.L (Al),A1Al -> NEXT NODE LINKCMPA.L#0,A
Linked Lists—A Programming Example 125eliminate the additions and subtractions used to obtain pointers to the data?To delete a node, we must kn
124 Assembly Language Programming for the 68000 Familyfigure 12 Deletion of a node.This is accomplished by the subroutine PLIST:********************
Linked Lists—A Programming Example 125* COMPARE THE INPUT CHARACTER WITH ALL POSSIBLE SINGLE* CHARACTER COMMANDS AND BRANCH TO THE PROPER COMMAND*
xli ContentsChapter 14: The 68020185Instruction Caching186Additional Addressing Modes188Instruction Extensions190New Instructions193Bit Field Instru
126 Assembly Language Programming for the 68000 Family************************************************************* PROGRAM DATA******************
Linked Lists—A Programming Example 127INSERT, PRINT, DELETE, QUIT? I ENTER: CINSERT, PRINT, DELETE, QUIT? I ENTER: DINSERT, PRINT, DELET
CHAPTER 10LOGICAL, SHIFT AND ROTATE INSTRUCTIONSIn this chapter we will examine a group of instructions that can manipulate the individual bits of a
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
Logical, Shift and Rotate Instructions 151AND[.<size>] ANDI.<size>] ANDII.<size>] OR I.<size>] 0R[.<size>] ORIt.<siz
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
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
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
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
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
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
Logical, Shift and Rotate Instructions 157The rotate instructions have the same format as the shift instructions.<rotate>[.<size>] Dx,Dy
158 Assembly Language Programming for the 68000 Family<bitop> Dn,<ea><bitop> #<data>,<ea><bitop> = BTSTr BSET,
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
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
CHAPTER 11ADVANCED ARITHMETICIn Chapters 4 and 5 you learned the ADD, SUB, ADDQ, and SUBQ instructions. These instructions, along with the condition
142 Assembly Language Programming for the 68000 Familysingle instruction. We can perform multiple precision operations by representing our numbers
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
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-
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
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
146 Assembly Language Programming for the 68000 Familypair is used for signed values. Unlike addition and subtraction, signed and unsigned mul
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
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
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,
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
Advanced Arithmetic 151JSR GETCGET A CHARCTERSOB.B # ' 0'/DOMAKE INTO DECIMALLSL.B #4,DOSHIFT INTO HIGH NIBBLEMOVE.L DO/-(SP) SAVE DOJSRGET
152 Assembly Language Programming for the 68000 Familythe result is the nine’s complement. This instruction can also be thought of as subtracting the
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
154 Assembly Language Programming for the 68000 Family9. The remainder is located in the high-order word of the destination register.HOVE.BNUH1,D0E
C/MPTER 12EXCEPTION PROCESSING, SYSTEM CONTROL OPERATIONS, AND I/OIn this chapter we will cover a number of topics and instructions that d
Introduction 3Step One. Text EditingStep Two. AssemblyFigure 1 Assembler Operation.In Chapter 11 will review number systems. If you are an experienc
156 Assembly Language Programming for the 68000 FamilyStatus Register15 13System Byte-10User Byte 4TS12 11 10CCRInterrupt Mask Supervisor State Trac
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
158 Assembly Language Programming for the 68000 FamilyThere is one more instruction that should be mentioned before going on to exceptions. Recall fr
Exception Processing, System Control Operations, and I/O 159VectorNumberls)DecAddressHex SpaceAssignment00 000SPReset: Initial SSP?14004SPReset: I
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
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
162 Assembly Language Programming for the 68000 Family1. Execution of the TRAP instruction will result in the CPU being placed into superv
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
164 Assembly Language Programming for the 68000 Familyserial and parallel refer to the methods used to transfer data from the input/output device t
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
166 Assembly Language Programming for the 68000 FamilyStatus RegisterIRQPE 0VRNFE CTS DCDTDRE RDRFL Recv. Data Reg. Full— Xmit. Data Reg. Empt
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
168 Assembly Language Programming for the 68000 Familythe main program. Many textbooks on systems programming or operating system techniques descri
Exception Processing, System Control Operations, and I/O 16931 24Register Contents 23 1G 15 07 0hi-orderlow-orderContents of Memory15B 70hi-ord
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
Exception Processing, System Control Operations, and I/O 17113. What exception vectors are associated with the TRAP instruction?14. Is an exception
172 Assembly Language Programming for the 68000 Family16. No, any memory reference instruction can be used, since the 68000 employs memory-mapped I
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
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
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
c m r r m 1NUMBER SYSTEMSThroughout history mankind has used a variety of methods to represent numerical quantities. Early man used piles of stones
176 Assembly Language Programming for the 68000 FamilyVirtual Address SpacePhysical Memorypage framesFigure 15 Virtual memory mapping.addresses. T
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
178 Assembly Language Programming for the 68000 Familyinstructions to be used in conjunction with the function class output lines. A source function
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
I180 Assembly Language Programming for the 68000 Familythe speed of execution of an instruction. As I mentioned in Chapter2, a CPU requ
The 68010 181You may recall that the DBcc instruction on the 68000 first checks the terminating condition. If it is true, execution continues w
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
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
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
6 Assembly Language Programming for the 68000 FamilyBinaryVirtually all computers use 2 as the base for numerical quantities. The choice of 2
186 Assembly Language Programming for the 68000 FamilyInstruction CachingBesides using full 32-bit operands both internally and via the data bus,
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
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
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
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
The 68020 191Generation: EA = (bd + An) + Xn.SIZE*SCALE + odAssembler Syntax: ([bd,An],Xn.SIZE*SCALE,od)Mode:Base Displacement:Index Register: Scal
192 Assembly Language Programming for the 68000 FamilyThe CMPI and TST instructions now allow all of the PC relative addressing modes. Ho
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
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
The 68020 19531 28 23 15 0Base- *+ $04+ $08+ $0C+ $10Figure 18 Module descriptor format (Courtesy of Motorola, Inc)immediate operand specifying
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
196 Assembly Language Programming for the 68000 FamilySP —+ $08 + $0C + $10 + $14 + $1815Opt12Type Saved Access LevelCondition CodesArgument Coun
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
198 Assembly Language Programming for the 68000 Familyjunction with the main CPU chip to provide additional features not available on the main CPU.
The 68020 199PACK -(AO),-(Al),#-$3030UNPK has the following identical general forms:UNPK -(Ax) ,-(Ay), #<adjustirent>UNPK Dx,Dy,#<adjusti
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
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
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
204 Assembly Language Programming for the 68000 FamilyFigure 21 68030 Block diagram. (Courtesy of Motorola, Inc.)Instruction and Data C achesFigure
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-----
8 Assembly Language Programming for the 68000 FamilyHexadecimalHexadecimal, or base 16, uses positional values that are powers of 16. Each hex digit
206 Assembly Language Programming for the 68000 FamilyPipelined ArchitecturePipelining is a technique used on high performance CPU’s such as main
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
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
The 68030 209tables, Motorola’s terms for the entries of a page table, translation descriptors, and for an individual table in the tree, de
210 Assembly Language Programming for the 68000 FamilyB-level tablesFigure 23 Example address translation tree.non-existent table or page, the o
The 68030 21116 15] A7 (ISP) tNTERRUPTSTACK POINTER16 15 0MASTERAT* (MSP) STACK POtNTER67 0(CCR) SR STATUS REGISTER0H VBR VECTOR BASE REGI
212 Assembly Language Programming for the 68000 FamilyPLOAD Takes a virtual address and searches the translation tree for the correspondi
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
cir012345678910111213141516171819202122232425262728293031APPENDIX AASCII CHARACTER CODESOctal HexASCIIDecimalOctalHex ASCII000 00NUL 3204020 SP001 01
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:
216 Assembly Language Programming for the 68000 FamilyDecimalOctalHex ASCIIDecimalOctalHexASCII64100 40<S>96 140 60*65101 41 A97 14161 a66 102
APPENDIX BPROGRAM SHELLS AND I/O SUBROUTINESShell foe the Atari ST computers.textYour program goes here <PROGRAM>Return to system.fini: move.w
218 Assembly Language Programming for the 68000 Familymovem.l (sp)+,dl-d2 rtsrestore registers returnThe following subroutine to output a decimal n
Appendix B 219**********************************************Amiga shell - This must run under the CLI Link with amiga.lib* You may have to modify the
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
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
222 Assembly Language Programming for the 68000 Family; Macintosh shell.;****************************************t; The following include files ac
Appendix B 225Start: movem.l d0-d7/a0-a6,-(sp) pea -4(a5)_InitGraf _InitPonts _InitWindows _InitMenua clr.l -(sp)_InitDialogsJTEInit_InitCursorlea
224 Assembly Language Programming for the 68000 Familymove.wmovemove_M0VET0movem.1rtsdO,(aO)#LMARG,-(sp) #TMARG,-(sp)(sp)+,d0-d2,a0-alFLASHTIME equ
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
10 Assembly Language Programming for the 68000 Familyor hexadecimal55P2- 4A630B8FHand calculations involving multiplication or division are rarely pe
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
Appendix B 227jsr putc move,l (sp)+,dO rtsend/restore <30 /return
APPEHDIX C68000-68020 INSTRUCTION SUMMARYMnemonicAddr Modes: Src DestSizeAttributesCond. Codes X N Z V CDescriptionABCD DnDnBS 0 S 0 sAdd Decima
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
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
252 Assembly Language Programming for the 68000 FamilyTST <dea> AlterableUNLK AnUNPACK -(An),-(An),#<adjstmnt>UNPK Dn,Dn,#<adjstmn
Appendix C 233Addressing Mode Descriptions:<ea> - effective address<rea> - register effective address<dea> - data effective address
INDEX# , 43, 73 *, 34, 79 ABCD, 149absolute addressing, 73-74access rights, 194ACIA, 163-68ADD, 45ADDA, 46ADDI, 46addition, 44-46addition and subtract
Humber 5ystems 11Representing Negative ValuesSo far in our discussion of number representations, we have only been dealing with positive nu
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,
Index 237EXG, 44 EXT, 148,192 extend bit, 62 condition, 143fields, source statement, 29 FORTRAN, 37, 99 forward reference, 37, 84 framing, 164 func
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,
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
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
12 Assembly Language Programming for the 68000 Family10011100 + 0000000110011101Let’s convert 8910 to —8910 using two’s complement. First we mus
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
14 Assembly Language Programming for the 68000 Family20. Hexadecimal numbers use what number base?21. What number base is used internally by the 68
fiumber Systems 1519. decimal, binary and hexadecimal20. 1621. binary22.a) 110010002; C816b) 1012; 5„c) lllllOllllOlOOOj; FDE81623. a) 213 b
A55EMBLY LANGUAGE PROGRAMMING TOR THE 68000 FAMILY
CHAPTER 2MICROCOMPUTER ARCHITECTUREBefore we begin to discuss assembly language, we should take time to explore the world of the microcomputer. Just w
18 Assembly Language Programming for the 68000 FamilyFigure 2 Organization of a simple microcomputer system.the M6800 family. The MC6800 is strictly
Microcomputer Architecture 19be modified by hand to allow for the differences in architectures. This scheme did have the advantage that it allowed so
20 Assembly Language Programming for the 68000 Familynal rate at which operations are performed. The basic interval between clock pulses is the cycle
Microcomputer Architecture 21operations allow manipulation of the individual bits of the data. You will soon see how logical operations can be very u
22 Assembly Language Programming for the 68000 Familymer from having to worry about the exact representation of instructions and data in memory. Ho
Microcomputer Architecture 23instruction is. Many instructions are actually represented by several different opcodes, each specifying a different ve
24 Assembly Language Programming for the 68000 Familyuser/supervisor mode information on every reference to memory. If the system is so designed, ce
Microcomputer Architecture 25memory. If an instruction causes a branch to a part of the program other than the next sequential instruction, the PC wi
Related Titles of Interest from John Wiley & SonsPROGRAMMING WITH MACINTOSH PASCAL, SwanEXCEL: A POWER USER’S GUIDE, HodgkinsJAZZ AT WORK, Venit &
26 Assembly Language Programming for the 68000 FamilyInput/OutputIt may come as a surprise to you that the 68000 does not have any input
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
CHAPTER 3ASSEMBLER SOURCE FORMATThere are many assemblers available for the 68000 family. They differ from each other in minor ways. It would be virtu
30 Assembly Language Programming for the 68000 Familyas a field separator; most assemblers also recognize the tab character as a field separator, and
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
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
Assembler Source Format 33are allowed by all assemblers. The characters +, —, and / are interpreted as addition, subtraction, multiplication, and
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
Assembler Source Format 35we can use are:Indicator Base% 2 @ 8 [none] 10 $ 16A binary constant would naturally consist of a percent sign followe
ASSEMBLY LANGUAGE PROGRAMMING FOR TNE 68000 FAMILYThomas P. SkinnerJohn Wiley & Sons, Inc.New York • Chichester • Brisbane • Toronto • Sin
36 Assembly Language Programming for the 68000 FamilyData-Defining DirectivesBefore we cover the specific instructions of the 68000, it is important
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
58 Assembly Language Programming for the 68000 Family<exp> is any legal expression as long as it does not contain any undefined symbols. Symbo
Assembler Source Format 3915. Indicate which of the following are legal constants:12345 $ABCD @F00 $345 @77716. What is the character string co
CHAPTER 4GETTING STARTEDIn order to write a program in assembly language, you must develop a familiarity with the machine instructions of the 68000. T
42 Assembly Language Programming for the 68000 Familywithout having to remember different mnemonics for all these instructions.The general form of
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
44 Assembly Language Programming for the 68000 FamilyUnfortunately these two instructions do not accomplish the desired result. The first MOVE instr
Getting 5tarted 45actually perform meaningful tasks. The general form of the add and subtract instructions are:[<label>] ADD[.<si
Intel is a trademark oflntel Corporation.Amiga is a trademark of Commodore International.Apple and Macintosh are trademarks of Apple Computer, Inc.Ata
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
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
48 Assembly Language Programming for the 68000 Familyterminal. Normally, some degree of hardware independence is provided by the operating system be
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
50 Assembly Language Programming for the 68000 Familytion, STOP, but if this instruction is used to terminate your program, the microprocessor will
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,
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
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
54 Assembly Language Programming for the 68000 Family1 22 43 84 165 326 647 1288 2569 51210 102411 204812 409613 819214 1638415 32768
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
*To my wife Linda
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
CHAPTER 5CONDITIONAL AND ARITHMETIC INSTRUCTIONSIn Chapter 4 you learned a small number of 68000 instructions. These were enough to write some very si
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
Conditional and Arithmetic Instructions 59destination register. For example, the addition of the following unsigned 8-bit binary numbers results in
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
Conditional and Arithmetic Instructions 61The Overflow BitWhat if we were adding signed numbers? A carry out of the high-order bit is not necessaril
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
Conditional and Arithmetic Instructions 63values such as ASCII characters. One way to perform a comparison would be to subtract the two numbers and
64 Assembly Language Programming for the 68000 Familynot equal, it is sometimes difficult to remember which value should be the source and which valu
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
66 Assembly Language Programming for the 68000 FamilyMany assemblers will allow the use of the CMP mnemonic for all variations of the CMP ins
Conditional and Arithmetic Instructions 67referencing an address register. However, only word and longword forms of the instruction can be used wit
68 Assembly Language Programming for the 68000 FamilyExercisesAssume longword operands unless otherwise specified.1. What CCR bit is used to
Conditional and Arithmetic Instructions 6920. Can MOVEQ be used to load only the low-order byte of a data register?Answers1. The carry
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
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
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
Addressing Modes 73least one word of memory. If we have an immediate operand, this immediate constant data is placed in one or two succ
74 Assembly Language Programming for the 68000 Familyword. This is similar to the technique used with immediate addressing, but these words are an
Addressing Modes 75this memory address at program execution time, we could reference data using this address value rather than a symbol. Thi
>PREFACEThis book deals specifically with the Motorola 68000 family of microprocessors. It is primarily about assembly language programmi
76 Assembly Language Programming for the 68000 FamilyThe LEA instruction takes the address of COUNT, not the value at location COUNT, and
Addressing Modes 77Address Register Indirect With Postincrem entThis addressing mode works exactly the same way as address register indirect except
78 Assembly Language Programming for the 68000 FamilyLOOPsPINILEA MOVE.B BEQ JSR BRASTR,A0(A0)+,D0PINIPUTCLOOPGET ADDRESS OF STRING GET NEXT CHARACT
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
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
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:
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
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
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
Addressing Modes 85Data Register DirectAddress Register DirectAddress Register IndirectAddress Register Indirect with PostincrementAddress Regi
Commentaires sur ces manuels