0

i am able to read the nice.ls FILE.
Let me explain u my nice.ls FILE content
1st column is integers dont bother abt them,
2nd column is address, i read it by using isxdigit array[6] and i am able to read the hexadecimal
3rd column is opcode , i am also able to read them with array[11]
4th column are instructions, i am not able to read the array[26]

i am not able to understand why it is not reading the 4th column
PLZ give me some suggestions

# include <stdio.h>
#include<conio.h>
#include<ctype.h>

int main()
{
FILE * pFile;
char mystring [1024];
char line[1024];
unsigned long int address,opcode;
char inst1[1024],inst2[10];

pFile = fopen ("nice.ls" , "r");

if (pFile == NULL) perror ("Error opening file");
else
while(fgets (mystring , 1024 , pFile) != NULL) //reads the file nice.ls line wise and stores in mystring
{
if(isxdigit(mystring[6])) //this will check for hexadecimal in the 6 column of nice.ls file
{
address = strtol(mystring+6,NULL,16); //it will store 6th char hexadecimal(address)
opcode = strtol(mystring+11,NULL,16); //it will store 11th char hexadecimal(opcode)
// printf("%lx %lx \n",address,opcode);
sscanf(mystring+26,"%s",&inst1); //it will store 26th char, the instruction, but i failed to use correctly
printf("lx %lx %s \n",address,opcode,inst1); // i am able to check 6th and 11th column(hexadecimal or not) but in the 26th column i have to read the instructions(not able to read these instructions)
}
}
fclose (pFile);
getch();
}

my FILE nice.ls

1 ; C Compiler for M68HC08 (COSMIC Software)
2 ; Generator V4.5.10.1 - 14 Jun 2007
3 ; Optimizer V4.5.4.2 - 17 Jul 2007
5 xref _printf
32 ; 1 void main(void)
32 ; 2 {
33 switch .text
34 0000 _main:
38 ; 3 printf(" hello world ");
40 0000 a600 lda #low(L71)
41 0002 ae00 ldx #high(L71)
43 ; 4 }
46 0004 cc0000 jmp _printf
58 xdef _main
59 .const: section .text
60 0000 L71:
61 0000 2068656c6c6f dc.b " hello world ",0
62 end

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by nucleon
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.