forked from rileym65/Basic-02
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrestore.c
More file actions
68 lines (64 loc) · 2 KB
/
Copy pathcrestore.c
File metadata and controls
68 lines (64 loc) · 2 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
*******************************************************************
*** This software is copyright 2021 by Michael H Riley ***
*** You have permission to use, modify, copy, and distribute ***
*** this software so long as this copyright notice is retained. ***
*** This software may not be used in commercial applications ***
*** without express written permission from the author. ***
*******************************************************************
*/
#include "header.h"
char* crestore(char* line) {
int i;
word pos;
word num;
line = trim(line);
pos = 0;
if (passNumber == 2) {
if (*line != ':' && *line != 0) {
if (*line < '0' || *line > '9') {
showError("Invalid line number");
exit(1);
}
num = 0;
while (*line >= '0' && *line <= '9') {
num = (num * 10) + (*line - '0');
line++;
}
pos = 0xffff;
for (i=0; i<numDataLines; i++) {
if (dataLines[i] == num) {
pos = dataPositions[i];
i = numDataLines;
}
}
if (pos == 0xffff) {
showError("Line number not found");
exit(1);
}
}
}
else {
while (*line != ':' && *line != 0) line++;
}
line = trim(line);
Asm(" ldi DATA_.1 ; Get address of DATA pointer");
Asm(" phi rf");
Asm(" ldi DATA_.0");
Asm(" plo rf");
if (use32Bits) {
sprintf(buffer," ldi (%d*4+data).1 ; Need a SEP R3 command",pos); Asm(buffer);
Asm(" str rf");
Asm(" inc rf");
sprintf(buffer," ldi (%d*4+data).0",pos); Asm(buffer);
Asm(" str rf");
}
else {
sprintf(buffer," ldi (%d*2+data).1 ; Need a SEP R3 command",pos); Asm(buffer);
Asm(" str rf");
Asm(" inc rf");
sprintf(buffer," ldi (%d*2+data).0",pos); Asm(buffer);
Asm(" str rf");
}
return line;
}