PICÀÇ ¸í·É ¼­½Ä

[¼Ò½º ÄÚµåÀÇ ¼­½Ä]

PIC ½Ã¸®ÁîÀÇ ¾î¼Àºí·¯¿¡¼­ »ç¿ëµÇ´Â ¸í·ÉÀÇ ¼­½ÄÀº ´ÙÀ½°ú °°ÀÌ µÇ¾î ÀÖ´Ù.
source codeÀÇ °¢ ÇàÀº ´ÙÀ½°ú °°Àº ±âº» Æ÷¸ËÀ¸·Î ¾´´Ù.

    Label       Mnemonic           Operand            Comment

ÁÖ1: LabelÀº ÇàÀÇ ¼±µÎºÎÅÍ ½ÃÀÛÇÒ °Í
ÁÖ2: Mnemonic¿¡¼­ LabelÀÌ ¾øÀ» ¶§´Â ¼±µÎ¿¡ 1°³ ÀÌ»óÀÇ ½ºÆäÀ̽º°¡ ÇÊ¿ä
ÁÖ3: Comment´Â ¾îµð¿¡¼­ ½ÃÀÛÇصµ ÁÁ´Ù
ÁÖ4: 1ÇàÀº 255 ¹®ÀÚ ÀÌÇÏ
ÁÖ5: °¢°¢ÀÇ Ç×Àº 1°³ ÀÌ»óÀÇ ½ºÆäÀ̽º·Î ºÐ¸®ÇÑ´Ù
ÁÖ6: 1Çà¿¡ º¹¼öÀÇ Æ÷¸ËÀ» ','·Î ´Ü¶ôÁö¾î ¾µ ¼ö ÀÖ´Ù

Label

LabelÀº °¢ ÇàÀÇ ¼±µÎ·ÎºÎÅÍ ½ÃÀÛÇÏÁö ¾ÊÀ¸¸é ¾ÈµÈ´Ù.
¶Ç, Æ÷ÇԵǴ ¹®ÀÚ´Â ¾ËÆĺªÀ̳ª ¾ðµå¹Ù(_)·Î ½ÃÀ۵Ǵ ¿µ¼ýÀÚ¿©¾ß ÇÑ´Ù.
LabelÀº 32 ¹®ÀÚ ÀÌÇÏÀÇ ±æÀ̱îÁöÀ̸ç, ´ë¹®ÀÚ, ¼Ò¹®ÀÚÀÇ ±¸º°ÀÌ ÀÖ´Ù.
´Ü, ´ë¼Ò ¹®ÀÚÀÇ ±¸º°Àº ȯ°æ ¼³Á¤¿¡¼­ ¾ø¾Ù ¼öµµ ÀÖ´Ù.

Mnemonic

¾î¼Àºí·¯ ¸í·É°ú Áö½Ã¸í·É(ÀÇ»ç¸í·É)Àº ÇàÀÇ ¼±µÎºÎÅÍ 1°³ ÀÌ»óÀÇ ½ºÆäÀ̽º°¡ ÀÖ¾î¾ß ÇÑ´Ù.
LabelÀÌ ÀÖ´Â °æ¿ì´Â Label ´ÙÀ½¿¡ 1°³ ÀÌ»óÀÇ ½ºÆäÀ̽º³ª ÄÝ·Ð(:)ÀÌ ÇÊ¿äÇÏ´Ù.

Operand

Operand´Â MnemonicÀÇ ´ÙÀ½¿¡ 1°³ ÀÌ»óÀÇ ½ºÆäÀ̽º³ª Ÿºê·Î ºÐ¸®µÈ´Ù. ¶ÇÇÑ º¹¼öÀÇ Operand°¡ ÇÊ¿äÇÑ °æ¿ì¿¡´Â ','À¸·Î ºÐ¸®ÇÑ´Ù.

Comment

¼¼¹ÌÄÝ·Ð(;)¿¡ À̾îÁö´Â ¹®ÀýÀº ¸ðµÎ ÄÚ¸àÆ®·Î µÈ´Ù.
±×¸®°í ¾î¼Àºí¿¡¼­´Â ¹«½ÃµÇ°í ¿ÀºêÁ§Æ®¿¡´Â ¾Æ¹«·± °ü°è°¡ ¾ø´Ù.
¹®ÀÚÁ¤¼ö·Î ¼¼¹ÌÄÝ·ÐÀ» »ç¿ëÇÏ´Â °ÍÀº ¹®Á¦°¡ ¾ø´Ù.


[¸í·ÉÀÇ ¼­½Ä]

source code Áß¿¡¼­µµ ƯÈ÷ ¸í·ÉÀ» ¾µ ¶§ÀÇ ¼­½ÄÀ» ¼³¸íÇÑ´Ù. ¸í·É °¡¿îµ¥¼­ Operand¿¡´Â ´ÙÀ½°ú °°Àº µ¥ÀÌÅ͸¦ ¾µ ÇÊ¿ä°¡ ÀÖ´Ù.
    f: register file address
    d: destination select
    b: bit address
    k: literal


 °¢ ¼­½Ä¿¡ ´ëÇØ ÀÚ¼¼È÷ ¼³¸íÇÑ´Ù.

  (1) f: register file address

