1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-07-03 05:29:30 +00:00

Fix address initializera

This commit is contained in:
David Schmenk 2014-11-24 08:53:34 -08:00
parent 1efd12b15c
commit c92e659a9b
3 changed files with 40 additions and 13 deletions

View File

@ -6,7 +6,7 @@ include(testlib.plh)
//
// Structure definition.
//
struc
struc mystruc
byte cmd
word param
byte[3]
@ -105,4 +105,6 @@ puti(param)
putln
puti(data)
putln
puti(mystruc)
putln
done

View File

@ -1054,9 +1054,17 @@ int parse_var(int type)
}
int parse_struc(void)
{
long size;
int type, constsize, offset = 0;
long size;
int type, constsize, offset = 0;
char *idstr, strucid[80];
int idlen = 0, struclen = 0;
if (scan() == ID_TOKEN)
{
struclen = tokenlen;
for (idlen = 0; idlen < struclen; idlen++)
strucid[idlen] = tokenstr[idlen];
}
while (next_line() == BYTE_TOKEN || scantoken == WORD_TOKEN)
{
size = 1;
@ -1073,8 +1081,7 @@ int parse_struc(void)
scan();
}
do {
char *idstr;
int idlen = 0;
idlen = 0;
if (scantoken == ID_TOKEN)
{
idstr = tokenstr;
@ -1100,6 +1107,8 @@ int parse_struc(void)
if (scantoken != EOL_TOKEN && scantoken != COMMENT_TOKEN)
return (0);
}
if (struclen)
idconst_add(strucid, struclen, offset);
return (scantoken == END_TOKEN);
}
int parse_vars(int type)

View File

@ -2100,7 +2100,7 @@ def emit_data(vartype, consttype, constval, constsize)
constsize = constsize - 1
emit_byte(constsize)
while constsize > 0
emit_byte(^chrptr)
emit_byte(^chrptr)
chrptr = chrptr + 1
constsize = constsize - 1
loop
@ -2465,7 +2465,8 @@ def iddata_add(namestr, len, type, size)
end
def iddata_size(type, varsize, initsize)
if varsize > initsize
datasize = datasize + emit_data(0, 0, 0, varsize - initsize)
datasize = datasize + varsize
emit_data(0, 0, 0, varsize - initsize)
else
datasize = datasize + initsize
fin
@ -2913,7 +2914,7 @@ def parse_constval(valptr, sizeptr)
if !idptr; return parse_err(@bad_cnst); fin
type = idptr->idtype
if type & XADDR_TYPE
if !(mod & 8); return parse_err(@bad_cnst); fin
if mod <> 8; return parse_err(@bad_cnst); fin
fin
*valptr = idptr=>idval
break
@ -3666,8 +3667,8 @@ def parse_stmnt
return TRUE
end
def parse_var(type)
byte consttype, constsize, idlen
word idptr, constval, arraysize, size
byte consttype, idlen
word idptr, constval, arraysize, constsize, size
idlen = 0
size = 1
@ -3706,7 +3707,7 @@ def parse_var(type)
return parse_err(@bad_decl)
fin
loop
iddata_size(PTR_TYPE, size, arraysize)//
iddata_size(PTR_TYPE, size, arraysize)
else
return parse_err(@bad_decl)
fin
@ -3720,8 +3721,20 @@ def parse_var(type)
return TRUE
end
def parse_struc
word size, type, constsize, offset, idstr, idlen
byte strucid[16]
byte type, idlen, struclen
word size, constsize, offset, idstr
struclen = 0
if scan == ID_TKN
struclen = tknlen
if struclen > 16
struclen = 16
fin
for idlen = 0 to struclen
strucid[idlen] = ^(tknptr + idlen)
next
fin
offset = 0
while nextln == BYTE_TKN or token == WORD_TKN
size = 1
@ -3758,6 +3771,9 @@ def parse_struc
until token <> COMMA_TKN
if token <> EOL_TKN; return FALSE; fin
loop
if struclen
idconst_add(@strucid, struclen, offset)
fin
return token == END_TKN
end
def parse_vars