Commit b6067e00 authored by Axel Simon's avatar Axel Simon

update runtime

parent 164ab561
......@@ -375,7 +375,12 @@ static char blob[BUF_SIZE];
int main (int argc, char** argv) {
uint64_t buf_size = BUF_SIZE;
FILE* file = NULL;
int_t decode_options = 0;
int_t decode_options =
#if defined(gdsl_default_config)
gdsl_default_config;
#else
0;
#endif
int_t run_translate = 0;
int_t translate_options = 0;
int_t base_address = 0;
......@@ -395,21 +400,26 @@ int main (int argc, char** argv) {
}
} else {
arg+=2;
int negated = 0;
if (strcmp(arg,"no-")==0) { negated = 1; arg+=3; };
#if defined(gdsl_decoder_config)
for (config = gdsl_decoder_config(s); gdsl_has_conf(s,config);
config = gdsl_conf_next(s,config))
if (strcmp(arg,gdsl_conf_short(s,config))==0) {
decode_options |= gdsl_conf_data(s,config);
if (negated)
decode_options &= ~gdsl_conf_data(s,config);
else
decode_options |= gdsl_conf_data(s,config);
break;
}
if (gdsl_has_conf(s,config)) continue;
#endif
if (strncmp(arg,"base=",5)==0) {
scanf(arg+5,"%lli",&base_address);
sscanf(arg+5,"%lli",&base_address);
continue;
}
if (strncmp(arg,"start=",6)==0) {
scanf(arg+6,"%lli",&start_address);
sscanf(arg+6,"%lli",&start_address);
continue;
}
if (strcmp(arg,"trans")==0) {
......@@ -418,15 +428,20 @@ int main (int argc, char** argv) {
}
fprintf(stderr,
"usage: %s [options] filename\nwhere\n"
" --trans translate to semantics\n"
" --base=addr print addresses relative to addr\n"
" --start=addr decode starting from addr\n", argv[0]);
" --trans translate to semantics\n"
" --base=addr print addresses relative to addr\n"
" --start=addr decode starting from addr\n", argv[0]);
#if defined(gdsl_decoder_config)
for (config = gdsl_decoder_config(s); gdsl_has_conf(s,config);
config = gdsl_conf_next(s,config))
fprintf(stderr," --%s\t\t%s\n",
gdsl_conf_short(s,config), gdsl_conf_long(s,config));
fprintf(stderr," --%s\t\t%s%s\n --no-%s%s\t\tnegated option\n",
gdsl_conf_short(s,config),
gdsl_conf_data(s,config) & decode_options ? "*" : "",
gdsl_conf_long(s,config),
gdsl_conf_short(s,config),
gdsl_conf_data(s,config) & decode_options ? "" : "*");
#endif
fprintf(stderr,"The default is denoted by *.\n");
return 1;
}
}
......@@ -470,7 +485,7 @@ int main (int argc, char** argv) {
2);
obj_t res = gdsl_rreil_pretty(s,rreil);
string_t str = gdsl_merge_rope(s,res);
printf("%llx:\n",address);
printf("0x%llx:\n",address);
fputs(str,stdout);
#else
fputs("GDSL modules contain no semantic translation\n",stdout);
......@@ -488,9 +503,9 @@ int main (int argc, char** argv) {
#endif
}
} else {
fputs("exception: ",stdout);
fputs(gdsl_get_error_message(s),stdout);
if (gdsl_seek(s,gdsl_get_ip_offset(s)+1)) break;
int_t address = gdsl_get_ip_offset(s);
fprintf(stdout,"exception at address 0x%llx: %s\n", address, gdsl_get_error_message(s));
return 1;
}
fputs("\n",stdout);
int_t size = gdsl_heap_residency(s);
......
......@@ -2,10 +2,12 @@ export config-default: decoder-configuration
export decode: (decoder-configuration) -> S insndata <{} => {}>
export decoder-config : configuration[vec=decoder-configuration]
type decoder-configuration = 0
type decoder-configuration = |1|
val decoder-config = END
val config-default = ''
val decoder-config =
conf '1' "reduced" "decode for ATtiny4/5/9/10 controller"
val config-default = '0'
val d ['bit:1'] = do
rd <- query $rd;
......@@ -191,7 +193,7 @@ val / ['1001010010111000'] = nullop CLV
val / ['1001010010011000'] = nullop CLZ
### COM
### - Ones Complement
### - One's Complement
val / ['1001010 d d d d d 0000'] = unop COM rd5
### CP
......@@ -305,7 +307,7 @@ val / ['1110 k k k k d d d d k k k k'] = binop LDI rd4 ck8
### LDS
### - Load Direct from Data Space
val / ['1001000 d d d d d 0000' 'k k k k k k k k k k k k k k k k'] = binop LDS rd5 ck16
#val / ['10100 k k k d d d d k k k k'] = binop LDS rd4 ck7
val /tiny ['10100 k k k d d d d k k k k'] = binop LDS rd4 ck7
### LPM
### - Load Program Memory
......@@ -480,13 +482,15 @@ val / ['1001001 r r r r r 1110'] = binop ST (//X DECR) rr5
### - Store Indirect From Register to Data Space using Index Y
val / ['1001001 r r r r r 1001'] = binop ST (//Y (INCR 1)) rr5
val / ['1001001 r r r r r 1010'] = binop ST (//Y DECR) rr5
val / ['10 q 0 q q 1 r r r r r 1 q q q '] = binop ST (///Y dq6) rr5
val / ['10 q 0 q q 1 r r r r r 1 q q q '] | isTiny = genTinyInstr
| otherwise = binop ST (///Y dq6) rr5
### ST
### - Store Indirect From Register to Data Space using Index Z
val / ['1001001 r r r r r 0001'] = binop ST (//Z (INCR 1)) rr5
val / ['1001001 r r r r r 0010'] = binop ST (//Z DECR) rr5
val / ['10 q 0 q q 1 r r r r r 0 q q q '] = binop ST (///Z dq6) rr5
val / ['10 q 0 q q 1 r r r r r 0 q q q '] | isTiny = genTinyInstr
| otherwise = binop ST (///Z dq6) rr5
### STS
### - Store Direct to Data Space
......@@ -495,7 +499,7 @@ val / ['1001001 r r r r r 0000' 'k k k k k k k k k k k k k k k k'] = binop STS c
# ATtiny4,5,9, and 10 implement the instruction below while other
# chips (notably those that implement ST with dq6) implement only the 32-bit
# variant of STS; see Wikipedia
#val / ['10101 k k k r r r r k k k k'] = binop STS ck7 rr4
val /tiny ['10101 k k k r r r r k k k k'] = binop STS ck7 rr4
### SUB
### - Subtract without Carry
......@@ -522,13 +526,22 @@ val / ['1001010110101000'] = nullop WDR
val / ['1001001 d d d d d 0100'] = binop XCH /Z rd5
val decode config = do
update@{rd='',rr='',ck='',cs='',cb='',io='',dq=''};
update@{rd='',rr='',ck='',cs='',cb='',io='',dq='', config = config};
idx-before <- idxget;
insn <- /;
idx-after <- idxget;
return {length=(idx-after - idx-before), insn=insn}
end
val isTiny s = zx (s.config and '1') > 0
val genTinyInstr = do
update@{rd='',rr='',ck='',cs='',cb='',io='',dq=''};
index <- idxget;
seek (index - 4);
/tiny
end
type side-effect =
NONE
| INCR of int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment