Skip to content

Instantly share code, notes, and snippets.

@talayhan
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save talayhan/63552341b0d3d61c6eea to your computer and use it in GitHub Desktop.

Select an option

Save talayhan/63552341b0d3d61c6eea to your computer and use it in GitHub Desktop.
hcs12_Notes_Part2.md

HCS12 Microcontroller Notes

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.

Slayt 3

HCS12 Addresing Modes

  1. Inherent
  2. Extended
  3. Direct
  4. Immediate
  5. Indexed -- Won't study indirect indexed mode
  6. Relative Modes -- used only with branch instructions

Direct (DIR) Addressing Mode

LDAA $20 ;($0020) --> A Effective Address: $0020 STX $21 ;(X) --> $0020:$0022 Effective Address: $0021

The Indexed (IDX, IDX1, IDX2) addressing mode

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 (REL) Addressing Mode

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.

HCS12 Cycles

Örnek kodlara bak.

Assembler Directives

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.

You should try below Codes

ldx #table not equal ldx table

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment