áåñïëàíî ðåôåðàòû

Ðàçäåëû

ðåôåðàòû   Ãëàâíàÿ
ðåôåðàòû   Èñêóññòâî è êóëüòóðà
ðåôåðàòû   Êèáåðíåòèêà
ðåôåðàòû   Ìåòðîëîãèÿ
ðåôåðàòû   Ìèêðîýêîíîìèêà
ðåôåðàòû   Ìèðîâàÿ ýêîíîìèêà ÌÝÎ
ðåôåðàòû   ÐÖÁ öåííûå áóìàãè
ðåôåðàòû   ÑÀÏÐ
ðåôåðàòû   ÒÃÏ
ðåôåðàòû   Òåîðèÿ âåðîÿòíîñòåé
ðåôåðàòû   ÒÌÌ
ðåôåðàòû   Àâòîìîáèëü è äîðîãà
ðåôåðàòû   Êîìïüþòåðíûå ñåòè
ðåôåðàòû   Êîíñòèòóöèîííîå ïðàâî
      çàðóáåæíûéõ ñòðàí
ðåôåðàòû   Êîíñòèòóöèîííîå ïðàâî
      Ðîññèè
ðåôåðàòû   Êðàòêîå ñîäåðæàíèå
      ïðîèçâåäåíèé
ðåôåðàòû   Êðèìèíàëèñòèêà è
      êðèìèíîëîãèÿ
ðåôåðàòû   Âîåííîå äåëî è
      ãðàæäàíñêàÿ îáîðîíà
ðåôåðàòû   Ãåîãðàôèÿ è ýêîíîìè÷åñêàÿ
      ãåîãðàôèÿ
ðåôåðàòû   Ãåîëîãèÿ ãèäðîëîãèÿ è
      ãåîäåçèÿ
ðåôåðàòû   Ñïîðò è òóðèçì
ðåôåðàòû   Ðåôåðàòû Ôèçèêà
ðåôåðàòû   Ôèçêóëüòóðà è ñïîðò
ðåôåðàòû   Ôèëîñîôèÿ
ðåôåðàòû   Ôèíàíñû
ðåôåðàòû   Ôîòîãðàôèÿ
ðåôåðàòû   Ìóçûêà
ðåôåðàòû   Àâèàöèÿ è êîñìîíàâòèêà
ðåôåðàòû   Íàóêà è òåõíèêà
ðåôåðàòû   Êóëèíàðèÿ
ðåôåðàòû   Êóëüòóðîëîãèÿ
ðåôåðàòû   Êðàåâåäåíèå è ýòíîãðàôèÿ
ðåôåðàòû   Ðåëèãèÿ è ìèôîëîãèÿ
ðåôåðàòû   Ìåäèöèíà
ðåôåðàòû   Ñåêñîëîãèÿ
ðåôåðàòû   Èíôîðìàòèêà
      ïðîãðàììèðîâàíèå
 
 
 

Ìèêðîïðîöåññîðíàÿ ñèñòåìà óïðàâëåíèÿ, ïðåäíàçíà÷åííàÿ äëÿ èñïîëüçîâàíèÿ íà ëåñîïèëüíîì çàâîäå

                   LD     B, A            ;

                   JR     NC, DIV1   ; åñëè BC>DE, òî ïåðåõîä

                   LD     A, C            ;

                   ADD E                 ;

                   LD     C, A            ;

                   LD     A, B            ;

                   ADC D                ;

                   LD     B, A            ;

                   JR     DIV2          ;

DIV1          INC   HL              ; åñëè BC>DE: óñòàíîâèòü ïîñëåäíèé áèò

                                                ; ÷àñòíîãî â 1

DIV2          POP  AF              ; èçâëå÷ü ñ÷åò÷èê À èç ñòåêà

                   CP     #09             ; ïðîâåðèòü, 16-é öèêë èäåò èëè íåò

                   JR     NZ, DIV3   ;

                   PUSH         HL              ; åñëè 16-é öèêë, òî â HL öåëàÿ ÷àñòü ÷àñòíîãî,

                                                ; ñîõðàíèòü åå â ñòåêå, ÷òîáû èçâëå÷ü

                                                ; â êîíöå ïðîãðàììû

                   LD     HL, 0          ;

DIV3          DEC  A                ;

                   JR     NZ, DIV4   ; êîíåö öèêëà

                   POP  BC              ; èçâëåêàåì èç ñòåêà öåëóþ ÷àñòü ÷àñòíîãî

                   LD     H, C            ; ïîëó÷àåì ÷àñòíîå â H.L

                   RET                     ;

Êîñèíóñ

×òîáû âû÷èñëèòü êîñèíóñ, èñïîëüçóåòñÿ îãðàíè÷åííûé ÷åòûðüìÿ ÷ëåíàìè ðÿä Òåéëîðà:

, óãîë a èçìåíÿåòñÿ îò 0 äî p/2.                            (6)

Ýòà ôîðìóëà äàåò êîñèíóñ ñ ìàêñèìàëüíîé ïîãðåøíîñòüþ 8,9×10-4, ýòî ìåíüøå, ÷åì îøèáêà ðàçðÿäíîñòè èñïîëüçóåìîãî ôîðìàòà [1].[1] äðîáíûõ ÷èñåë.

                                                              (7)

Ïðåäñòàâëåíèå (7) ôîðìóëû (6) ãîðàçäî óäîáíåå äëÿ âû÷èñëåíèÿ êîñèíóñà ïðîãðàììíî. Äîñòàòî÷íî ñäåëàòü ïðîöåäóðó äëÿ âû÷èñëåíèÿ , ãäå n – öåëîå ÷èñëî, b – äðîáíîå ÷èñëî. Ïåðåä îáðàùåíèåì ê ýòîé ïðîöåäóðå (íàçâàííîé COS_A) îïåðàíäû ñîäåðæàòñÿ:

HL = a2;

DE = b;

