Basically i am trying to read a hexadecimal string such as the below mentioned

0x401d50 0x360aa7c030 0x405dc2 0x405dc9 0x405dd0 0x405dd5 0x405dd8 0x401bb0

compute the length of the same in bytes and compare to see if its lesser than 32 bytes(which is the size of a register that is going to hold all these addresses, which i am referring to as buffer) and if the comparison satisfies then i keep loading the instrutions until the register is full i.e unti lit reaches 32 bytes. Once it does i call it a miss .

#! user/bin/perl #use strict; #use warnings; $length_buffer= 0x100; $base= 0; $base_end= ($base+ $length_buffer-1); open(FILE1," < output_log.txt") or die "can't read the file"; + while(<FILE1>) { $inst_addr= $_; if($inst_addr) { use bytes; + $len_ofinstr=length( $inst_addr); + print " Length in bytes: ", $len_ofinstr, "\n"; + if($len_ofinstr >= $base && $len_ofinstr <=$base_end) { print FILE2 $hit. "\n"; print " The inst fits in the buffer->hit, \n"; $len_ofinstr+=$len_ofinstr; print "Total number of bytes in the buffer=", $len_ofinstr, "\ +n"; $count_hit=$count_hit+1; print " Number of hits in the buffer= $count_hit", "\n"; print FILE2 "number of hits in buffer". $count_hit. "\n"; } } else{ if($len_inst == $length_buffer) { print " it can not hold anymore, \n"; $base= $instr_addr & 0xffffffe0; } } }

The snippet of the code is pasted above, the problem i am facing with the above pasted code is that, when $length_buffer= 0x100 (equivalent of the number 256 but not euvalent of 256 bits or 32 bytes) so the comparison is not really making any sense. Could anyone suggest how to fix this issue? thanks


In reply to Re^6: How to assign a variable its width/vector by samd
in thread How to assign a variable its width/vector by samd

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.