1
Name:
Anonymous
2009-02-12 19:20
Quick question: I have a trace file in binary, each trace is 12 bytes and I have the appropriate struct defined (using C obviously).
I'm using fgets() to read 12 bytes into a char[], and setting the struct's pointer to the char[]'s address, with the hopes that the data read will "fall into place." It isn't working, though, because I know that I don't have 0xFF registers.
Can someone give me an idea what I'm doing wrong? Thanks in advance. Here's my code (with fopen(), etc omitted):
struct trace_item {
uint8_t type;
uint8_t sReg_a;
uint8_t sReg_b;
uint8_t dReg;
uint32_t PC;
uint32_t Addr;
};
// snip
struct trace_item * cur;
char line[12];
cur = line;
while(fgets(line,12,f) != NULL)
{
printf("%x\n",cur->dReg);
}
2
Name:
Anonymous
2009-02-12 19:24
while(fgets(line,12,f) != NULL)
............................................________
....................................,.-‘”...................``~.,
.............................,.-”...................................“-.,
.........................,/...............................................”:,
.....................,?......................................................\,
.................../...........................................................,}
................./......................................................,:`^`..}
.............../...................................................,:”........./
..............?.....__.........................................:`.........../
............./__.(.....“~-,_..............................,:`........../
.........../(_....”~,_........“~,_....................,:`........_/
..........{.._$;_......”=,_.......“-,_.......,.-~-,},.~”;/....}
...........((.....*~_.......”=-._......“;,,./`..../”............../
...,,,___.\`~,......“~.,....................`.....}............../
............(....`=-,,.......`........................(......;_,,-”
............/.`~,......`-...............................\....../\
.............\`~.*-,.....................................|,./.....\,__
,,_..........}.>-._\...................................|..............`=~-,
.....`=~-,_\_......`\,.................................\
...................`=~-,,.\,...............................\
................................`:,,...........................`\..............__
.....................................`=-,...................,%`>--==``
........................................_\..........._,-%.......`\
...................................,<`.._|_,-&``................`\
3
Name:
Anonymous
2009-02-12 19:25
Programming does not work this way.
4
Name:
Anonymous
2009-02-12 19:28
It looks like you're not using LISP . That is likely the problem.
5
Name:
Anonymous
2009-02-12 20:05
>>1
. . .
I'll post the answer in about ten hours if noone does.
8
Name:
Anonymous
2009-02-12 21:30
void putStr(char* w){
if(*w){
putchar(*w);
putStr(w+1,len-1);
}
}
9
Name:
Anonymous
2009-02-12 22:28
u need to read big endian
10
Name:
Anonymous
2009-02-13 6:08
struct trace_item cur;
while(fgets(&cur,12,f) != NULL)
12
Name:
Anonymous
2009-02-13 8:17
>> 10
DON'T HELP ... nevermind.
13
Name:
Anonymous
2009-02-13 17:09
##################
############################
################################
####################################
########################################
############################################
##############################################
############# #############
######### #########
####### #######
###### ######
##### #####
##### #####
#### ####
#### ####
#### ####
#### ####
##### #####
##### #####
##### #####
###### ######
####### #######
######### #########
############# #############
##############################################
############################################
########################################
####################################
################################
############################
##################