BC = n â ôîðìàòå n.0 (B=n, C=0).

Ðåçóëüòàò – â HL

Ýòà ïîäïðîãðàììà èñïîëüçóåò ïðåäûäóùèå àðèôìåòè÷åñêèå ïðîãðàììû.

Ëèñòèíã 12: ïîäïðîãðàììà COS_A

; – – – âñïîìîãàòåëüíàÿ ïîäïðîãðàììà äëÿ êîñèíóñà

; îïåðàíäû: HL, DE, BC

; èçìåíÿþòñÿ âñå ðåãèñòðû

COS_A                PUSH         BC              ; ñîõðàíèòü â ñòåêå n ïåðåä âûçîâîì MUL

CALL         MUL           ; HL=HL´DE

POP  DE              ; DE=n

CALL         DIV            ; HL=HL/DE

LD     D, 1            ; DE=1.0

LD     E, 0             ;

EX    HL, DE                 ;

CALL         MINUS                ; HL=HL-DE

RET                     ;

Ïîäïðîãðàììà êîñèíóñà âû÷èñëÿåò êîñèíóñ óãëà â ïàðå HL.

Ëèñòèíã 13: ïîäïðîãðàììà COS

; – – –ïîäïðîãðàììà êîñèíóñà

; îïåðàíä è ðåçóëüòàò â HL

; èçìåíÿþòñÿ âñå ðåãèñòðû

COS            LD     D, H            ;

                   LD     E, L             ;

                   CALL         MUL           ; HL=a2

                   PUSH         HL              ; a2 â ñòåêå

                   LD     D, 1            ; DE=1.0

                   LD     E, 0             ;

                   LD     B, #1E                  ; BC=1E.0H=30

                   LD     C, 0             ;

                   CALL         COS_A                ; HL=1-a2/30

                   EX    HL, DE                 ;

                   POP  HL              ; HL=a2

                   PUSH         HL              ; a2 â ñòåêå

                   LD     B, #0C                  ; BC=C.0H=12

                   LD     C, 0             ;

                   CALL         COS_A                ; HL=1-a2/12(1-a2/30)

                   EX    HL, DE                 ;

                   POP  HL              ; HL=a2

                   LD     B, #02                  ; BC=2.0

                   LD     C, 0             ;

                   CALL         COS_A                ; HL=1-a2/2[1-a2/12(1-a2/30)]

                   RET                     ;


Ïðåîáðàçîâàíèå äâîè÷íûé®äâîè÷íî-äåñÿòè÷íûé êîä

 óïðàâëÿþùåé ïðîãðàììå íàäî ïåðåâîäèòü äâóõáàéòíûå ÷èñëà ôîðìàòà [12].[34] â äâîè÷íî-äåñÿòè÷íûé êîä âèäà [123.45] ðàçìåðîì â ïÿòü òåòðàä äëÿ ïîñëåäóþùåãî ïåðåâîäà â ñåìèñåãìåíòíûé êîä è èíäèêàöèè.

Äëÿ ýòîãî íóæíû äâå îòäåëüíûõ ïîäïðîãðàììû: îäíà (ïî èìåíè B2D) äëÿ ïåðåâîäà öåëîé ÷àñòè ÷èñëà [12] è âòîðàÿ (èìÿ B2D_F) äëÿ ïåðåâîäà äðîáíîé ÷àñòè ÷èñëà [34].

Ïîäïðîãðàììà B2D ïåðåâîäèò öåëîå äâîè÷íîå ÷èñëî â ðåãèñòðå C (0..FFH) â 2-10 êîä, ðàñïîëîæåííûé â ðåãèñòðîâîé ïàðå HL. Ïåðåâîä ïðîèçâîäèòñÿ â ñîîòâåòñòâèè ñ ôîðìóëîé:

HL=(…((c7)×2+c6)×2+…+c1)×2+c0,

â êîòîðîé ci – ðàçðÿäû ÷èñëà â ðåãèñòðå C, à óäâîåíèå è ñëîæåíèå ñ áèòàìè ci ïðîèñõîäèò ïî ïðàâèëàì äåñÿòè÷íîé àðèôìåòèêè (ñ êîìàíäîé DAA ïîñëå îïåðàöèè).

Ëèñòèíã 14: ïîäïðîãðàììà B2D

; – – – ïåðåâîä áàéòà (öåëîãî) â 2-10 êîä

; îïåðàíä C – ïåðåâîäèìîå ÷èñëî, ðåçóëüòàò â HL

; ñîõðàíÿåò DE

B2D            LD     B, 8             ;

B2D1                   SLA  C                 ; CY¬C (ïîëó÷àåì ïîñëåäíèé áèò îïåðàíäà)

LD     A, L            ; óäâîåíèå HL ñ ó÷åòîì ïåðåíîñà CY

ADC L                 ; ïî ïðàâèëàì äåñÿòè÷íîé àðèôìåòèêè

DAA                    ;

LD     L, A            ;

LD     A, H            ;

ADC H                ;

DAA                    ;

LD     H, A            ;

DJNZ          B2D1                   ; êîíåö öèêëà

RET                     ;

Ïîäïðîãðàììà B2D_F ïåðåâîäèò äðîáíîå ÷èñëî â ôîðìàòå 0.L â 2-10 êîä èç òðåõ òåòðàä â ôîðìàòå 0.ABC (ó÷èòûâàþòñÿ òðè öèôðû ïîñëå çàïÿòîé). Ðåãèñòðû A, B, C ñîäåðæàò â êîíöå êàæäûé ïî îäíîé äåñÿòè÷íîé öèôðå. Ïåðåâîä ïðîèñõîäèò òàê. ×èñëî 0.L óìíîæàåòñÿ íà 10, ðåçóëüòàò â ïàðå H.L. Åãî öåëàÿ ÷àñòü (H) è áóäåò ïåðâîé öèôðîé A ðåçóëüòàòà. Çàòåì H îáíóëÿåòñÿ, ïîëó÷åííàÿ äðîáü 0.L ñíîâà óìíîæàåòñÿ íà 10 è ò.ä.

