Download Meyer Preliminary Text Chapters 2 and 3
Transcript
Microcontroller-Based Digital System Design Chapter 3 - Page 46 There are two basic variants of PSH and PUL: one for byte-registers (A, B, CCR) and another for word-registers (D, X, Y). Note that neither SP nor PC can be pushed or pulled. Note also that the same stack convention used by our simple computer is used here: the stack pointer (SP) points to the location in which the top stack item is stored (for word-length items, SP points to the high byte of the top stack item). Generally, PSH and PUL do not affect any of the condition code bits – with the obvious exception of PULC, which affects all the condition code bits. Table 3-9 Data Transfer Group: Stack Manipulation Instructions. Description Mnemonic Push PSHrb register rb = A, B, C onto stack PSHrw rw = D, X, Y Pull (pop) register from stack PULrb rb = A, B, C Operation (SP) ← (SP) – 1 ((SP)) ← (rb) (SP) ← (SP) – 1 ((SP)) ← (rwl) (SP) ← (SP) – 1 ((SP)) ← (rwh) (rb) ← ((SP)) (SP) ← (SP) + 1 CC – – * Mode ~ PSHA Examples ž 2 PSHB ž 2 PSHC ž 2 PSHD ž 2 PSHX ž 2 PSHY ž 2 PULA ž 3 PULB ž 3 PULC ž 3 ž 3 ž 3 ž 3 PULD (rwh) ← ((SP)) – (SP) ← (SP) + 1 PULX (rwl) ← ((SP)) PULY (SP) ← (SP) + 1 * PULC affects all the condition code bits, with the exception of X, which cannot be set by a software instruction once it is cleared. PULrw rw = D, X, Y 3.8.2 Arithmetic Group Instructions Instructions that perform an arithmetic operation (add, subtract, multiply, divide) are broadly classified here as belonging to the arithmetic group. As one might guess, most of these instructions affect all of the condition code bits (with a few notable exceptions). Table 3-10 lists the variations of add (ADD) and subtract (SUB) of which the 68HC12 is capable. The “with carry” versions (ADC and SBC) are provided for implementing extended (or “infinite”) precision add or subtract routines; in Chapter 4, we will learn how to write such routines. For the ADC instruction, the “C” bit of the condition code register is interpreted as a carry propagated forward, and is therefore added to the result. For the SBC instruction, the “C” bit is interpreted as a borrow propagated forward, and is therefore subtracted from the result. The “astute digijock(ette)” will Preliminary Draft add ADD add with carry ADC subtract SUB subtract with carry SBC ©2001 by D. G. Meyer