register file address·Î¼­´Â 7ºñÆ®ÀÇ ÆøÀÌ Àֱ⠶§¹®¿¡ 00ºÎÅÍ 7F±îÁö, ÃÖ´ë 128°³ÀÇ ·¹Áö½ºÅ͸¦ ÁöÁ¤ÇÒ ¼ö ÀÖ´Ù. ±×·¯³ª, ½ÇÁ¦·Î Á¸ÀçÇÏ´Â ·¹Áö½ºÅÍ´Â PICÀÇ Á¾·ù¿¡ µû¶ó ´Ù¸£´Ù.

    (¿¹) PIC16F84ÀÇ °æ¿ì
          address     00¡­0C        :½Ã½ºÅÛ ·¹Áö½ºÅÍ
          address     0C¡­4F        :¹ü¿ë ·¹Áö½ºÅÍ(68°³)

ÀÌ ·¹Áö½ºÅÍ ¾îµå·¹½ºÀÇ ÁöÁ¤¿¡´Â ¾îµå·¹½º ¼öÄ¡¸¦ Á÷Á¢ ÁöÁ¤ÇÏ´Â °Í¿¡¼­´Â ½Ç¼öµµ ¸¹°í ÀÌÇØÇϱ⠾î·Á¿öÁö¹Ç·Î ÀϹÝÀûÀ¸·Î´Â EQU ¸í·É µîÀ¸·Î ·¹À̺íÀ» ¼³Á¤ÇÏ¿© ·¹À̺í·Î ÁöÁ¤ÇÑ´Ù.

  (¿¹)
         COUNTER    EQU    0DH                 ;·¹ÀÌºí ¼³Á¤ Á¤ÀÇ
                     ---------------
                            INCR    COUNTER, F   ; ·¹ÀÌºí »ç¿ë

  (2) d: destination select

ÀÌ°ÍÀº ¸í·ÉÀ» ½ÇÇàÇÑ °á°ú¸¦ ¾îµð¿¡ ÀúÀåÇÒ °ÍÀΰ¡¸¦ ÁöÁ¤ÇÏ´Â °ÍÀε¥, 0À̳ª 1ÀÇ 2°¡Áö¸¸ ÁöÁ¤ÇÒ ¼ö ÀÖ´Ù. ±×¸®°í Ç¥ÁØ include file·Î W¿Í F°¡ Á¤ÀǵǾî ÀÖÀ¸¸ç ´ÙÀ½°ú °°ÀÌ µÈ´Ù.

W:  d=0¿¡¼­ Wreg¿¡ °á°ú¸¦ ÀúÀåÇÑ´Ù
F:   d=1¿¡¼­ f·Î ÁöÁ¤ÇÏ°í ÀÖ´Â ·¹Áö½ºÅÍ¿¡ ÀúÀåÇÑ´Ù.

(¿¹)
DECF          COUNTER,W          COUNTER-1À» Wreg¿¡ ÀúÀå

(3) b: bit address

ºñÆ® À§Ä¡¸¦ ÁöÁ¤ÇÏ´Â 3ºñÆ®ÀÇ ¾îµå·¹½º·Î 1¹ÙÀÌÆ® µ¥ÀÌÅÍÀÇ ¸î ºñƮ°Àΰ¡¸¦ ÁöÁ¤ÇÒ ¼ö ÀÖ´Ù.
ÀÌ bÀÇ ¼­½Ä¿¡´Â Á÷Á¢ ¼öÄ¡¸¦ »ç¿ëÇÏ¿© ÁöÁ¤ÇÏ´Â ¹æ¹ý°ú, º°µµ·Î ¼³Á¤µÈ ·¹À̺íÀ» »ç¿ëÇÏ¿© ÁöÁ¤ÇÏ´Â ¹æ¹ýÀ¸·Î 2°¡Áö°¡ »ç¿ëµÇ°í ÀÖ´Ù.

(¿¹)
            BSF            PORTA,3           Æ÷Æ® AÀÇ 4ºñƮ°(0ºÎÅÍ Ä«¿îÆ®ÇÑ´Ù)
RA3      EQU            3                      ·¹ÀÌºí ¼³Á¤ Á¤ÀÇ
           BCF             PORTA,RA3       ·¹À̺íÀÇ »ç¿ë

  (4) k: Literal

Á÷Á¢ °íÁ¤ÀÇ °ªÀ» »ç¿ëÇÏ´Â °æ¿ì¿¡ »ç¿ëÇÑ´Ù. 1¹ÙÀÌÆ®(8ºñÆ®)ÀÇ ÆøÀÌ ÀÖÀ¸¹Ç·Î, ¼öÄ¡¶ó¸é 0¡­256,¹®ÀÚ¶ó¸é ASCII Äڵ带 »ç¿ëÇÒ ¼ö ÀÖ´Ù.