Äëÿ áûñòðîãî óìíîæåíèÿ íà 10 ñäåëàíà îòäåëüíàÿ ïîäïðîãðàììà MUL10, óìíîæàþùàÿ ïàðó HL (ãäå H=0) è ïîëó÷àþùàÿ ðåçóëüòàò â òîé æå HL. Îíà èñïîëüçóåò ðàâåíñòâî:

10×HL=2×HL+8×HL, à óìíîæåíèÿ íà 2 è íà 8 äåëàþòñÿ ñ ïîìîùüþ êîìàíäû ADD HL, HL.

Ëèñòèíã 15: ïîäïðîãðàììû B2D_F è MUL10

; – – – ïåðåâîä áàéòà (äðîáíîãî) â 2-10 êîä

; îïåðàíä C – ÷èñëî ñ ôèêñèðîâàííîé ïåðåä ñòàðøèì ðàçðÿäîì òî÷êîé, ðåçóëüòàò â ABC

; èçìåíÿþòñÿ âñå ðåãèñòðû

B2D_F        LD     H, 0            ;

CALL         MUL10                ; ïîëó÷èòü â H ïåðâóþ öèôðó

LD     A, H            ; ñêîïèðîâàòü åå â A

LD     H, 0            ; è îáíóëèòü H

CALL         MUL10                ;

LD     B, H            ; âòîðóþ öèôðó – â ðåãèñòð B

LD     H, 0            ;

CALL         MUL10                ; òðåòüþ – â C

LD     C, H            ;

RET

; – – – óìíîæåíèå íà 10

; îïåðàíä â HL (èìååò çíà÷åíèå òîëüêî L) è ðåçóëüòàò â HL

; ñîõðàíÿåò A, BC

MUL10                ADD HL, HL                 ; HL×10=HL×2+HL×8

LD     D, H            ;

LD     E, L             ;

ADD HL, HL       ;

ADD HL, HL       ;

ADD HL, DE       ;

RET                     ;

Ïðåîáðàçîâàíèå äâîè÷íûé®ñåìèñåãìåíòíûé êîä

Ýòî ïðåîáðàçîâàíèå ñ ïîìîùüþ òàáëèöû ïåðåêîäèðîâêè óæå âñòðå÷àëîñü â òåñòîâîé ïðîãðàììå ÎÇÓ. Ñåé÷àñ îôîðìèì åå êàê îòäåëüíóþ ïîäïðîãðàììó (â òåñòå ÎÇÓ íåëüçÿ âûçûâàòü ïîäïðîãðàììû, ò.ê. êîìàíäà âûçîâà CALL èñïîëüçóåò ñòåê). Îïåðàíä ïîäïðîãðàììû – äâîè÷íî-äåñÿòè÷íàÿ öèôðà â ðåãèñòðå A (0..9, ñòàðøàÿ òåòðàäà íóëåâàÿ).

Ëèñòèíã 16: ïîäïðîãðàììà D27

; – – – ïåðåâîä áàéòà â ñåìèñåãìåíòíûé êîä

; îïåðàíä (0..9) è ðåçóëüòàò â A

; ñîõðàíÿåò BC, DE

D27            LD     H, #07                  ;

LD     L, A            ;

LD     A, (HL)                 ;

RET                     ;


Îáðàáîò÷èêè ïðåðûâàíèé

Âñåãî èõ øåñòü – ïî ÷èñëó ïðåðûâàíèé. Îáðàáîò÷èê îáÿçàòåëüíî äîëæåí ñîõðàíèòü â ñòåêå âñå èçìåíÿåìûå èì ðåãèñòðû è â êîíöå âîññòàíîâèòü èõ. Âûõîä èç îáðàáîò÷èêà âûïîëíÿåòñÿ íå ñòàíäàðòíûì RET, à êîìàíäîé RETI.

Îáðàáîò÷èê IRQ0 (íà÷àëî èçìåðåíèé)

Ôóíêöèÿ îáðàáîò÷èêà – îáíóëèòü òàéìåðû T1 è T2, à òàêæå ñïåöèàëüíóþ ÿ÷åéêó ïàìÿòè D_NUM (2 áàéòà). Ýòà ÿ÷åéêà èíêðåìåíòèðóåòñÿ âñÿêèé ðàç ïîñëå ÷òåíèÿ íàïðÿæåíèÿ Ud ñ äàò÷èêà äèàìåòðà. Ïî ïðèõîäó çàïðîñà IRQ0, êîãäà ïðèõîäèò íîâîå áðåâíî, îíà äîëæíà áûòü îáíóëåíà.

Ëèñòèíã 17: îáðàáîò÷èê çàïðîñà IRQ0

          ; – – – îáíóëèòü T1, T2, D_NUM

          IR0_H                  PUSH         BC              ;

                                      PUSH         AF              ;

                                      LD     BC, 0          ;

                                      LD     (T1), BC     ; îáíóëèòü T1

                                      LD     (T2), BC     ; îáíóëèòü T2

                                      LD     (D_NUM), BC     ; îáíóëèòü D_NUM

                                      POP  AF              ;

                                      POP  BC              ;

                                      RETI                    ;

Îáðàáîò÷èê IRQ2 (èíôîðìàöèÿ ñ ÀÖÏ ãîòîâà)

