-
Notifications
You must be signed in to change notification settings - Fork 3
/
cget.c
79 lines (75 loc) · 2.43 KB
/
cget.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
*******************************************************************
*** 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* cget(char* line) {
byte fnum;
int i;
char token[256];
line = trim(line);
if (*line != '#') {
showError("Syntax error");
*line = 0;
return line;
}
line++;
if (*line < '1' || *line > '8') {
showError("Syntax error");
*line = 0;
return line;
}
fnum = *line - '1';
line++;
line = trim(line);
sprintf(buffer," ldi (file1_+%d*2).0 ; Point to file handle",fnum % 256);
Asm(buffer);
Asm(" plo rf");
sprintf(buffer," ldi (file1_+%d*2).1",fnum / 256);
Asm(buffer);
Asm(" phi rf");
Asm(" lda rf ; Retrieve FILDES");
Asm(" phi rd");
Asm(" lda rf");
Asm(" plo rd");
while (*line != ':' && *line != 0) {
line=trim(line);
i = 0;
while (*line != 0 && *line > ' ' && *line != ',' && *line != ':') {
token[i++] = *line++;
}
token[i] = 0;
i = getVariable(token);
sprintf(buffer," ldi v_%s.1 ; get address of variable data",token);
Asm(buffer);
Asm(" phi rf");
sprintf(buffer," ldi v_%s.0",token);
Asm(buffer);
Asm(" plo rf");
Asm(" ldi 0 ; set high byte of count to zero");
Asm(" phi rc");
if (useFp || use32Bits) {
Asm(" ldi 4 ; set low byte of count to 4");
Asm(" plo rc");
}
else {
Asm(" ldi 2 ; set low byte of count to 2");
Asm(" plo rc");
}
Asm(" sep scall ; Call Elf/OS to read value");
Asm(" dw 0309h");
line=trim(line);
if (*line == ',') {
line++;
line = trim(line);
}
}
Asm(" sep scall ; Set I/O return variables");
Asm(" dw ioresults");
return line;
}