Ñèñòåìà êîìàíä ÂÅ51
Ñèñòåìà íàñ÷èòûâàåò 111 êîìàíä, èç íèõ 49 îäíîáàéòîâûõ, 45 äâóõáàéòîâûõ è 17 òðåõáàéòîâûõ. Ïîÿâëåíèå òðåõáàéòîâûõ êîìàíä ñâÿçàíî ñ ðàñøèðåíèåì îáúåìîâ CSEG è XSEG, à òàêæå ââîäîì ïðÿìîé àäðåñàöèè â DSEG. Âñå êîìàíäû âûïîëíÿþòñÿ çà îäèí èëè äâà ìàøèííûõ öèêëà (12 òàêòîâ ALE) çà èñêëþ÷åíèåì êîìàíä MUL è DIV, êîòîðûå òðåáóþò ÷åòûðå öèêëà. Áîëüøèíñòâî äâóõáàéòîâûõ êîìàíä îäíîöèêëîâûå, à âñå òðåõáàéòîâûå êîìàíäû—äâóõöèêëîâûå. Ýòî îáúÿñíÿåòñÿ òåì, ÷òî çà îäèí ìàøèííûé öèêë â ÂÅ51 ìîæåò ââîäèòüñÿ äî äâóõ áàéòîâ ïðîãðàììíîãî êîäà.
Âñå ìíîæåñòâî êîìàíä ÂÅ51 óäîáíî ðàçáèòü íà ïÿòü ãðóïï: ïåðåñûëêè (28), ëîãè÷åñêîé îáðàáîòêè (25), àðèôìåòè÷åñêîé îáðàáîòêè (24), ïåðåäà÷è óïðàâëåíèÿ (17), áóëåâîãî ïðîöåññîðà (17).
 ïðîöåññå èñïîëíåíèÿ êîìàíäû âëèÿþò íà ðÿä ôëàæêîâ-ïðèçíàêîâ ðåçóëüòàòà, âõîäÿùèõ â ñîñòàâ PSW (òàáë. 4.10). Ïðèçíàê Ð óñòàíàâëèâàåòñÿ âñÿêèé ðàç, êîãäà ïðèåìíèêîì ðåçóëüòàòà ñëóæèò àêêóìóëÿòîð, âêëþ÷àÿ îïåðàöèè ïåðåñûëêè.
