summaryrefslogtreecommitdiff
path: root/lib/acid/gpa
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2006-12-22 20:52:35 +0000
committerCharles.Forsyth <devnull@localhost>2006-12-22 20:52:35 +0000
commit46439007cf417cbd9ac8049bb4122c890097a0fa (patch)
tree6fdb25e5f3a2b6d5657eb23b35774b631d4d97e4 /lib/acid/gpa
parent37da2899f40661e3e9631e497da8dc59b971cbd0 (diff)
20060303-partial
Diffstat (limited to 'lib/acid/gpa')
-rw-r--r--lib/acid/gpa88
1 files changed, 88 insertions, 0 deletions
diff --git a/lib/acid/gpa b/lib/acid/gpa
new file mode 100644
index 00000000..8a08393f
--- /dev/null
+++ b/lib/acid/gpa
@@ -0,0 +1,88 @@
+//
+// generate ``General Purpose Ascii'' file for HP logic analyser
+//
+// usage: gpa()
+// note: output has to be postprocessed with "sed 's/0x//g' "...
+//
+
+defn functions(start, end)
+{
+ print("[FUNCTIONS]\n");
+ pc = start;
+ while pc < end do {
+ bnd = fnbound(pc);
+ print(pc\a, "\t", bnd[0], "..", bnd[1]-1, "\n");
+ pc = bnd[1];
+ }
+ print("\n");
+}
+
+defn variables(start, end)
+{
+ print("[VARIABLES]\n");
+ // TODO: how do we get this one?
+ print("\n");
+}
+
+defn sourcelines(start, end)
+{
+ local pc, curfile, curline, newfile, newline;
+
+ print("[SOURCE LINES]\n");
+ pc = txtstart;
+ curfile = "<no-file>";
+ curline = -1;
+ while pc < txtend do {
+ newfile = pcfile(pc);
+ newline = pcline(pc);
+ if newfile != curfile then {
+ if curline != -1 then
+ print("\n");
+ print("File: ", newfile, "\n");
+ curfile = newfile;
+ }
+ if newline != curline then {
+ print(newline, "\t", pc, "\n");
+ curline = newline;
+ }
+ pc++;
+ }
+ print("\n");
+}
+
+defn gpa()
+{
+ local l, ent, txtstart, txtend, datastart, dataend, pc, bnd;
+
+ print("[SECTIONS]\n");
+ l = map();
+ while l do {
+ ent = head l;
+ if ent[0] == "text" || ent[0] == "data" then {
+ if ent[0] == "text" then {
+ txtstart = ent[1];
+ txtend = ent[2];
+ }
+ else {
+ datastart = ent[1];
+ dataend = ent[2];
+ }
+ print(ent[0], "\t", ent[1], "..", ent[2]-1, "\n");
+ }
+ l = tail l;
+ }
+ print("\n");
+
+ functions(txtstart, txtend);
+// variables(datastart, dataend);
+ sourcelines(datastart, dataend);
+
+ print("[START ADDRESS]\n");
+ print(txtstart, "\n");
+ print("\n");
+}
+
+defn acidinit()
+{
+ gpa();
+}