OpenCores
URL https://opencores.org/ocsvn/blue/blue/trunk

Subversion Repositories blue

[/] [blue/] [trunk/] [blue8/] [asm2hex.awk] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wd5gnr
#!/usr/bin/gawk -f
2
 
3
function lineout() {
4
    cksum=ct+int((loc)/256)+int((loc)%256)+cksum;
5
    cksum=(cksum)%256;
6
    cksum=xor(cksum,0xFF);
7
    cksum=(cksum+1)%256;
8
    if (line!="") printf(":%02x%04x00%s%02x\n",ct,loc,line,cksum);
9
    loc+=ct;
10
    line="";
11
    ct=0;
12
    newline=0;
13
}
14
 
15
BEGIN { loc=0; newline=0;ct=0; cksum=0; line=""; }
16
 
17
/^@ [0-9a-fA-F]/ {
18
  lineout();
19
  loc=strtonum("0x" $2);
20
  loc=loc*2;  # adjust for byte adjust
21
  next;
22
}
23
 
24
 
25
/^[0-9a-fA-F]/ {
26
  x=strtonum("0x" $1);
27
  x1=int(x/256);
28
  x2=x-(x1*256);
29
  line=sprintf("%s%02x%02x",line,x1,x2);
30
  ct+=2;
31
  cksum=cksum+x1+x2;
32
 
33
  if (ct==16) {
34
    lineout();
35
  }
36
}
37
 
38
END { lineout(); printf(":00000001FF\n"); }  # need to fix checksum

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.