Òàáëèöà 4.10
Ìíåìîíèêè | CY | OV | AC | Ìíåìîíèêà | CY | OV | AC | |
ADD | + | + | + | CLR Ñ | – | – | ||
ADDC | + | + | + | CPL Ñ | + | – | – | |
SUBB | + | + | + | ANL C, bit | + | – | – | |
MUL | + | – | ANL C, /bit | + | – | – | ||
DIV | + | – | ORL C, bit | + | – | – | ||
DA | + | – | – | ORL C, /bit | + | – | – | |
RRC | + | – | – | MOV C, bit | + | – | – | |
RLC | + | – | – | CJNE | + | – | – | |
SET Ñ | – | – |
Ãðóïïà êîìàíä ïåðåñûëêè (òàáë. 4.11) ñîäåðæèò êîìàíäû MOV (ïåðåñûëêè äàííûõ ìåæäó DSEG è RSEG), MOVC (ìåæäó CSEG è À), MOVX (ìåæäó XSEG è À èëè RSEG), êîìàíäû îáðàùåíèÿ ê ñòåêó PUSH è POP, à òàêæå äâå êîìàíäû îáìåíà XCH è XCHD. Íàèáîëåå åìêîé èíñòðóêöèåé ÿâëÿåòñÿ êîìàíäà MOV, êîòîðàÿ èñïîëüçóåò ÷åòûðå ñïîñîáà àäðåñàöèè: ðåãèñòðîâûé (À, Rn, DPTR), ïðÿìîé (direct), êîñâåííûé (@Ri) è íåïîñðåäñòâåííûé (#data, #data 16). Äëÿ óêàçàíèÿ ïðèåìíèêà ñëóæàò òðè ñïîñîáà àäðåñàöèè (êðîìå íåïîñðåäñòâåííîãî), äëÿ óêàçàíèÿ èñòî÷íèêà âñå ÷åòûðå. Òðåõáàéòîâàÿ êîìàíäà MOV direct, direct îáåñïå÷èâàåò ïåðåñûëêó ìåæäó äâóìÿ ëþáûìè ÿ÷åéêàìè ïàìÿòè, âêëþ÷àÿ ðåãèñòðû ÌÊ. Òåì íå ìåíåå äëÿ îáìåíà ñ ðåãèñòðàìè ïðåäóñìîòðåíû ñïåöèàëüíûå äâóõ- è îäíîáàéòîâûé ôîðìàòû:
MOV | Rn, direct |
MOV | direct, Rn |
MOV | A, Rn |
MOV | Rn, A |
Òàáëèöà 4.11
Ìíåìîíèêà | ×èñëî öèêëîâ | Êîä | Ôëàæêè | Îïèñàíèå |
C A F R R O P I C 0 S S V | ||||
MOV A, Rn MOV A, direct MOV A, @Ri MOV A, #data MOV Rn, A MOV Rn, direct MOV Rn, #data MOV direct, A MOV direct, Rn MOV direct, direct MOV direct, @Ri MOV direct, #data MOV @Ri, A MOV @Ri, direct MOV @Ri, #data MOV DPTR, #data16 MOVC A, @A + DPTR MOVC A, @A + PC MOVX A, @Ri MOVX A, @DPTR MOVX @Ri, A MOVX @DPTR, A PUSH direct POP direct XCH A, Rn XCH A, direct XCH A, @Ri XCHD A, @Ri | E8—EF E5 E6—E7 F8—FF A8—AF 78—7F F5 88—8F 86—87 F6—F7 A6—A7 76—77 E2—E3 E0 F2—F3 F0 C0 D0 C8—CF C5 C6—C7 D6—D7 | – – – – – – + – – – – – – + – – – – – – + – – – – – – + – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – + – – – – – – + – – – – – – + – – – – – – + – – – – – – – – – – – – – – – – – – – – – + + + + + + + – – – – – – + – – – – – – + – – – – – – + – – – – – – + | ARn, n = 0—7 A(direct) A(Ri), i = 0—1 Adata RnA, n = 0—7 Rn(direct), n = 0—7 Rndata, n = 0—7 (direct)A (direct)Rn, n = 0—7 (direct)(direct) (direct)(Ri), n = 0—7 (direct)data (Ri)A, i = 0—1 (Ri)(direct), i = 0—1 (Ri)data, i = 0—1 DPTRdata16 ACSEG (A + DPTR) ACSEG (A + PC) AXSEG (P2:Ri), i = 0—1 AXSEG (DPTR) XSEG (P2:Ri)A, i = 0—1 XSEG (DPTR)A +(SP)(direct) (direct)(SP) A«Rn, n= 0—7 A«(direct) A«(Ri), i = 0—1 A0—3«(Ri)0—3, i = 0—1 |
Èõ èñïîëüçîâàíèå ïîçâîëÿåò ñóùåñòâåííî ñîêðàòèòü äëèíó ïðîãðàììíîãî êîäà. Ñïåöèàëüíàÿ êîìàíäà
MOV DPTR, #data 16
ïîçâîëÿåò çàãðóçèòü 16-ðàçðÿäíûé óêàçàòåëü DPTR çíà÷åíèåì data 16.
Ïðè âûïîëíåíèè êîìàíäû MOVC ñ÷èòûâàíèÿ äàííûõ èç ïðîãðàììíîé ïàìÿòè ìîãóò áûòü ïðèìåíåíû äâà ñïîñîáà àäðåñàöèè: ïî áàçå DPTR è îòíîñèòåëüíûé.  îáîèõ ñëó÷àÿõ öåëîå áåç çíàêà ñìåùåíèå (èíäåêñ) õðàíèòñÿ â àêêóìóëÿòîðå. Ïðèåìíèêîì ðåçóëüòàòà òàêæå ñëóæèò àêêóìóëÿòîð. Êîìàíäà äàåò âîçìîæíîñòü âûïîëíÿòü áûñòðóþ ïåðåêîäèðîâêó ïî òàáëèöàì, îñóùåñòâëÿòü äîñòóï ê ìàññèâàì ïàìÿòè.
Îáðàùåíèå ê âíåøíåé ïàìÿòè îñóùåñòâëÿåòñÿ ñ ïîìîùüþ êîìàíäû MOVX. Îáìåí ïðîèçâîäèòñÿ ïî áàéòàì ìåæäó àêêóìóëÿòîðîì è ÿ÷åéêîé âíåøíåé ïàìÿòè äàííûõ. ß÷åéêà XSEG ìîæåò áûòü àäðåñîâàíà äâóìÿ ñïîñîáàìè: êîñâåííî ÷åðåç 16-ðàçðÿäíûé óêàçàòåëü DPTR è ñòðàíè÷íî êîñâåííî ÷åðåç 8-ðàçðÿäíûé óêàçàòåëü Ri, i = 0—1.  ïîñëåäíåì ñëó÷àå ðåãèñòðîì ñòðàíèö ñëóæèò âûõîäíîé ðåãèñòð Ð2.
Îïåðàöèè PUSH è POP èñïîëüçóþò òîëüêî ïðÿìîé ñïîñîá àäðåñàöèè, îäíàêî ýòî íå ìåøàåò èì ìàíèïóëèðîâàòü ñîäåðæèìûì ðåãèñòðîâ, êîòîðûå ðàññìàòðèâàþòñÿ êàê ÿ÷åéêè ïàìÿòè.
Äâå òèïîâûå îïåðàöèè îáìåíà ÕÑÍ è XCHD äîïîëíÿþò îäíîñòîðîííþþ ïåðåñûëêó äâóñòîðîííåé. Ïðè âûïîëíåíèè îïåðàöèè ÕÑÍ îáìåíó ïîäëåæàò áàéòû, ïðè XCHD—ìëàäøèå òåòðàäû áàéòîâûõ îïåðàíäîâ.
Ïðèâåäåííàÿ â òàáë. 4.12 ãðóïïà êîìàíä ëîãè÷åñêèõ îïåðàöèé ñîäåðæèò òðè òèïîâûå äâóõìåñòíûå îïåðàöèè: ANL—ëîãè÷åñêîå È, ORL—ëîãè÷åñêîå ÈËÈ è XRL—ëîãè÷åñêîå èñêëþ÷àþùåå ÈËÈ. Èñòî÷íèêîì ïåðâîãî îïåðàíäà è îäíîâðåìåííî ïðèåìíèêîì ðåçóëüòàòà ñëóæèò ëèáî àêêóìóëÿòîð À, ëèáî ïðÿìî àäðåñóåìàÿ ÿ÷åéêà ïàìÿòè. Âòîðîé îïåðàíä çàäàåòñÿ îäíèì èç ÷åòûðåõ îñíîâíûõ ìåòîäîâ àäðåñàöèè.  ñîñòàâ ãðóïïû âõîäèò òàêæå ðÿä îäíîìåñòíûõ îïåðàöèé: CLR—î÷èñòêè, CPL—ëîãè÷åñêîãî äîïîëíåíèÿ (èíâåðñèÿ), à òàêæå RL, RLC, RR è RRC—îïåðàöèè öèêëè÷åñêîãî è ðàñøèðåííîãî ñäâèãîâ âïðàâî è âëåâî. Âñå îïåðàöèè ìàíèïóëèðóþò ñîäåðæèìûì òîëüêî àêêóìóëÿòîðà À. Ñþäà æå âêëþ÷åíà îïåðàöèÿ îáìåíà òåòðàä â àêêóìóëÿòîðå SWAP, êîòîðàÿ ìîæåò èíòåðïðåòèðîâàòüñÿ êàê öèêëè÷åñêèé ñäâèã áàéòà íà ÷åòûðå ðàçðÿäà.
Òàáëèöà 4.12
Ìíåìîíèêà | ×èñëîöèêëîâ | Êîä | Ôëàæêè | Îïèñàíèå |
C A F R R O P Y C 0 S S V | ||||
ANL A, Rn ANL A, direct ANL A, @Ri ANL A, #data ANL direct, A ANL direct, #data ORL A, Rn ORL A, direct ORL A, @Ri ORL A, #data ORL direct, A ORL direct, #data XRL A, Rn XRL A, direct XRL A, @Ri XRL A, #data XRL direct, A XRL direct, #data CLR A CPL A RL A RLC A RR A RRC A SWAP A | 58—5F 56—57 48—4F 46—47 68—6F 66—67 E4 F4 C4 | – – – – – – + – – – – – – + – – – – – – + – – – – – – + – – – – – – – – – – – – – – – – – – – – + – – – – – – + – – – – – – + – – – – – – + – – – – – – – – – – – – – – – – – – – – + – – – – – – + – – – – – – + – – – – – – + – – – – – – – – – – – – – – – – – – – – + – – – – – – – – – – – – – – + – – – – – + – – – – – – – + – – – – – + – – – – – – – | AA AND Rn, n = 0—7 AA AND (direct) AA AND (Ri), i = 0—1 AA AND data (direct)(direct) AND A (direct)(direct) AND data AA OR Rn, n = 0—7 AA OR (direct) AA OR (Ri), i = 0—1 AA OR data (direct)(direct) OR A (direct)(direct) OR data AA XOR Rn, n =0—7 AA XOR (direct) AA XOR (Ri), i = 0—1 AA XOR data (direct)(direct) XOR A (direct)(direct) XOR data A0 ANOT A A7A6…A0A7 CYA7A6…A0CY A0A1…A7A0 CYA0A1…A7CY A4—7«A0—3 |
 ñîñòàâ ãðóïïû êîìàíä àðèôìåòè÷åñêîé îáðàáîòêè (òàáë. 4.13) âõîäÿò: îïåðàöèÿ ñëîæåíèÿ ADD, ñëîæåíèÿ ñ ó÷åòîì ïåðåíîñà ADDC, âû÷èòàíèÿ ñ ó÷åòîì çàéìà SUBB, óâåëè÷åíèÿ è óìåíüøåíèÿ íà åäèíèöó INC è DEC, äåñÿòè÷íàÿ êîððåêöèÿ ñëîæåíèÿ â 2/10-êîäå óïàêîâàííîãî ôîðìàòà DA, óìíîæåíèå MUL è äåëåíèå DIU. Îïåðàöèè âûïîëíÿþòñÿ íàä áåççíàêîâûìè öåëûìè ÷èñëàìè.
Òàáëèöà 4.13
Ìíåìîíèêà | ×èñëî öèêëîâ | Êîä | Ôëàæêè | Îïèñàíèå |
C A F R R O P Y C 0 S S V | ||||
ADD A, Rn ADD A, direct ADD A, @Ri ADD A, #data ADDC A, Rn ADDC A, direct ADDC A, @Ri ADDC A, #data SUBB A, Rn SUBB A, direct SUBB A, @Ri SUBB A, #data INC A INC Rn INC direct INC @Ri INC DPTR DEC A DEC Rn DEC direct DEC @Ri MUL AB DIV AB DA A | 28—2F 26—27 38—3F 36—37 98—9F 96—97 08—0F 06—07 A3 18—1F 16—17 A4 | + + – – – + + + + – – – + + + + – – – + + + + – – – + + + + – – – + + + + – – – + + + + – – – + + + + – – – + + + + – – – + + + + – – – + + + + – – – + + + + – – – + + + + – – – + + – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – + – – – – – – – – – – – – – – – – – – – – – 0 – – – – + + 0 – – – – + + + – – – – – + | AA + Rn, n = 0—7 AA + (direct) AA + (Ri), i = 0—1 AA + data AA + Rn + CY, n = 0—7 AA + (direct) + CY AA + (Ri) + CY, i = 0—1 AA + data + CY AA – Rn – CY, n = 0—7 AA – (direct) – CY AA – (Ri) – CY, i = 0—1 AA – data – CY AA + 1 RnRn + 1, n = 0—7 (direct)(direct) + 1 (Ri)(Ri) + 1, i = 0—1 DPTRDPTR + 1 AA – 1 RnRn – 1, n = 0—7 (direct)(direct) – 1 (Ri)(Ri) – 1, i = 0—1 BAA´B ABA / B A2/10 êîððåêöèÿ A |
 îïåðàöèÿõ ñëîæåíèÿ è âû÷èòàíèÿ ïåðâûì îïåðàíäîì è ïðèåìíèêîì ðåçóëüòàòà ñëóæèò àêêóìóëÿòîð.  êà÷åñòâå âòîðîãî îïåðàíäà âûñòóïàåò ëèáî ðàáî÷èé ðåãèñòð Rn, n = 0—7, âûáðàííîãî ðåãèñòðîâîãî áàíêà, ëèáî ÿ÷åéêà ïàìÿòè äàííûõ, àäðåñóåìàÿ ïðÿìî direct èëè êîñâåííî @Ri, i = 0—1, ëèáî íåïîñðåäñòâåííûå äàííûå #data. Îïåðàöèè INC è DEC ïðèìåíèìû ê àêêóìóëÿòîðó, îäíîìó èç ðàáî÷èõ ðåãèñòðîâ èëè ê ÿ÷åéêå ïàìÿòè, àäðåñóåìîé êàê ïðÿìî, òàê è êîñâåííî. Êðîìå ýòîãî îïåðàöèÿ óâåëè÷åíèÿ íà åäèíèöó ìîæåò áûòü ïðèìåíåíà ê ñîäåðæèìîìó ðåãèñòðà óêàçàòåëÿ DPTR.
 îïåðàöèÿõ öåëî÷èñëåííîãî óìíîæåíèÿ è äåëåíèÿ áåç çíàêà ó÷àñòâóþò àêêóìóëÿòîð è ðåãèñòð Â. Ïðè óìíîæåíèè 8-ðàçðÿäíîå çíà÷åíèå À óìíîæàåòñÿ íà 8-ðàçðÿäíîå çíà÷åíèå Â, à 16-ðàçðÿäíûé ðåçóëüòàò çàïèñûâàåòñÿ â ïàðó ÂÀ. Ïðè ýòîì ðåãèñòð  õðàíèò ñòàðøóþ ÷àñòü ïðîèçâåäåíèÿ. Ôëàæîê ïåðåïîëíåíèÿ OV óñòàíàâëèâàåòñÿ, åñëè ïðîèçâåäåíèå áîëüøå 255. Ïðè äåëåíèè 8-ðàçðÿäíîãî çíà÷åíèÿ À íà 8-ðàçðÿäíîå çíà÷åíèå  ÷àñòíîå çàïèñûâàåòñÿ â À, à îñòàòîê â Â. Ïðè ïîïûòêå äåëåíèÿ íà 0 óñòàíàâëèâàåòñÿ ôëàæîê ïåðåïîëíåíèÿ. Îïåðàöèÿ äåñÿòè÷íîé êîððåêöèè äëÿ ñëîæåíèÿ DA îñóùåñòâëÿåòñÿ ñòàíäàðòíûì ñïîñîáîì (ñì. § 2.3).
 ñîñòàâå ãðóïïû êîìàíä ïåðåäà÷è óïðàâëåíèÿ (òàáë. 4.14) íàõîäÿòñÿ êîìàíäû ïåðåõîäà AJMP, LJMP, SJMP, JMP, óñëîâíîãî ïåðåõîäà JZ, JNZ, CJNE, âûçîâà ACALL, LCALL, âîçâðàòà RET, RETI è ìîäèôèêàöèè ñ óñëîâíûì ïåðåõîäîì DJNZ. Ñþäà æå âêëþ÷åíà ïóñòàÿ êîìàíäà NOP.
Òàáëèöà 4.14
Ìíåìîíèêà | ×èñëo öèêëîâ | Êîä | Ôëàæêè | Îïèñàíèå |
C A F R R O P Y C 0 S S V | ||||
ACALL addr11 LCALL addr16 RET RETI AJMP addr11 LJMP addr16 SJMP rel JMP @A+DPTR JZ rel JNZ rel CJNE A, direct, rel CJNE A, #data, rel CJNE Rn, #data, rel CJNE @Ri, #data, rel DJNZ Rn, rel DJNZ direct, rel NOP | aaa10001 aaa00001 B5 B4 B8—BF B6—B7 D8—DF D5 | – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – + – – – – – – + – – – – – – + – – – – – – + – – – – – – – – – – – – – – – – – – – – – – – – – – – | +(SP)PC, PC0—10addr11 +(SP)PC, PCaddr16 (PC)(SP)– (PC)(SP)–, êîíåö ïðåðûâàíèÿ PC0—10addr11 PCaddr16 PCPC + rel PCDPTR + A Åñëè À = 0, òî PCPC + rel Åñëè À ¹ 0, òî PCPC + rel Åñëè À ¹ (direct), òî PCPC + rel Åñëè À ¹ (data), òî PCPC + rel Åñëè Rn ¹ (data),òî PCPC + rel, n = 0—7 Åñëè (Ri) ¹ (data), òî PCPC + rel, i = 0—1 RnRn – 1. Åñëè Rn ¹ 0, òî PCPC + rel, n = 0—7 (direct)(direct) – 1. Åñëè (direct) ¹ 0, òî PCPC + rel Íåò îïåðàöèè |
 êîìàíäàõ ïåðåäà÷è óïðàâëåíèÿ øèðîêî ïðèìåíÿåòñÿ îòíîñèòåëüíàÿ àäðåñàöèÿ, êîòîðàÿ ïîääåðæèâàåò ïåðåìåùàåìûå ïðîãðàììíûå ìîäóëè.  êà÷åñòâå îòíîñèòåëüíîãî àäðåñà âûñòóïàåò 8-ðàçðÿäíîå ñìåùåíèå rel ñî çíàêîì, îáåñïå÷èâàþùåå âåòâëåíèå îò òåêóùåãî ïîëîæåíèÿ PC â îáå ñòîðîíû íà ±127 áàéò. Äëÿ ïåðåõîäà â ëþáóþ äðóãóþ òî÷êó 64Ê-áàéòîâîãî àäðåñíîãî ïðîñòðàíñòâà ìîæåò áûòü èñïîëüçîâàí ëèáî ïðÿìîé addr16, ëèáî êîñâåííûé @A + DPTR àäðåñ.  ïîñëåäíåì ñëó÷àå ñîäåðæèìîå À èíòåðïðåòèðóåòñÿ êàê öåëîå áåç çíàêà. Âàðèàíò êîðîòêîé ïðÿìîé àäðåñàöèè addr11 âíóòðè 2Ê-áàéòîâîé òåêóùåé ñòðàíèöû ââåäåí äëÿ ñîâìåñòèìîñòè ñ àðõèòåêòóðîé ÂÅ48.
Âñå ýòè òèïû àäðåñàöèè ìîãóò áûòü ïðèìåíåíû òîëüêî ê îïåðàöèè ïåðåõîäà, à äëÿ îïåðàöèè âûçîâà äîïóñòèìû òîëüêî ïðÿìîé addr16 è âíóòðèñòðàíè÷íûé addr11 ñïîñîáû àäðåñàöèè. Âî âñåõ óñëîâíûõ îïåðàöèÿõ ìîæåò èñïîëüçîâàòüñÿ òîëüêî îòíîñèòåëüíàÿ àäðåñàöèÿ.
Êîãäà ÌÊ ÂÅ51 îïîçíàåò çàïðîñ íà ïðåðûâàíèå, îíà ãåíåðèðóåò îäíó èç êîìàíä òèïà LCALL addr16, ÷òî àâòîìàòè÷åñêè îáåñïå÷èâàåò çàïîìèíàíèå àäðåñà âîçâðàòà â ñòåêå. Îäíàêî â îòëè÷èå îò ÂÅ48 â ÂÅ51 íåò àâòîìàòè÷åñêè ñîõðàíÿåìîé èíôîðìàöèè î ñîñòîÿíèè. Ïðè ýòîì ëîãèêà ïðåðûâàíèé ïåðåñòàåò ñðàáàòûâàòü íà çàïðîñû òîãî óðîâíÿ, êîòîðûé áûë ïðèíÿò ê îáñëóæèâàíèþ. Äëÿ ïîíèæåíèÿ óðîâíÿ ïðåðûâàíèÿ ñëóæèò êîìàíäà âîçâðàòà èç ïðåðûâàíèÿ RETI, êîòîðàÿ êðîìå îïåðàöèè, ýêâèâàëåíòíîé RET, âêëþ÷àåò îïåðàöèþ ðàçðåøåíèÿ ïðåðûâàíèÿ äàííîãî óðîâíÿ.
Ê òèïîâûì óñëîâíûì îïåðàöèÿì ÂÅ51 îòíîñÿòñÿ òàêæå îïåðàöèè JZ è JNZ, JC è JNC. Äâå ïîñëåäíèå âêëþ÷åíû â ãðóïïó áóëåâûõ. Îäíàêî ïîÿâèëàñü íîâàÿ îïåðàöèÿ «Ñðàâíèòü è ïåðåéòè» CJNE. Ïî äàííîé êîìàíäå îïåðàíä ñíà÷àëà ñðàâíèâàåòñÿ ïî ïðàâèëàì âû÷èòàíèÿ öåëûõ ÷èñåë ñ êîíñòàíòîé è â ñîîòâåòñòâèè ñ ðåçóëüòàòîì ñðàâíåíèÿ âûñòàâëÿåòñÿ ôëàæîê CY. Çàòåì â ñëó÷àå íåñîâïàäåíèÿ ñ êîíñòàíòîé âûïîëíÿåòñÿ âåòâëåíèå. Ñðàâíèâàÿ àêêóìóëÿòîð, ðåãèñòð èëè ÿ÷åéêó ïàìÿòè ñ ïîñëåäîâàòåëüíîñòüþ êîíñòàíò, ïîëó÷àåì óäîáíûé ñïîñîá ïðîâåðêè íà ñîâïàäåíèÿ, íàïðèìåð ñ öåëüþ âûÿâëåíèÿ îñîáûõ ñëó÷àåâ. Ïî ñóòè äåëà êîìàíäà CJNE ÿâëÿåòñÿ ýëåìåíòîì îïåðàòîðà ÿçûêîâ âûñîêîãî óðîâíÿ òèïà CASE.
Äàëüíåéøåå ðàçâèòèå ïîëó÷èëà è êîìàíäà DJNZ. Òåïåðü ïðîãðàììèñò â êà÷åñòâå ñ÷åò÷èêà ìîæåò èñïîëüçîâàòü íå òîëüêî îäèí èç ðàáî÷èõ ðåãèñòðîâ Rn, n = 0—7, íî è ëþáóþ ÿ÷åéêó ïàìÿòè äàííûõ DSEG.
Ðÿä êîìàíä, ïðåäíàçíà÷åííûõ äëÿ âûïîëíåíèÿ îïåðàöèé ïåðåñûëêè, ïðîâåðêè óñëîâèé è ëîãè÷åñêîé îáðàáîòêè áóëåâûõ (îäíîðàçðÿäíûõ) ïåðåìåííûõ, îáðàçóåò îòäåëüíóþ ãðóïïó (òàáë. 4.15).  êà÷åñòâå îäíîãî èç îïåðàíäîâ îíè ïðèìåíÿþò ôëàæîê ïåðåíîñà CY, â êà÷åñòâå äðóãîãî ñëóæèò ïðÿìî àäðåñóåìûé ýëåìåíò ïðîñòðàíñòâà BSEG. Ôëàæîê CY ïðè âûïîëíåíèè îïåðàöèé È è ÈËÈ ìîæåò ðàññìàòðèâàòüñÿ êàê áóëåâûé àêêóìóëÿòîð.
Òàáëèöà 4.15
Ìíåìîíèêà | ×èñëo öèêëîâ | Êîä | Ôëàæêè | Îïèñàíèå |
C A F R R O P Y C 0 S S V | ||||
MOV C, bit MOV bit, C CLR C CLR bit SETB C SETB bit CPL C CPL bit ANL C, bit ANL C, /bit ORL C,bit ORL C/,bit JC rel JNC rel JB bit, rel JNB bit, rel JBC bit, rel | A2 C3 C2 D3 D2 B3 B2 B0 A0 | + – – – – – – – – – – – – – 0 – – – – – – – – – – – – – 1 – – – – – – – – – – – – – + – – – – – – – – – – – – – + – – – – – – + – – – – – – + – – – – – – + – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – | CYBSEG (bit) BSEG (bit)CY CY0 BSEG (bit)0 CY1 BSEG (bit)1 CYNOT CY BSEG (bit)NOT BSEG (bit) CYCY AND BSEG (bit) CYCY AND NOT BSEG (bit) CYCY OR BSEG (bit) CYCY OR NOT BSEG (bit) Åñëè CY = 1, òî SJMP rel Åñëè CY = 0, òî SJMP rel Åñëè BSEG (bit) = 1,òî SJMP rel Åñëè BSEG(bit)=0,òî SJMP rel Åñëè BSEG(bit)=1,òî SJMP rel è BSEG(bit)0 |
 ãðóïïó âõîäÿò òàêæå îïåðàöèè áåçóñëîâíîãî è óñëîâíîãî ïåðåõîäîâ ñ îòíîñèòåëüíûì 8-ðàçðÿäíûì ñìåùåíèåì rel. Óñëîâíûé ïåðåõîä ìîæåò áûòü îñóùåñòâëåí êàê ïðè óñòàíîâëåííîì JB, òàê è ïðè ñáðîøåííîì JNB áèòå. Íàëè÷èå êîìàíä ñ ïðÿìûì àäðåñîì ïðîâåðÿåìîãî áèòà îáúÿñíÿåò îòñóòñòâèå ñïåöèàëüíûõ êîìàíä ïðîâåðêè òåñòîâûõ âõîäîâ, êîòîðûå áûëè â ÂÅ48. Îñîáî ñëåäóåò îòìåòèòü îïåðàöèþ JBC, êîòîðàÿ ðåàëèçóåò âåòâëåíèå ïðè óñòàíîâëåííîì áèòå è îäíîâðåìåííî ñ ýòèì ñáðàñûâàåò åãî â 0. Òàêàÿ îïåðàöèÿ ïîëåçíà â ñèñòåìàõ, ðåøàþùèõ ìíîãî çàäà÷, ïðè îðãàíèçàöèè ñåìàôîðîâ, êîòîðûå ââîäÿòñÿ äëÿ çàùèòû êîëëåêòèâíî èñïîëüçóåìûõ ðåñóðñîâ ÌÑ.
Ñåìàôîð ïðåäñòàâëÿåò ñîáîé ðàñïîëîæåííûé â ïàìÿòè ôëàæîê, èíôîðìèðóþùèé î ñîñòîÿíèè ñâÿçàííîãî ñ íèì ðåñóðñà: 1—«Ñâîáîäíî»; 0—«Çàíÿòî». Çàõâàò ðåñóðñà äîïóñêàåòñÿ òîëüêî â ñëó÷àå, åñëè îí ñâîáîäåí, çàòåì ñåìàôîð äîëæåí áûòü ïåðåâåäåí â ñîñòîÿíèå «Çàíÿòî». Çàõâàò ðåñóðñà ñ ïîìîùüþ êîìàíäû JBC îñóùåñòâëÿåòñÿ ñëåäóþùèì îáðàçîì:
WAIT: | JBC | bit, OK | ;Ïðîâåðêà ñåìàôîðà bit |
SJMP | WAIT | ;Pecypc çàíÿò, îæèäàíèå | |
OK: | — | ;Pecypc çàõâà÷åí |
Äàòà äîáàâëåíèÿ: 2019-02-07; ïðîñìîòðîâ: 430;