-
Notifications
You must be signed in to change notification settings - Fork 0
/
rom.c
45 lines (38 loc) · 874 Bytes
/
rom.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// ROM
//
void buildRomAreaStruct() {
int i = 0;
ROMArea lastRa = CODE;
//uint rasIndex = 0;
while(i < numSymbols) {
if(ORG == symbolTable[i].area) {
i++;
continue;
}
if(lastRa != symbolTable[i].area) {
lastRa = symbolTable[i].area;
ras[rasIndex].address = symbolTable[i].addr;
ras[rasIndex].area = symbolTable[i].area;
rasIndex++;
}
i++;
}
}
ROMArea getRomArea(word binCurrPos, ROMArea ra, bool reset) {
ROMArea ret = ra;
for(int i = 0; i < rasIndex; i++) {
if(binCurrPos == ras[i].address) {
ret = ras[i].area;
break;
} else if(binCurrPos < ras[i].address) {
ret = ras[i-1].area;
break;
}
}
return ret;
}
void updateRomArea(byte* buffPtr, ROMArea* ra, bool reset) {
word binCurrPos = getBinPos(buffPtr);
*ra = getRomArea(binCurrPos, *ra, reset);
}