Ôóíêöèÿ îáðàáîò÷èêà – åñëè áðåâíî ñåé÷àñ ïîä ïëàñòèíîé äàò÷èêà (ìîæíî ñóäèòü, ïðî÷òÿ ïîðò ôîòîýëåìåíòîâ ñ àäðåñîì 0B), ñ÷èòàòü äâà áàéòà íàïðÿæåíèÿ èç ïîðòîâ 00 (ìëàäøèé) è 01 (ñòàðøèé). Çàïèñàòü èõ â ìàññèâ íàïðÿæåíèé, ïîä êîòîðûé îòâåäåíà îáëàñòü ïàìÿòè íà÷èíàÿ ñ àäðåñà 0100Í äî êîíöà ÎÇÓ (âñåãî 2Ê). Ïåðåä çàïèñüþ ïðîâåðèòü, íå çàïîëíåí ëè ýòîò ìàññèâ. Èíêðåìåíòèðîâàòü ÿ÷åéêó D_NUM, ñîäåðæàùóþ ÷èñëî ýëåìåíòîâ ýòîãî ìàññèâà.

Ëèñòèíã 18: îáðàáîò÷èê çàïðîñà IRQ2

; – – – ñ÷èòàòü è îáðàáîòàòü áàéò ñ ÀÖÏ

IR2_H                  PUSH         BC              ;

PUSH         HL              ;

PUSH         AF              ;

