Äîêóìåíòàöèÿ ïî ARM7
https://www.ele.uva.es/~jesman/BigSeti/ftp/Microcontroladores/ARM/Arm7%20Datasheet.pdf
Èñêëþ÷èòåëüíûå ñèòóàöèè — ïðåðûâàíèÿ.
Äëÿ êàæäîãî ïðåðûâàíèÿ åñòü ïðîöåäóðà, êîòîðàÿ åãî îáðàáàòûâàåò.
Òàáëèöà ñ àäðåñàìè ýòèõ ïðîöåäóð — òàáëèöà âåêòîðîâ ïðåðûâàíèé.
1. Reset – ïåðåçàãðóçêà èëè âêëþ÷åíèå ïèòàíèÿ.
2. Undefined instruction – ïðîöåññîð íå ìîæåò äåêîäèðîâàòü èíñòðóêöèþ (íàïðèìåð, êîãäà äàííûå òðàêòóþòñÿ êàê èíñòðóêöèÿ; ïðîèñõîäèò, íàïðèìåð, êîãäà óïðàâëåíèå ïåðåäàþò íà íåâåðíûé àäðåñ).
3. Software interrupt – ïðîãðàììíîå ïðåðûâàíèå, êîòîðîå ìîæíî âûçâàòü èç ïðîãðàììû (íàïðèìåð, â àðõèòåêòóðå Intel ïðåðûâàíèå — èíñòðóêöèÿ int3, èñïîëüçóåòñÿ â îòëàä÷èêå). Gdb – ìîæíî ñòàâèòü êàê hardware ïðåðûâàíèÿ (èñïîëüçóþòñÿ, íàïðèìåð, êîãäà ïàìÿòü íå èíèöèàëèçèðîâàíà), òàê è software ïðåðûâàíèÿ — âìåñòî òîé èíñòðóêöèè, íà êîòîðóþ ñòàâèòñÿ òî÷êà ïðåðûâàíèÿ (breakpoint), çàïèñûâàåòñÿ èíñòðóêöèÿ int3, à ïðåæíÿÿ èíñòðóêöèÿ ñîõðàíÿåòñÿ. Ïðè âûïîëíåíèè ïðîãðàììû, åñëè ïðîèñõîäèò software ïðåðûâàíèÿ, òî êîä èíñòðóêöèè ïîäñòàâëÿåòñÿ íàçàä è îòëàä÷èê ïîêàçûâàåò èñõîäíûå êîäû ïðîãðàììû.
4. Instruction abort – îøèáêà èçâëå÷åíèÿ èíñòðóêöèè. Îòëè÷àåòñÿ îò undefined instruction òåì, ÷òî òàì êîä èíñòðóêöèè áûë èçâëå÷åí, íî îêàçàëñÿ íåâåðíûì (íå êîäîì èíñòðóêöèè).  äàííîì ïðåðûâàíèè íåâîçìîæíî îêàçàëîñü èçâëå÷ü ñîäåðæèìîå ïàìÿòè ïî àäðåñó, ïî êîòîðîìó åãî ïûòàëèñü èçâëå÷ü.
5. Data abort – îøèáêà èçâëå÷åíèÿ äàííûõ.
6. Reserved – íå èñïîëüçóåòñÿ â ARM, ïðîèçâîäèòåëè æåëåçà ìîãóò åãî èñïîëüçîâàòü íà ñâîå óñìîòðåíèå.
7. IRQ – INterrupt Query – çàïðîñ íà ïðåðûâàíèå.
8. FIQ – Fast Interrupt Query – çàïðîñ íà ïðåðûâàíèå, êîòîðîå äîëæíî áûòü îáñëóæåíî íåìåäëåííî.
Ñóùåñòâóåò èåðàðõèÿ ïî ïðèîðåòàì. FIQ – ñàìûé âûñîêèé ïðèîðèòåò.
Íåñêîëüêî òèïîâ ïàìÿòè:
- âíåøíÿÿ ïàìÿòü — äåøåâàÿ è ìåäëåííàÿ
- îïåðàòèâíàÿ ïàìÿòü — áîëåå äîðîãàÿ è áîëåå áûñòðàÿ
- êåø-ïàìÿòü — åùå áîëåå äîðîãàÿ è åùå áîëåå áûñòðàÿ
- ðåãèñòðû ïðîöåññîðà — ñîâñåì äîðîãàÿ è ñîâñåì áûñòðàÿ. Íàõîäÿòñÿ â ÿäðå, ìàêñèìàëüíî áëèçêî ê ÀËÓ (àðèôìåòèêî-ëîãè÷åñêîå óñòðîéñòâî). Ðåãèñòðîâ î÷åíü ìàëî.
V – oVerflow – áèò ðàâåí 1, åñëè ïîñëåäíÿÿ èíñòðóêöèÿ âûçâàëà ïåðåïîëíåíèå ÿ÷åéêè ïàìÿòè. Íàïðèìåð, R1 + R2 → R3
0xFFFFFFFF + 0xFFFFFFFF = 0x1FFFFFFFE → R3 = 0xFFFFFFFE, áèò V = 1, òàê êàê ïðîèçîøëî ïåðåïîëíåíèå ïðè ñëîæåíèè.
(16-ðè÷íîå èñ÷èñëåíèå: 0, 1, 2, …, 9, A, B, C, D, E, F, öèôðû — êîýôôèöèåíòû ïðè ñòåïåíÿõ 16).
Ñ — Carry – áèò ïåðåíîñà. Èñïîëüçóåòñÿ, íàïðèìåð, ïðè ñäâèãàõ ñîäåðæèìîãî ðåãèñòðà âïðàâî èëè âëåâî.
Ðåãèñòð:
31 |
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
0 |
0 |
1 |
1 |
1 |
Ïðè ñäâèãå âïðàâî (áèòû ñäâèãàþòñÿ â ñòîðîíó ñîñåäíåãî ìëàäøåãî áèòà) ìëàäøèé áèò âûéäåò èç ñîäåðæèìîãî ðåãèñòðà. ×òîáû íå ïîòåðÿòü åãî çíà÷åíèÿ, îíî ïîìåùàåòñÿ â áèò Carry.
Ðåãèñòð:
31 |
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
3 |
2 |
1 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
0 |
0 |
0 |
1 |
1 |
Carry: 1
C:
short x;
x >>= 1;
Ïðîâåðèòü áèò Carry â C íåëüçÿ.
Z – Zero – áèò ðàâåí 1, åñëè ðåçóëüòàò ïîñëåäíåé èíñòðóêöèè ðàâåí íóëþ
N – Negative – áèò ðàâåí 1, åñëè ðåçóëüòàò ïîñëåäíåé èíñòðóêöèè îòðèöàòåëüíûé
Ïðèìåðû:
ASR R1, #1 – Arithmetic Shift Right (àðèôìåòè÷åñêèé ñäâèã âïðàâî).
R1 = 0x7 => R1 = 0x3, NZVC=0001
ROR R1, #1 – ROtate Right (öèêëè÷åñêèé ñäâèã âïðàâî)
R1 = 0x7 => R1 = 0x80000003, NZVC=1000
Ðåãèñòð:
31 |
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
0 |
0 |
1 |
1 |
1 |
31 |
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
3 |
2 |
1 |
0 |
1 |
0 |
0 |
0 |
0 |
0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
0 |
0 |
0 |
1 |
1 |
Ïðîãðàììèðîâàíèå äëÿ ARM:
gcc – åñòü êðîññ-ïëàòôîðìåííûé (arm-linux-gcc è ò. ï.)
Åñòü äëÿ cygwin (https://www.artila.com/download/9200/Linux/toolchain/Cygwin/Cygwin%20Installation%20Guide.pdf, https://sourceforge.net/projects/armlinux4cygwin/, …)
Íà Ëèíóêñ — ñêà÷èâàåòå èñõîäíèêè gcc, êîìïèëèðóåòå äëÿ êðîññ-ïëàòôîðìåííîé êîìïèëÿöèè (TARGET_ARCH=arm).
Âûïîëíåíèå:
1.
Ïðîøèâêà — çàãðóæàåòå íà óñòðîéñòâî (íàïðèìåð, ðîóòåð).
Åñòü ñàéòû ñ îòêðûòûìè èñõîäíûìè òåêñòàìè ïðîøèâîê äëÿ ðîóòåðîâ è
äðóãèõ óñòðîéñòâ. OpenWRT(?)
2. Ñèìóëÿòîðû. gdb – åñòü ðåæèì ñèìóëÿöèè ARM.
3. Evaluation board, JTAG – èíòåðôåéñ äëÿ ïîäñîåäèíåíèÿ ïå÷àòíîé ïëàòû ê êîìïüþòåðó.
Íóæåí áûë ñèìóëÿòîð WiFi êàðòî÷êè. Ïåðèôåðèþ ñèìóëèðîâàëè ñàìè (ïî ñïåöèôèêàöèÿì), ARM – íóæåí ãîòîâûé ñèìóëÿòîð.  gdb – îêàçàëñÿ ñàìûé ëó÷øèé ñèìóëÿòîð.