forked from rileym65/Basic-02
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcput.c
More file actions
96 lines (92 loc) · 3.27 KB
/
Copy pathcput.c
File metadata and controls
96 lines (92 loc) · 3.27 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
*******************************************************************
*** 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* cput(char* line) {
byte fnum;
line = trim(line);
if (*line != '#') {
showError("Syntax error");
exit(1);
}
line++;
if (*line < '1' || *line > '8') {
showError("Syntax error");
exit(1);
}
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);
Asm(" ghi rd ; save FILDES");
Asm(" stxd");
Asm(" glo rd");
Asm(" stxd");
line = cexpr(line, 2);
Asm(" inc r7 ; Point to expression result");
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");
Asm(" ldi (iobuffer+3).1 ; point to i/o buffer");
Asm(" phi rf");
Asm(" ldi (iobuffer+3).0");
Asm(" plo rf");
Asm(" lda r7 ; and remove expression from stack");
Asm(" str rf");
Asm(" dec rf");
Asm(" lda r7");
Asm(" str rf");
Asm(" dec rf");
Asm(" lda r7");
Asm(" str rf");
Asm(" dec rf");
Asm(" ldn r7");
Asm(" str rf");
}
else {
Asm(" ldi 2 ; set low byte of count to 2");
Asm(" plo rc");
Asm(" ldi (iobuffer+1).1 ; point to i/o buffer");
Asm(" phi rf");
Asm(" ldi (iobuffer+1).0");
Asm(" plo rf");
Asm(" lda r7 ; and remove expression from stack");
Asm(" str rf");
Asm(" dec rf");
Asm(" ldn r7");
Asm(" str rf");
}
Asm(" irx ; Retrieve FILDES");
Asm(" ldxa");
Asm(" plo rd");
Asm(" ldx");
Asm(" phi rd");
Asm(" sep scall ; Call Elf/OS to write value");
Asm(" dw 030ch");
line=trim(line);
if (*line == ',') {
line++;
line = trim(line);
}
}
return line;
}