I'm trying to convert a disassembled Hex Dump to a SPIM friendly assembly file. This requires that I take lines like:
004000f8 <_init>:
4000f8: 27bdffe8 addiu sp,sp,-24
4000fc: afbf0010 sw ra,16(sp)
400100: 0c100064 jal 400190 <call_gmon_start>
400104: 00000000 nop
400108: 0c100094 jal 400250 <frame_dummy>
...
and make them:
.text 004000f8
<_init>:
addiu $sp,$sp,-24
sw $ra,16($sp)
jal 400190 <call_gmon_start>
nop
jal 400250 <frame_dummy>
...
How I do this is I define starting features and terminating features. I then just search for them using a big if statement within a loop that traverses each word in my document. I insert into 3 vectors the starting position, the length of the "sentence", and the type of sentence. I then reiterate through the vector full of words and copy the sentences as specified by the vectors into a new file. I'm having a lot of trouble getting this to work and I hate using so many if statements. 3 for every terminating feature (there are 4 features) + another feature for a second type of "sentence". How do I do this in a more precise way? I know that there will always be 13 different kinds of lines to be added to my new file.