(¿¹)
ADDLW          15          15¸¦ °¡»ê
MOVLW         'C'         ASCII ¹®ÀÚ ÄÚµå(3C)¸¦ Wreg·Î


[Ç¥ÁØ ÀÎŬ·çµå ÆÄÀÏÀÇ ³»¿ë]

file register Áß¿¡¼­µµ ½Ã½ºÅÛ¿¡¼­ »ç¿ëÇÏ°í ÀÖ´Â ¾îµå·¹½º 00ºÎÅÍ 0C±îÁöÀÇ ¹üÀ§´Â ¸Åȸ °°Àº ·¹ÀÌºí ¼³Á¤À¸·Î µÈ´Ù.
±×·¡¼­ ÀÌ°ÍÀ» °¡±ÞÀû Æí¸®ÇÏ°Ô ÇÒ ¼ö ÀÖµµ·Ï MPLAB µîÀÇ ¾î¼Àºí·¯¿¡´Â ½Ã½ºÅÛÀÇ 'Ç¥ÁØ include file'·Î¼­ »çÀü¿¡ Á¤ÀÇ ÆÄÀÏÀÌ ÁغñµÇ¾î ÀÖ´Ù.
±×·¡¼­, ½Ã½ºÅÛÀÇ ·¹Áö½ºÅ͸¦ ÁöÁ¤ÇÒ ¶§¿¡´Â ÀÌ Ç¥ÁØÀ¸·Î ¼³Á¤µÇ¾î ÀÖ´Â ·¹À̺íÀ» ¼­½ÄÀ¸·Î ÁöÁ¤ÇÏ´Â °ÍÀÌ ÆíÇÏ´Ù.
´ÙÀ½ÀÇ ¸®½ºÆ®°¡ ÀÌ Ç¥ÁØ include file·Î ¼³Á¤µÇ¾î ÀÖ´Â ·¹À̺íÀÇ À϶÷ÀÌ´Ù.


;===============================================
;
;    Register  Definitions
;
;===============================================

W                     EQU         H'0000'
F                      EQU         H'0001'

;-----  Register  iles -------------------------

INDF                EQU          H'0000'
TMR0               EQU          H'0001'
PCL                 EQU          H'0002'
STATUS           EQU          H'0003'
FSR                 EQU          H'0004'
PORTA            EQU           H'0005'
PORTB            EQU           H'0006'
EEDATA           EQU          H'0008'
EEADR             EQU          H'0009'
PCLATH           EQU          H'000A'
INTCON           EQU           H'000B'

OPTION_REG   EQU           H'0081'
TRISA              EQU           H'0085'
TRISB              EQU           H'0086'
EECON1          EQU           H'0088'
EECON2          EQU           H'0089'

;----- STATUS Bits --------------------------

IRP                 EQU            H'0007'
RP1                EQU            H'0006'
RP0                EQU            H'0005'
NOT_TO         EQU            H'0004'
NOT_PD         EQU            H'0003'
Z                   EQU            H'0002'
DC                 EQU            H'0001'
C                   EQU            H'0000'

;-----   INTCON Bits  --------------------------

GIE                EQU             H'0007'
EEIE              EQU             H'0006'
T0IE               EQU             H'0005'
INTE              EQU             H'0004'
RBIE              EQU             H'0003'
T0IF               EQU             H'0002'
INTF              EQU              H'0001'
RBIF              EQU              H'0000'

;-----  OPTION Bits  --------------------------

NOT_RBPU    EQU               H'0007'
INTEDG         EQU               H'0006'
T0CS            EQU               H'0005'
T0SE            EQU               H'0004'
PSA              EQU               H'0003'
PS2              EQU               H'0002'
PS1              EQU               H'0001'
PS0              EQU               H'0000'

;-----  EECON1 Bits  --------------------------

EEIF            EQU                H'0004'
WRERR        EQU                H'0003'
WREN          EQU                H'0002'
WR              EQU                H'0001'
RD               EQU                H'0000'

;===============================================
;
;                RAM  Definition
;
;===============================================

                __MAXRAM       H'CF'
                __BADRAM        H'07',   H'50'-H'7F',  H'87'

;===============================================
;
;               Configuration Bits
;
;===============================================

_CP_ON          EQU                H'000F'
_CP_OFF         EQU                H'3FFF'
_PWRTE_ON    EQU                H'3FF7'
_PWRTE_OFF   EQU                H'3FFF'
_WDT_ON        EQU                H'3FFF'
_WDT_OFF       EQU                H'3FFB'
_LP_OSC         EQU                H'3FFC'
_XT_OSC         EQU                H'3FFD'
_HS_OSC         EQU                H'3FFE'
_RC_OSC         EQU                H'3FFF'


´ÙÀ½ ÆäÀÌÁö·Î      ¸ñÂ÷ ÆäÀÌÁö·Î