NOT: Bu döküman HCS12 2. Labı için oluşturulmumş çalışma notlarıdır, lab soruları ve cevapları, lab sonrası eklenecektir. Dili yarı Türkçe olucak şekilde kullanılmaya gayret gösterilmiştir.
HCS12 Addresing Modes
- Inherent
- Extended
- Direct
- Immediate
- Indexed -- Won't study indirect indexed mode
- Relative Modes -- used only with branch instructions
LDAA $20 ;($0020) --> A Effective Address: $0020 STX $21 ;(X) --> $0020:$0022 Effective Address: $0021
LDAA 0,X ; Use (X) as address to get value to put in A Effective address: contents of X
ADDA 5,Y ; Use (Y) + 5 as address to get value to add Effective address: contents of Y+5
More Complicated Forms
INC 2,X- ; Post-decrement Indexed ; Increment the number at address(X) ; then subtract 2 fom X Effective address: contents of X
INC 4,+X ; Pre-increment Indexed ; Add 4 to X ; then increment the number at address (X) Effective address: contents of X + 4
IDX1: Addressin tanımlanması için 2 byte kullanılmaktadır. IDX2: Bunda 3 byte kullanılmaktadır.
Relative addresing sadece branch için kullanılmaktadır.
BRA: Sonra bi daha bak.
A few instructions have two effective addresses:
MOVB #$AA, $1C00 ; Move byte 0xAA (IMM) to address $1C00(EXT) MOVW 0,X,0,Y ; Move word from address pointed to by X (IDX) to address pointed to by Y (IDX)
BRSET FOO,#$03,LABEL Branch to LABEL (REL) if bits #$03 (IMM) of variable FOO (EXT) are set.
Example: ldaa 0,x and inx == ldaa 1,x+
Table
| Data | Address |
|---|---|
| 0c | $1000 |
| 7A | $1001 |
| D5 | $1002 |
| 00 | $1003 |
| 61 | $1004 |
| 62 | $1005 |
| 63 | $1006 |
| 64 | $1007 |
org $1000
table: dc.b 12,122,-43,0 dc.b 'a' dc.b 'b' dc.b 'c' dc.b 'd'
Loop Kodu
org $2000 ; Addresi burdan başlat
ldab #10 ; load accumulator B'ye decimal olarak 10.
loop: clra ; clear accumulator A yap. dbne b, loop ; B yi azal 0 mı diye kontrol et değilse , loop a atla. swi
Note: dbne = d branch not equal.
Örnek kodlara bak.
Directive Name slayt 4. page 15. oraya bak.
Transfer - copy contents of one register to another.
TBA ; Transfer B nin içerisini A ya kopyalar. TFR X,Y ; Transfer X in değerini Y ye kopyala.
Exchange contents of two registers.
XGDX ; D ile X in contentlerini değiştir. EXG A,B ; A ile B nin contentlerini değiştir.
ldx #table not equal ldx table