1 // See LICENSE for license details.
3 // This little program finds occurrences of strings like
5 // in its input, then replaces them with the disassembly
6 // enclosed hexadecimal number, interpreted as a RISC-V
20 while (getline(cin
, s
))
22 for (size_t start
= 0; (start
= s
.find("DASM(", start
)) != string::npos
; )
24 size_t end
= s
.find(')', start
);
25 if (end
== string::npos
)
28 size_t numstart
= start
+ strlen("DASM(");
29 uint32_t n
= strtoul(&s
[numstart
], NULL
, 16);
31 string dis
= d
.disassemble(*(insn_t
*)&n
);
33 s
= s
.substr(0, start
) + dis
+ s
.substr(end
+1);
34 start
+= dis
.length();