summaryrefslogtreecommitdiff
path: root/frontends/calculator/CEdev/examples/fileio_detectany/obj/main.src
blob: 4e2f65536771bf6ca4d62c0d7b53d9ceb01aec74 (plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
; Zilog eZ80 ANSI C Compiler Release 3.4
; -optsize -noreduceopt -nomodsect -peephole -globalopt
; -localcse -const=ROM 
	FILE	"SRC\MAIN.C"
	.assume ADL=1
	SEGMENT CODE
;    1	#include <stdbool.h>
;    2	#include <stddef.h>
;    3	#include <stdint.h>
;    4	#include <tice.h>
;    5	
;    6	#include <stdio.h>
;    7	#include <stdlib.h>
;    8	#include <string.h>
;    9	
;   10	#include <fileioc.h>
;   11	
;   12	/* Function prototypes */
;   13	void printText(int8_t xpos, int8_t ypos, const char *text);
;   14	
;   15	/* Main Function */
;   16	void main(void) {
_main:
	LD	HL,-11
	CALL	__frameset
;   17	    /* Declare some variables -- search_pos must be NULL to begin with */
;   18	    uint8_t *search_pos = NULL, type;
	LD	BC,0
	LD	(IX+-11),BC
;   19	    int8_t y = 0;
	LD	(IX+-1),0
;   20	    ti_var_t myVar;
;   21	    char *var_name;
;   22	
;   23	    /* First couple bytes of the LibLoad AppVar, which is known to exist *
;   24	    /* Technically is a null-terminated string, if an odd looking one */
;   25	    const char search_string[] = { 0xBF, 0xFE, 0x00 };
	LEA	DE,IX+-8
;   26	
;   27	    /* Clear the homescreen */
;   28	    os_ClrHome();
	LD	BC,_asm_ClrLCD
	PUSH	BC
	LD	HL,_0temp0
	LD	BC,3
	LDIR	
	CALL	__OS
	POP	BC
	LD	BC,_asm_HomeUp
	PUSH	BC
	CALL	__OS
	POP	BC
	LD	BC,_asm_DrawStatusBar
	PUSH	BC
	CALL	__OS
	POP	BC
	JR	L_5
;   29	
;   30	    /* Find all of the variables that start with this string */
;   31	    while ((var_name = ti_DetectAny(&search_pos, search_string, &type)) != NULL) {
L_6:
;   32	        if (type == TI_APPVAR_TYPE) {
	LD	A,(IX+-2)
	CP	A,21
	JR	NZ,L_5
;   33	            /* Print the name of the variable (Should be LibLoad) */
;   34	            printText(0, y++, var_name);
	LD	C,(IX+-1)
	INC	(IX+-1)
	LD	DE,(IX+-5)
	PUSH	DE
	LD	B,0
	PUSH	BC
	LD	BC,0
	PUSH	BC
	CALL	_printText
	POP	BC
	POP	BC
	POP	BC
;   35	        }
;   36	    }
L_5:
	PEA	IX+-2
	PEA	IX+-8
	PEA	IX+-11
	CALL	_ti_DetectAny
	POP	BC
	POP	BC
	POP	BC
	LD	(IX+-5),HL
	CALL	__icmpzero
	JR	NZ,L_6
;   37	
;   38	    /* Wait for a key */
;   39	    while (!os_GetCSC());
L_9:
	CALL	_os_GetCSC
	OR	A,A
	JR	Z,L_9
;   40	
;   41	    /* Close all open files */
;   42	    ti_CloseAll();
	CALL	_ti_CloseAll
;   43	}
	LD	SP,IX
	POP	IX
	RET	


;**************************** _main ***************************
;Name                         Addr/Register   Size   Type
;_ti_CloseAll                        IMPORT  -----   function
;_os_GetCSC                          IMPORT  -----   function
;_ti_DetectAny                       IMPORT  -----   function
;_printText                          IMPORT  -----   function
;_asm_DrawStatusBar                  IMPORT  -----   function
;_asm_HomeUp                         IMPORT  -----   function
;_asm_ClrLCD                         IMPORT  -----   function
;__OS                                IMPORT  -----   function
;_0temp0                             STATIC      3   variable
;search_pos                           IX-11      3   variable
;search_string                         IX-8      3   variable
;var_name                              IX-5      3   variable
;type                                  IX-2      1   variable
;y                                     IX-1      1   variable


; Stack Frame Size: 17 (bytes)
;       Spill Code: 0 (instruction)


	SEGMENT TEXT
_0temp0:
	DB	191
	DB	254
	DB	0
	SEGMENT CODE
;   44	
;   45	/* Draw text on the homescreen at the given X/Y location */
;   46	void printText(int8_t xpos, int8_t ypos, const char *text) {
_printText:
	CALL	__frameset0
;   47	    os_SetCursorPos(ypos, xpos);
	LD	C,(IX+6)
	LD	B,0
	PUSH	BC
	LD	C,(IX+9)
	PUSH	BC
	CALL	_os_SetCursorPos
	POP	BC
	POP	BC
;   48	    os_PutStrFull(text);
	LD	BC,(IX+12)
	PUSH	BC
	CALL	_os_PutStrFull
	POP	BC
;   49	}
	LD	SP,IX
	POP	IX
	RET	


;**************************** _printText ***************************
;Name                         Addr/Register   Size   Type
;_os_PutStrFull                      IMPORT  -----   function
;_os_SetCursorPos                    IMPORT  -----   function
;text                                 IX+12      3   parameter
;ypos                                  IX+9      1   parameter
;xpos                                  IX+6      1   parameter


; Stack Frame Size: 15 (bytes)
;       Spill Code: 0 (instruction)


	XREF _ti_DetectAny:ROM
	XREF _ti_CloseAll:ROM
	XREF _asm_DrawStatusBar:ROM
	XREF _asm_ClrLCD:ROM
	XREF _asm_HomeUp:ROM
	XREF __OS:ROM
	XREF _os_GetCSC:ROM
	XREF _os_PutStrFull:ROM
	XREF _os_SetCursorPos:ROM
	XREF __frameset0:ROM
	XREF __frameset:ROM
	XREF __icmpzero:ROM
	XDEF _printText
	XDEF _main
	END