IN      A, (#0B)     ;

AND #02             ; íàëîæèòü ìàñêó 000000010

JR     Z, IR2_H1  ; åñëè âòîðîé áèò íóëåâîé, òî âûõîä

LD     HL, #1000  ; ðàññ÷èòàòü àäðåñ î÷åðåäíîãî ýëåìåíòà ìàññèâà

LD     C, (D_NUM)        ; ñ÷èòàòü D_NUM

LD     B, (D_NUM+1)    ;

SLA  C                 ; óìíîæèòü åãî íà 2

RL     B                 ;

ADD HL, BC       ; òåïåðü àäðåñ â HL

LD     A, H            ;

CP     #18             ;

JR     NC, IR2_H1         ; åñëè âûøëè çà ïðåäåëû ìàññèâà, òî âûõîä

IN      A, (#00)      ; ñ÷èòàòü ïåðâûé áàéò ñ ÀÖÏ

LD     (HL), A       ; è îòïðàâèòü åãî â ïàìÿòü

INC   HL              ;

IN      A, (#01)      ; ñ÷èòàòü âòîðîé

LD     (HL), A       ; îòïðàâèòü

INC   BC              ; óâåëè÷èòü ïåðåìåííóþ D_NUM íà åäèíèöó

LD     (D_NUM), BC     ;

IR2_H1       POP  AF     ;

POP  HL              ;

POP  BC              ;

RETI                    ;

Îáðàáîò÷èê IRQ3 (îò ãåíåðàòîðà 16 Ãö)

Ôóíêöèÿ îáðàáîò÷èêà – ïðîèçâåñòè èíêðåìåíò ÷àñîâ ðåàëüíîãî âðåìåíè è óñëîâíûé èíêðåìåíò òàéìåðîâ. ×àñû ðåàëüíîãî âðåìåíè – ýòî 4 áàéòà â ïàìÿòè:

TIME                   1/16 ñåêóíäû (0..15);

TIME+1      ñåêóíäû (0..59);

TIME+2      ìèíóòû (0..59);

TIME+3      ÷àñû (0..23);

Âñå âåëè÷èíû õðàíÿòñÿ â äâîè÷íîì ôîðìàòå.

Òàéìåðàì T1 è T2 îòâåäåíî ïî 2 áàéòà ñ íà÷àëüíûìè àäðåñàìè T1 è T2. Óñëîâèÿ, ïðè êîòîðûõ îíè èíêðåìåíòèðóþòñÿ, áûëè ïðèâåäåíû â ï. 3.4.

Ëèñòèíã 19: îáðàáîò÷èê çàïðîñà IRQ3

; – – – èíêðåìåíò ÷àñîâ ðåàëüíîãî âðåìåíè è óñëîâíûé èíêðåìåíò òàéìåðîâ

IR3_H         PUSH         BC              ;

                   PUSH         HL              ;

                   PUSH         AF              ;

                   ; ÷àñû ðåàëüíîãî âðåìåíè

                   LD     HL, TIME   ;

                   INC   (HL)            ; èíêðåìåíò 1/16 ñåêóíä

                   LD     A, (HL)                 ;

                   CP     16               ; ïðîâåðèòü íà äîñòèæåíèå ìàêñèìóìà                       JR          C, IR3_H1  ; óñëîâíûé âûõîä èç ïîäïðîãðàììû

                   LD     (HL), 0                 ; èíà÷å îáíóëèòü 1/16 ñåêóíäû è ïðîäîëæèòü

                   INC   HL              ;

                   LD     B, 2             ; èíêðåìåíò ñåêóíä è ìèíóò äåëàåòñÿ â öèêëå

                   IR3_H2                INC   (HL)            ;

                   LD     A, (HL)                 ;

                   CP     60               ;

                   JR     C, IR3_H1  ;

                   LD     (HL), 0                 ;

                   INC   HL              ;

                   DJNZ          IR3_H2                ; êîíåö öèêëà

                   INC   (HL)            ; èíêðåìåíò ÷àñîâ

                   LD     A, (HL)                 ;

                   CP     24               ;

                   JR     C, IR3_H1  ;

                   XOR A                ; åñëè ñ÷åò÷èê ÷àñîâ=24

                   LD     (HL), A                 ; òî îáíóëèòü âñå 4 áàéòà ÷àñîâ ðåàëüíîãî âðåìåíè

                   DEC  HL              ;

                   LD     (HL), A                 ;

                   DEC  HL              ;

                   LD     (HL), A                 ;

                   DEC  HL              ;

                   LD     (HL), A                 ;

                   ; òàéìåðû

                   IR3_H1                IN      A, (#0B)               ; çàãðóçèòü ñëîâî ñòàòóñà ôîòîýëåìåíòîâ

                   AND 1                 ;

                   JR     Z, IR3_H3  ; åñëè íå óñòàíîâëåí 1-é áèò, òî âûõîä

                   LD     HL, T2                 ; èíà÷å èíêðåìåíò Ò2

                   INC   (HL)            ;

                   JR     NZ, IR3_H4         ; åñëè èíêðåìåíò íå îáíóëèë

                   ; ïåðâûé áàéò Ò2, òî èäåì äàëüøå

                   INC   HL              ; èíà÷å óâåëè÷èòü íà 1 è âòîðîé áàéò

                   INC   (HL)            ;

                   IR3_H4                IN      A, (#0B)               ;

                   AND 2                 ; ïðîâåðèòü 2-é áèò ñòàòóñà ÔÝË

                   JR     Z, IR3_H3  ; åñëè îí íå óñòàíîâëåí, òî âûõîä

                   LD     HL, T1                 ; èíà÷å èíêðåìåíò Ò1

                   INC   (HL)            ;

                   JR     NZ, IR3_H3         ;

                   INC   HL              ;

                   INC   (HL)            ;

                   IR3_H3       POP  AF              ;

                                      POP  HL              ;

                                      POP  BC              ;

                                      RETI                    ;

Îáðàáîò÷èê IRQ4 (îò êíîïêè “+×àñ”)

Ôóíêöèÿ îáðàáîò÷èêà – óâåëè÷èòü íà åäèíèöó ÷àñû ðåàëüíîãî âðåìåíè (ÿ÷åéêà TIME+3).

Ëèñòèíã 20: îáðàáîò÷èê çàïðîñà IRQ4

                   ; – – – èíêðåìåíò ÷àñîâ

                   IR4_H         PUSH         HL              ;

                                      PUSH         AF              ;

                                      LD     HL, TIME+3;

                                      INC   (HL)            ; èíêðåìåíò ÷àñîâ

                                      LD     A, (HL)       ;

                                      CP     24               ;

                                      JR     C, IR4_H1  ;

                             XOR A                ; åñëè ñ÷åò÷èê ÷àñîâ=24

                             LD     (HL), A                 ; òî îáíóëèòü ÷àñû è ìèíóòû

                             DEC  HL              ;

                             LD     (HL), A                 ;

                   IR4_H1                POP  AF     ;

                                      POP  HL              ;

                                      RETI

Îáðàáîò÷èê IRQ5 (îò êíîïêè “+Ìèí”)

Ôóíêöèÿ îáðàáîò÷èêà – óâåëè÷èòü íà åäèíèöó ìèíóòû ðåàëüíîãî âðåìåíè (ÿ÷åéêà TIME+2).

Ëèñòèíã 21: îáðàáîò÷èê çàïðîñà IRQ5

                   ; – – – èíêðåìåíò ìèíóò

                   IR5_H         PUSH         HL              ;

                   PUSH         AF              ;

                   LD     HL, TIME+2;

                   INC   (HL)            ; èíêðåìåíò ìèíóò

                   LD     A, (HL)       ;

                   CP     60               ;

                   JR     C, IR5_H1  ;

                   XOR A                ; åñëè ñ÷åò÷èê ìèíóò=60

                   LD     (HL), A                 ; òî îáíóëåíèå ìèíóò

                   INC   HL              ; è èíêðåìåíò ÷àñîâ

                   INC   (HL)            ;

                   LD     A, (HL)       ; ñ ïðîâåðêîé ÷àñîâ íà 24

                   CP     24               ;

                   JR     C, IR5_H1  ;

                   XOR A                ; åñëè ñ÷åò÷èê ÷àñîâ=24

                   LD     (HL), A       ; òî îáíóëèòü è ÷àñû

                   IR4_H1                POP  AF     ;

                   POP  HL              ;

                   RETI

Îáðàáîò÷èê IRQ1 (îò ôîòîýëåìåíòà Ôýë2)

Îáðàáîò÷èê IRQ1 âûïîëíÿåò ñàìóþ âàæíóþ ôóíêöèþ. Åãî çàäà÷à – âû÷èñëèòü îáúåì áðåâíà. Ïîñëåäîâàòåëüíîñòü ñëåäóþùàÿ: âû÷èñëÿåì äèàìåòð áðåâíà, äëèíó, âû÷èñëÿåì îáúåì Vi, íàõîäèì îáúåì VS.

Äëÿ âû÷èñëåíèÿ äèàìåòðà âñå çíà÷åíèÿ, ïðåæäå ñ÷èòàííûå â ìàññèâ íàïðÿæåíèé ñ ÀÖÏ, óñðåäíÿþòñÿ: ñóììèðóþòñÿ è äåëÿòñÿ íà êîëè÷åñòâî (D_NUM). Ïðè ñóììèðîâàíèè ìîæåò ïðîèçîéòè ïåðåïîëíåíèå ñóììû (à îíà äâóõáàéòíàÿ), ÷òîáû ýòîãî íå áûëî, ìàññèâ ðàçáèâàåòñÿ íà ãðóïïû ïî 16 èçìåðåíèé â êàæäîé. Åñëè îñòàëàñü îñòàòî÷íàÿ ãðóïïà ñ ÷èñëîì ìåíüøå 16, òî îíà îòáðàñûâàåòñÿ.  êàæäîé èç íèõ ïîäñ÷èòûâàåòñÿ ñðåäíåå, çàòåì ðàññ÷èòûâàåòñÿ èñêîìîå êàê ñðåäíåå ñðåäíèõ.

Èç ñðåäíåãî íàïðÿæåíèÿ íàõîäèòñÿ óãîë

a=.

Çàòåì íàõîäèì äèàìåòð d=0,625 – 0,5cos a=00,A0H – 00,80Hcos a. Çàíåñòè åãî â ÿ÷åéêó DIAM (2 áàéòà â ïàìÿòè). Ñðàâíèòü äèàìåòð ñ äîïóñòèìûìè ïðåäåëàìè [0,2..0,5]=[0,33H..0,8H]. Åñëè îí âûõîäèò çà ýòè ïðåäåëû, òî âûäàòü íà îòáðàêîâêó (ïîðò 02H) åäèíèöó.

Îáúåì Vi íàõîäèòñÿ êàê Vi=(p/4)d2×T1/T2=0,C9H×d2×T1/T2.

Ëèñòèíã 22: îáðàáîò÷èê çàïðîñà IRQ1

; – – – íàéòè îáúåì áðåâíà è ñóììàðíûé îáúåì

; óñðåäíåíèå âñåõ íàïðÿæåíèé ñ äàò÷èêà äèàìåòðà â ìàññèâå ïî àäðåñó 1000H

IR1_H         PUSH         AF     ;

                   PUSH         BC    ;

                   PUSH         DE    ;

                   PUSH         HL     ;

                   LD     L, (D_NUM)        ;

                   LD     H, (D_NUM+1)    ;

                   LD     B, 4             ; äåëèì D_NUM íà 16

IR1_H1                SRL   H       ;

                   RR    L                 ;

                   DJNZ          IR1_H1       ;

                   LD     C, L   ; â ðåçóëüòàòå C=÷èñëî ãðóïï ïî 16

                   PUSH         BC              ; ñîõðàíèòü Ñ â ñòåêå

                   LD     HL, #1000  ;

                   LD     DE, 0          ; DE – íà÷àëüíàÿ ñóììà ãðóïï

          PUSH         DE              ; îòïðàâèòü åå â ñòåê, C ñòàíåò âòîðîé â ñòåêå

          PUSH         DE              ; DE – íà÷àëüíàÿ ñóììà îòäåëüíîé ãðóïïû,

                                      ; îòïðàâèòü®â ñòåê, ñóììà ãðóïï âòîðàÿ â ñòåêå

                                      ; C – òðåòüÿ â ñòåêå

IR1_H4                LD     B, 16           ;

IR1_H2                LD     E, (HL)       ; ÷èòàåì â DE ýëåìåíò ìàññèâà

          INC   HL              ;

          LD     D, (HL)       ;

          INC   HL              ;

          EX    (SP), HL     ; òåêóùóþ ñóììà â HL, òåêóùèé àäðåñ â ñòåêå

          ADD HL, DE       ;

          EX    (SP), HL     ; íîâàÿ ñóììà â ñòåêå, òåêóùèé àäðåñ â HL

          DJNZ          IR1_H2       ;

          ; â èòîãå ñóììà îäíîé ãðóïïû ïî 16 – â ñòåêå

          ; íà÷àëüíûé àäðåñ ñëåäóþùåé ãðóïïû – â HL

          POP  DE              ;

          LD     B, 4             ; íàõîäèì ñðåäíåå îäíîé ãðóïïû,

          IR1_H3       SRL   D       ; äåëÿ ñóììó â DE íà 16

          RR    E                 ;

          DJNZ          IR1_H3                ;

          POP  HL              ; áåðåì èç ñòåêà ñóììó ãðóïï

          ADD HL, DE                 ;

          PUSH         HL              ; ñíîâà îòïðàâëÿåì â ñòåê: ñíà÷àëà ñóììó ãðóïï

          PUSH         DE              ; çàòåì ñóììó îäíîé ãðóïïû

          DEC  C                 ; Ñ – ñ÷åò÷èê ãðóïï

          JR     NZ, IR1_H4         ; ñëåäóþùàÿ ãðóïïà…

          POP  HL              ;

          POP  HL              ; èçâëå÷ü íàéäåííóþ ñóììó ãðóïï

          POP  BC              ; èçâëå÷ü ñ÷åò÷èê ãðóïï C

          LD     D, C            ; DE=C.0

          LD     E, 0             ;

          CALL         DIV            ; äåëèì ñóììó ãðóïï íà ÷èñëî ãðóïï

          ; òåïåðü HL=Ud=ñðåäíåå âñåãî ìàññèâà íàïðÿæåíèé äàò÷èêà

          ; ñëåäóþùèé øàã – íàõîæäåíèå óãëà a, cos a, d

          LD     D, 4            ; DE=491H

          LD     E, #91                  ;

          LD     B, H            ; ñîõðàíèòü Ud â BC

          LD     C, L            ;

          EX    DE, HL                 ;

          CALL         MINUS                ; HL=491H-Ud

          EX    HL, DE                 ;

          LD     H, B            ;

          LD     L, C            ;

          CALL         DIV            ; HL= Ud/(491H-Ud)

          LD     D, 0            ;

          LD     E, #4F                  ;

          CALL         MUL           ; HL=a

          CALL         COS            ; HL=cos a

          LD     D, 0            ;

          LD     E, #80                  ;

          CALL         MUL           ; HL=0,5cos a

          LD     D, 0            ;

          LD     E, #A0                  ;

          EX    HL, DE                 ;

          CALL         MINUS                ; HL=0,625-0,5cos a=d

          LD     (DIAM), HL         ; çàíåñòè äèàìåòð â ïàìÿòü

          ; ôîðìèðóåì ñèãíàë îòáðàêîâêè

          LD     A, L            ;

          CP     #33             ;

          JR     NC, IR1_H5         ; åñëè d>20, òî èäåì äàëüøå

          LD     A, 1            ; èíà÷å â ïîðò îòáðàêîâêè çàïèñàòü 1

          OUT  (#02), A                ;

          JR     IR1_OUT   ; è âûõîä, íå ñ÷èòàÿ îáúåì

          IR1_H5                LD     A, L            ;

          CP     #80             ;

          JR     C, IR1_H6  ; åñëè d<50, òî èäåì äàëüøå

          LD     A, 1            ; èíà÷å â ïîðò îòáðàêîâêè çàïèñàòü 1

          OUT  (#02), A                ;

          ; äàëüøå íàõîäèì Vi, VS

          IR1_H6                LD     L, (T1)        ;

          LD     H, (T1+1)   ;

          LD     E, (T2)                  ;

          LD     D, (T2+1)   ;

          CALL         DIV            ; HL=T1/T2

          LD     E, (DIAM)  ;

          LD     D, (DIAM+1)       ;

          PUSH         DE              ;

          CALL         MUL           ; HL=T1×d/T2

          POP  DE              ;

          CALL         MUL           ; HL=T1×d2/T2

          LD     D, 0            ;

          LD     E, #C9                  ;

          CALL         MUL           ; HL=(p/4)T1×d2/T2=Vi

          EX    HL, DE                 ;

          LD     L, (V_SUM)         ;

          LD     H, (V_SUM+1)    ;

          CALL         PLUS                   ; HL=VS

          LD     (V_SUM), HL      ; çàíåñòè ñóììàðíûé îáúåì â ïàìÿòü

          IR1_OUT   POP  HL     ;

          POP  DE              ;

          POP  BC              ;

          POP  AF              ;

          RETI                    ;

Îñíîâíàÿ èñïîëíÿåìàÿ ÷àñòü ïðîãðàììû

Ýòó ÷àñòü, êîòîðàÿ, ñîáñòâåííî, è ÿâëÿåòñÿ óïðàâëÿþùåé ïðîãðàììîé, ìèêðîïðîöåññîð âûïîëíÿåò áîëüøóþ ÷àñòü ñâîåãî âðåìåíè, èçðåäêà îòâëåêàÿñü îò íåå íà îáðàáîòêó ïðåðûâàíèé.

Åå ôóíêöèè:

ïðî÷åñòü VS èç ÿ÷åéêè V_SUM, ïåðåâåñòè åãî â 2-10 êîä (ïîäïðîãðàììû B2D, B2D_F), ïåðåâåñòè êàæäóþ öèôðó â ñåìèñåãìåíòíûé êîä (ïîäïðîãðàììà D27) è âûâåñòè â ïîðò èíäèêàòîðîâ (03-0A), ïðèñîåäèíèâ äåñÿòè÷íóþ çàïÿòóþ â èíäèêàòîðå 06Í;

ïðî÷åñòü âðåìÿ èç ÿ÷åéêè TIME (TIME+1–ñåêóíäû, TIME+2–ìèíóòû, TIME+3–÷àñû), ïåðåâåñòè åãî â 2-10 êîä, ïåðåâåñòè êàæäóþ öèôðó â ñåìèñåãìåíòíûé êîä è âûâåñòè â ïîðò èíäèêàòîðîâ (13-1A), ïðèñîåäèíèâ äåñÿòè÷íóþ çàïÿòóþ â èíäèêàòîðàõ 13Í, 15Í, 17Í.

Ðèñ. 7 Ðàñïîëîæåíèå îáúåìà è âðåìåíè íà èíäèêàòîðàõ

Ëèñòèíã 23: îñíîâíàÿ ÷àñòü

          ; – – – âûâåñòè íà èíäèêàòîðû îáúåì è âðåìÿ

          ; âûâîä îáúåìà

          MAIN                   LD     E, (V_SUM)         ;

          LD     D, (V_SUM+1)    ; D.E – ñóììàðíûé îáúåì

                                      ; âûâîäèì öåëóþ ÷àñòü D

          LD     C, D            ;

          CALL         B2D  ; HL=2-10 êîä D

          LD     A, H            ;

          CALL         D27   ; â ñåìèñåãìåíòíûé êîä

          OUT  (#08), A      ; âûâåñòè â ïîðò

          LD     A, H            ;

          AND #0F             ;

          CALL         D27   ;

          OR    #80             ; ïðèìåøàòü äåñÿòè÷íóþ çàïÿòóþ

          OUT  (#06), A      ; âûâåñòè â ïîðò

          LD     A, H            ;

          RR    A                ; ÷åòûðåæäû ñäâèãàåì âïðàâî

          RR    A                ;

          RR    A                ;

          RR    A                ;

          AND #0F             ;

          CALL         D27   ;

          OUT  (#07), A      ; âûâåñòè â ïîðò

                                      ; âûâîäèì äðîáíóþ ÷àñòü E

          LD     L, E             ;

          CALL         B2D_F        ; ABC=òðè öèôðû 2-10 êîäà ÷èñëà 0.L

          CALL         D27            ;

          OUT  (#05), A                ; âûâåñòè â ïîðò

          LD     A, B            ;

          CALL         D27            ;

          OUT  (#04), A                ; âûâåñòè â ïîðò

          LD     A, C            ;

          CALL         D27            ;

          OUT  (#03), A                ; âûâåñòè â ïîðò

          ; âûâîä òåêóùåãî âðåìåíè

          LD     HL, (TIME+1)      ; HL=àäðåñ ñåêóíä

          LD     B, #13                  ; ñàìûé ïðàâûé èíäèêàòîð

          MAIN1       PUSH         HL     ;

          LD     A, (HL)                 ;

          LD     C, A            ;

          CALL         B2D            ; HL=2-10 êîä ñåêóíä/ìèíóò/÷àñîâ (ïðè÷åì Í=0)

          LD     A, L            ;

          AND #0F             ;

          CALL         D27   ;

          OR    #80             ; ïðèìåøàòü çàïÿòóþ

          OUT  (B), A                   ; âûâåñòè â ïîðò

          INC   B                 ; ñëåäóþùèé èíäèêàòîð

          LD     A, L            ;

          RR    A                ; ÷åòûðåæäû ñäâèãàåì À âïðàâî

          RR    A                ;

          RR    A                ;

          RR    A                ;

          AND #0F             ;

          CALL         D27            ;

          OUT  (B), A                   ; âûâåñòè â ïîðò

          INC   B                 ; ñëåäóþùèé èíäèêàòîð

          POP  HL              ;

          INC   HL              ; ïåðåéòè ê ñëåäóþùåé ÿ÷åéêå (TIME+2, TIME+3)

          LD     A, B            ;

          CP     #08             ; ïðîâåðêà êîíöà öèêëà

          JR     NZ, MAIN1          ;

          JP      MAIN                   ; íà÷èíàåì âñå ñíà÷àëà

Îáùàÿ ñòðóêòóðà ÏÇÓ ìèêðîïðîöåññîðíîé ñèñòåìû

Íàêîíåö, ïðèâåäåì êàðòû ÏÇÓ è ÎÇÓ ìèêðîïðîöåññîðíîé ñèñòåìû.

ÏÇÓ

0000 DI
0001

Íà÷àëî òåñòîâ

TST_RAM

JR 0038

0020

Ðàñïðåäåëèòåëü îáðàáîò÷èêîâ ïðåðûâàíèé

0020 JP IR_H0

0024 JP IR_H1

0028 JP IR_H2

002C JP IR_H3

0030 JP IR_H4

0034 JP IR_H5

0038

Ïðîäîëæåíèå òåñòà ÎÇÓ (TST_RAM)

TST_ROM

TST_FEL

INI_PIC

INI_VAR

EI
LD SP, #0FFF

Ãëàâíûé öèêë ïðîãðàììû

MAIN

Ïîäïðîãðàììû

E_RAM

E_ROM

PLUS

MINUS

MUL

DIV

COS_A

COS

B2D

B2D_F

MUL10

D27

Îáðàáîò÷èêè

IR_H0

IR_H1

IR_H2

IR_H3

IR_H4

IR_H5

Îáëàñòü íóëåé 00000000
0700 Òàáëèöà ïåðåêîäèðîâêè
070F 00000000
07FF Ïîñëåäíèé áàéò (äîïîëíåíèå êîíòðîëüíîé ñóììû äî íóëÿ)

Îáùàÿ ñòðóêòóðà ÎÇÓ ìèêðîïðîöåññîðíîé ñèñòåìû. ÎÇÓ

0800 V_SUM
0802 DIAM
0804 TIME
0808 T1
080A T2
080C D_NUM
080D
0FFF ­ ÎÁËÀÑÒÜ ÑÒÅÊÀ ­
1000

Ìàññèâ íàïðÿæåíèé

ñ äàò÷èêà äèàìåòðà

(2Ê)

1FFF Êîíåö ÎÇÓ

Çàêëþ÷åíèå

 ðåçóëüòàòå ïðîäåëàííîé ðàáîòû ìû ïîëó÷èëè ñèñòåìó, îòáðàêîâûâàþùèå áðåâíà, íå ãîäíûå äëÿ ðàñïèëèâàíèÿ è ïîýòîìó îòáðàñûâàþùèåñÿ â ñòîðîíó. Åñëè áðåâíî íàì ïîäõîäèò, òî èäåò ïîäñ÷åò åãî îáúåìà è ïîäñ÷åò âñåõ áðåâåí, ïðîøåäøèõ ðàñïèë. Òàêæå ñ÷èòàåòñÿ âðåìÿ íàðàáîòêè.


ÏÅÐÅ×ÅÍÜ ÝËÅÌÅÍÒÎÂ

Ïîç. îáîçí. Íàèìåíîâàíèå Êîë. Ïðèìå÷àíèå
DD1 Ìèêðîñõåìà Z-80 1
DD2, DD4 Ìèêðîñõåìà Ê155ÈÐ13 2
DD3, DD5 Ìèêðîñõåìà Ê537ÐÓ8 2
DD6 Ìèêðîñõåìà Ê1118ÏÂ1 1
DD7 Ìèêðîñõåìà Ê546ÈÐ5 1
DD8 Ìèêðîñõåìà Ê155ÈÄ3 1
DD9 Ìèêðîñõåìà Ê541ÐÅ1 1
DD10 Ìèêðîñõåìà Ê580ÂÍ59À 1
DD11 Ìèêðîñõåìà Ê155ËÄ7 1

Rd

Ðåçèñòîð ÌËÒ-5.1Ê 1
R1, R3 Ðåçèñòîð ÌËÒ-10Ê 4

R 2, Räîá

Ðåçèñòîð ÌËÒ-1Ê 3
R9, R10

Ðåçèñòîð ÌËÒ-1-13 êÎì À

ÒÓ ÎÆÎ 467 003

2
R11, R12

Ðåçèñòîð ÌËÒ-1-510 êÎì À

ÒÓ ÎÆÎ 467 003

2

R8,

R13 – R16

Ðåçèñòîð ÌËÒ-0.5-1 êÎì À

ÒÓ ÎÆÎ 467 003

C1, C8, C9

Êîíäåíñàòîð ÌÁÌ – 16 Â – 0,47 ìêÔ

ÒÓ ÓÁÎ 462 014

7
C6

Êîíäåíñàòîð ÌÁÌ – 16 Â – 0,1 ìêÔ

ÒÓ ÓÁÎ 462 014

1
C7

Êîíäåíñàòîð ÌÁÌ – 16 Â – 0,15 ìêÔ

ÒÓ ÓÁÎ 462 014

1
1

2101 420 000 019 ÏÝ

Èçì

Ëèñò

¹ äîêóì.

Ïîäï.

Äàòà

Ðàçðàá.

Ìîëîêîâ Ò

Ìèêðîïðîöåññîðíàÿ ñèñòåìà óïðàâëåíèÿ, ïðåäíàçíà÷åííàÿ äëÿ èñïîëüçîâàíèÿ íà ëåñîïèëüíîì çàâîäå

Ïåðå÷åíü ýëåìåíòîâ

Ëèò.

Ëèñò.

Ëèñòîâ

Äàíèëîâ Ä.

Ïðîâ.

Ìîêðåöîâ Â.

ÓÃÒÓ – ÓÏÈ

ÐÒÔ ãð. Ж311À

Êàôåäðà ÀÓÒÑ

Í.Êîíòð.

Êàëèíèí Í.Ñ

Óòâ.


Ñòðàíèöû: 1, 2


© 2010 ÑÀÉÒ ÐÅÔÅÐÀÒÎÂ