W aritmeticky registr PIC
#lit ciselna konstanta, trebas #34, nebo #'A'
Pozor #'0' neni nula, ale ASCII adresa znaku nula
fr funkcni registr - libovolny registr RAM, obvykle odkazovany jako jmeno promene
bit adresa bitu
d‚lka pocet byte instrukce
W pracuje s W registrem
reg. nastavuje uvedene bity status registru
Funkce operujici s bajty:
delka reg. W specifikace original PIC instrukce MOV W,#lit 1 - - Naplni W konstantou MOVLW lit MOV W,fr 1 Z - Presune hodnotu registru do W MOVF fr,0 MOV fr,W 1 - - Presune hodnotu W do reg. MOVWF fr MOV fr,#lit 2 - W Naplni reg. konstantou MOVLW lit; MOVWF fr MOV fr1,fr2 2 Z W Presun registru MOVF fr2,0; MOVWF fr1 ADD W,#lit 1 C,DC,Z - W=W + konstanta ADDLW lit ('xx only) ADD W,fr 1 C,DC,Z - W=W + registr ADDWF fr,0 ADD fr,W 1 C,DC,Z - fr = fr + W ADDWF fr,1 ADD fr,#lit 2 C,DC,Z W fr = fr + konstanta MOVLW lit; ADDWF fr,1 ADD fr1,fr2 2 C,DC,Z W fr1=fr1+fr2 MOVF fr2,0; ADDWF fr1,1 MOV W,#lit-W 1 C,DC,Z - W=W - konstanta SUBLW lit ('xx only) MOV W,fr-W 1 C,DC,Z - W= fr - W SUBWF fr,0 SUB fr,W 1 C,DC,Z - fr=fr-W SUBWF fr,1 SUB fr,#lit 2 C,DC,Z W fr=fr-konstanta MOVLW lit; SUBWF fr,1 SUB fr1,fr2 2 C,DC,Z W fr1=fr1-fr2 MOVF fr2,0; SUBWF fr1,1 AND W,#lit 1 Z - W=W AND konstanta ANDLW lit AND W,fr 1 Z - W=W AND fr ANDWF fr,0 AND fr,W 1 Z - fr=fr AND W ANDWF fr,1 AND fr,#lit 2 Z W fr=fr AND konstanta MOVLW lit; ANDWF fr,1 AND fr1,fr2 2 Z W fr1=fr1 AND fr2 MOVF fr2,0; ANDWF fr,1 -to same funguje pro OR, nebo XOR CLR W 1 Z - Vynuluje W CLRW CLR fr 1 Z - Vynuluje registr CLRF fr MOV W,++fr 1 Z - W=fr+1 INCF fr,0 INC fr 1 Z - fr=fr+1 INCF fr,1 MOV W,--fr 1 Z - w=fr-1 DECF fr,0 DEC fr 1 Z - fr=fr-1 DECF fr,1 RR fr 1 C - Rotace registru doprava RRF fr,1 RL fr 1 C - Rotace registru doleva RRF fr,1 *rotace jde vzdy pres carry, nelze rotovat W SWAP fr 1 - - Zamena nizsich a vysich 4 bitu registru SWAPF fr,1 NOT W 1 Z - W=W XOR #255 XORLW 0FFh MOV W,/fr 1 Z - W=fr XOR #255 COMF fr,0 NOT fr 1 Z - fr=fr XOR #255 COMF fr,1 TEST W 1 Z - Test na nulu ve W IORLW 0 TEST fr 1 Z - Test na nulu ve fr MOVF fr,1
Funkce operujici s bity: CLRB bit 1 - - Vynuluj bit BCF bit CLC 1 C - Vynuluj C flag BCF 3,0 CLZ 1 Z - Vynuluj Z flag BCF 3,2 SETB bit 1 - - Nastav bit BSF bit STC 1 C - Nastav C flag BSF 3,0 STZ 1 Z - Nastav Z flag BSF 3,2 ADDB fr,bit 2 Z - Pokud je bit=1, fr=fr+1 BTFSC bit; INCF fr,1 ADDB fr,/bit 2 Z - Pokud je bit=0, fr=fr+1 BTFSS bit; INCF fr,1 SUBB fr,bit 2 Z - Pokud je bit=1, fr=fr-1 BTFSC bit; DECF fr,1 SUBB fr,/bit 2 Z - Pokud je bit=0, fr=fr-1 BTFSS bit; DECF fr,1
MOVB bit1,bit2 4 - - bit1=bit2 BTFSS bit2; BCF bit1; BTFSC bit2; BSF bit1 MOVB bit1,/bit2 4 - - bit1=negace bit2 BTFSC bit2; BCF bit1; BTFSS bit2; BSF bit1 Skoky do smycek: IJNZ fr,addr 2 - - fr=fr+1,pokud fr<>0, skoc na addr INCFSZ fr,1; GOTO addr DJNZ fr,addr 2 - - fr=fr-1,pokud fr<>0, skoc na addr DECFSZ fr,1; GOTO addr Podminen‚ skoky: CJA fr,#lit,addr 4 C,DC,Z W Skoc pokud fr>#lit MOVLW /lit; ADDWF fr,0; BTFSC 3,0; GOTO addr CJA fr1,fr2,addr 4 C,DC,Z W Skoc pokud fr1>fr2 MOVF fr1,0; SUBWF fr2,0; BTFSS 3,0; GOTO addr CJAE fr,#lit,addr 4 C,DC,Z W Skoc pokud fr>#lit,nebo stejne‚ MOVLW lit; SUBWF fr,0; BTFSC 3,0; GOTO addr CJAE fr1,fr2,addr 4 C,DC,Z W Skoc pokud fr1>fr2,nebo stejne‚ MOVF fr2,0; SUBWF fr1,0; BTFSC 3,0; GOTO addr CJB fr,#lit,addr 4 C,DC,Z W Skoc pokud fr1< #lit MOVLW lit; SUBWF fr,0; BTFSS 3,0; GOTO addr CJB fr1,fr2,addr 4 C,DC,Z W Skoc pokud fr1< #fr2 MOVF fr2,0; SUBWF fr1,0; BTFSS 3,0; GOTO addr CJBE fr,#lit,addr 4 C,DC,Z W Skoc pokud fr1< #lit ,nebo stejne‚ MOVLW /lit; ADDWF fr,0; BTFSS 3,0; GOTO addr CJBE fr1,fr2,addr 4 C,DC,Z W Skoc pokud fr1< fr2,nebo stejne‚ MOVF fr1,0; SUBWF fr2,0; BTFSC 3,0; GOTO addr CJE fr,#lit,addr 4 C,DC,Z W Skoc pokud fr1=#lit MOVLW lit; SUBWF fr,0; BTFSC 3,2; GOTO addr CJE fr1,fr2,addr 4 C,DC,Z W Skoc pokud fr1=fr2 MOVF fr2,0; SUBWF fr1,0; BTFSC 3,2; GOTO addr CJNE fr,#lit,addr 4 C,DC,Z W Skoc pokud neni fr1=#lit MOVLW lit; SUBWF fr,0; BTFSS 3,2; GOTO addr CJNE fr1,fr2,addr 4 C,DC,Z W Skoc pokud neni fr1=fr2 MOVF fr2,0; SUBWF fr1,0; BTFSS 3,2; GOTO addr -podobne funguji instrukce CSx, ktere‚ vynechaji na sledujici instrukci, pokud plati podminka, je ale dulezite, aby nasledujici instrukce byla jednobajtova Podminen‚ skoky bitove: JB bit,addr 2 - - Skoc, pokud je bit nastaveny BTFSC bit; GOTO addr JC addr 2 - - Skoc, pokud je carry nastaveny BTFSC 3,0; GOTO addr JZ addr 2 - - Skoc, pokud je Z nastaveny BTFSC 3,2; GOTO addr JNB bit,addr 2 - - Skoc, pokud neni bit nastaveny BTFSS bit; GOTO addr JNC addr 2 - - Skoc, pokud neni carry nastaveny BTFSS 3,0; GOTO addr JNZ addr 2 - - Skoc, pokud neni Z nastaveny BTFSS 3,2; GOTO addr Nepodminene‚ skoky apod: SKIP 1 - - preskoc jednu instrukci '5x: BTFSS 4,7 / 'xx: BTFSC 10,7 JMP addr 1 - - skok na adresu GOTO addr JMP PC+W 1 C,DC,Z - skoc o W bytes dopredu ADDWF 2,1 JMP W 1 - - skoc na adresu danou W MOVWF 2 CALL addr 1 - - skoc do podprogramu CALL addr *PIC16C5x ma pouze 2 mozne vnoreni podprogramu. Navic musi byt podprogram na prvni strance programu (prvnich 256 byte)
RET 1 - - navrat z podprogramu '5x: RETLW 0 / 'xx: RETURN RETW lit,lit... 1 - - navrat z podprogramu, W=lit RETLW lit; RETLW lit... *Instrukce se pouziva ve spojeni s JMP PC+W jako tabulka konstant v programu RETI 1 - - navrat z preruseni RETFIE ('xx only) Ruzne: CLR WDT 1 TO,PD - Vynuluj citac WDT CLRWDT SLEEP 1 TO,PD - spinkej muj malicky... SLEEP NOP 1 - - prazdna instrukce NOP
Definice konstant pro PIC 16C5X
INDF = 00h Indirect addressing register INDIRECT = 00h Indirect addressing register TMR0 = 01h RTCC register RTCC = 01h RTCC register PCL = 02h Program counter low-byte register PC = 02h Program counter low-byte register STATUS = 03h Status register C = STATUS.0 Carry bit DC = STATUS.1 Digit carry bit Z = STATUS.2 Zero bit PD = STATUS.3 Power-down bit TO = STATUS.4 Time-out bit PA0 = STATUS.5 Page preselect bit 0 PA1 = STATUS.6 Page preselect bit 1 PA2 = STATUS.7 Page preselect bit 2 FSR = 04h File select register PORTA = 05h RA i/o register RA = 05h RA i/o register PORTB = 06h RB i/o register RB = 06h RB i/o register PORTC = 07h RC i/o register RC = 07h RC i/o register Definice konstant pro PIC 16C84 INDF = 00h 0/1 Indirect addressing register TMR0 = 01h 0 Timer 0 register PCL = 02h 0/1 Program counter low-byte register STATUS = 03h 0/1 Status register C = STATUS.0 0/1 Carry bit DC = STATUS.1 0/1 Digit carry bit Z = STATUS.2 0/1 Zero bit PD = STATUS.3 0/1 Power-down bit TO = STATUS.4 0/1 Time-out bit RP0 = STATUS.5 0/1 Register page bit 0 RP1 = STATUS.6 0/1 Register page bit 1 IRP = STATUS.7 0/1 Indirect register page bit FSR = 04h 0/1 File select register PORTA = 05h 0 RA i/o register RA = 05h 0 RA i/o register PORTB = 06h 0 RB i/o register RB = 06h 0 RB i/o register EEDATA = 08h 0 EEPROM data register EEADR = 09h 0 EEPROM address register PCLATH = 0Ah 0/1 Program counter high-byte register INTCON = 0Bh 0/1 Interrupt control register RBIF = INTCON.0 0/1 RB4-RB7 change interrupt flag bit INTF = INTCON.1 0/1 RB0/INT interrupt flag bit T0IF = INTCON.2 0/1 TMR0 overflow interrupt flag bit RBIE = INTCON.3 0/1 RB4-RB7 change interrupt enable bit INTE = INTCON.4 0/1 RB0/INT interrupt enable bit T0IE = INTCON.5 0/1 TMR0 overflow interrupt enable bit EEIE = INTCON.6 0/1 EEPROM interrupt enable bit GIE = INTCON.7 0/1 Global interrupt enable bit OPTION = 01h 1 OPTION register PS0 = OPTION.0 1 Prescaler bit 0 PS1 = OPTION.1 1 Prescaler bit 1 PS2 = OPTION.2 1 Prescaler bit 2 PSA = OPTION.3 1 Prescaler assignment bit T0SE = OPTION.4 1 TMR0 source edge bit T0CS = OPTION.5 1 TMR0 clock select bit INTEDG = OPTION.6 1 RB0/INT edge select bit RBPU = OPTION.7 1 RB weak pull-up enable bit TRISA = 05h 1 RA tristate control register TRISB = 06h 1 RB tristate control register EECON1 = 08h 1 EEPROM control register 1 RD = EECON1.0 1 EEPROM read control bit WR = EECON1.1 1 EEPROM write control bit WREN = EECON1.2 1 EEPROM write enable bit WRERR = EECON1.3 1 EEPROM write error flag bit EEIF = EECON1.4 1 EEPROM interrupt flag bit EECON2 = 09h 1 EEPROM control register 2
- Zde je odkaz na kompletní článek
- Zde je ke stazeni assemler a simulator PARALLAX
- Odkaz na originální stránky firmy PARALLAX
Ondrej Vitous - 07 / 1999