Skip to content

Commit 203fe71

Browse files
committed
ti/vars: add os_DelVar() and arcUnarcVariable()
1 parent 2e07062 commit 203fe71

File tree

3 files changed

+152
-0
lines changed

3 files changed

+152
-0
lines changed

src/ce/arc_unarc.src

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
section .text,"ax",@progbits
2+
assume adl = 1
3+
4+
; bool arcUnarcVariable(uint8_t varType, uint8_t nameLen, const char *name)
5+
; {
6+
; const int err = os_PushErrorHandler();
7+
; if (err) {
8+
; return false;
9+
; }
10+
; *(os_OP1) = varType;
11+
; __builtin_memcpy((char*)(os_OP1+1), name, nameLen);
12+
; *(os_OP1+1+nameLen) = '\0';
13+
; asm volatile (
14+
; "call 021448h" // Arc_Unarc
15+
; :
16+
; : [flags] "iyl" (os_Flags)
17+
; : "cc", "a", "bc", "de", "hl", "ix", "iy"
18+
; );
19+
; os_PopErrorHandler();
20+
; return true;
21+
; }
22+
public _arcUnarcVariable
23+
_arcUnarcVariable:
24+
push ix
25+
ld hl, -6
26+
call __frameset
27+
call _os_PushErrorHandler
28+
add hl, bc
29+
or a, a
30+
sbc hl, bc
31+
jr nz, BB1_2
32+
ld (ix - 3), hl
33+
ld e, (ix + 12)
34+
ld iy, (ix + 15)
35+
ld bc, -3144199
36+
ld a, (ix + 9)
37+
ld (-3144200), a
38+
or a, a
39+
sbc hl, hl
40+
ld l, e
41+
ld (ix - 6), hl
42+
push hl
43+
push iy
44+
push bc
45+
call _memcpy
46+
pop hl
47+
pop hl
48+
pop hl
49+
ld hl, -3144199
50+
ld de, (ix - 6)
51+
add hl, de
52+
ld (hl), 0
53+
ld iy, $D00080 ; flags
54+
call 021448h ; Arc_Unarc
55+
call _os_PopErrorHandler
56+
ld hl, (ix - 3)
57+
BB1_2:
58+
add hl, bc
59+
or a, a
60+
sbc hl, bc
61+
jr z, BB1_4
62+
ld a, 0
63+
jr BB1_5
64+
BB1_4:
65+
ld a, -1
66+
BB1_5:
67+
ld sp, ix
68+
pop ix
69+
pop ix
70+
ret
71+
72+
extern _os_PushErrorHandler
73+
extern _os_PopErrorHandler
74+
extern __frameset
75+
extern _memcpy

src/ce/include/ti/vars.h

+18
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#ifndef TI_VARS_H
1313
#define TI_VARS_H
1414

15+
#include <stdbool.h>
1516
#include <stdint.h>
1617
#include <stddef.h>
1718
#include <ti/real.h>
@@ -291,6 +292,23 @@ void *os_NextSymEntry(void *entry, uint24_t *type, uint24_t *nameLength, char *n
291292
*/
292293
int os_DelSymEntry(void *entry);
293294

295+
/**
296+
* Delete a var from RAM or archive (Flash).
297+
*
298+
* @param[in] entry An entry as used in (or returned from) \c os_NextSymEntry or \c os_ChkFindSym.
299+
*/
300+
void os_DelVar(void *entry);
301+
302+
/**
303+
* Archive (if in RAM) or Unarchive (if in Flash) a variable.
304+
*
305+
* @param[in] varType The variable type ID (like \c OS_TYPE_PROT_PRGM etc.)
306+
* @param[in] nameLen Length of the variable name
307+
* @param[in] name Variable name
308+
* @return true on success, false on failure.
309+
*/
310+
bool arcUnarcVariable(uint8_t varType, uint8_t nameLen, const char *name);
311+
294312
/**
295313
* Creates an TIOS Str.
296314
*

src/ce/os_delvar.src

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
assume adl = 1
2+
section .text
3+
4+
; void os_DelVar(void *entry)
5+
; {
6+
; int clobber_hl, clobber_de;
7+
; unsigned int *tmp = (unsigned int *)(entry - 5);
8+
; void *data = (void*)((*tmp & 0xFF) << 16 | (*tmp & 0xFF00) | (*tmp & 0xFF0000) >> 16);
9+
; asm volatile (
10+
; "call 021434h" // DelVarArc
11+
; : "=l" (clobber_hl),
12+
; "=e" (clobber_de)
13+
; : [hl] "l" (entry),
14+
; [de] "e" (data),
15+
; [flags] "iyl" (os_Flags)
16+
; : "cc", "a", "bc", "ix", "iy"
17+
; );
18+
; }
19+
public _os_DelVar
20+
_os_DelVar:
21+
push ix
22+
call __frameset0
23+
ld iy, (ix + 9)
24+
ld de, (iy - 5)
25+
ld a, 16
26+
push de
27+
pop hl
28+
ld c, a
29+
call __ishl
30+
push hl
31+
pop iy
32+
push de
33+
pop hl
34+
ld bc, 65280
35+
call __iand
36+
push hl
37+
pop bc
38+
add iy, bc
39+
ex de, hl
40+
ld c, a
41+
call __ishru
42+
push hl
43+
pop de
44+
add iy, de
45+
ld hl, (ix + 9)
46+
lea de, iy
47+
ld iy, $D00080 ; flags
48+
call 021434h ; DelVarArc
49+
pop ix
50+
pop ix
51+
ret
52+
53+
extern __frameset
54+
extern __iand
55+
extern __frameset0
56+
extern _memcpy
57+
extern __ishl
58+
extern __ishru
59+

0 commit comments

Comments
 (0)