diff --git a/gdbgui/src/js/SourceCode.tsx b/gdbgui/src/js/SourceCode.tsx
index 018c7fab..fc2eee8d 100644
--- a/gdbgui/src/js/SourceCode.tsx
+++ b/gdbgui/src/js/SourceCode.tsx
@@ -260,19 +260,50 @@ class SourceCode extends React.Component<{}, State> {
) : (
);
+ const instStr: string = assm.inst || "";
+ const [mnemonic, ...operandParts] = instStr.trim().split(/\s+/);
+ const operandsStr = operandParts.join(" ");
+
+ // split operands by commas but keep commas
+ const operandTokens = operandsStr.split(/(\,)/).map((tok) => tok.trim()).filter((tok) => tok.length > 0);
+
+ const highlightedOperands = operandTokens.map((tok, i) => {
+ if (/^\%[a-z0-9]+$/i.test(tok)) {
+ // register like %rax
+ return {tok};
+ } else if (/^\$?0x[0-9a-f]+$/i.test(tok) || /^\$?\d+$/i.test(tok)) {
+ // immediate or numeric constant
+ return {tok};
+ } else if (tok === ",") {
+ return {tok};
+ } else {
+ // memory reference or other
+ return {tok};
+ }
+ });
+
+ const highlightedInstruction = (
+ <>
+ {mnemonic}{" "}
+ {highlightedOperands}
+ >
+ );
return (
-
- {/* @ts-expect-error ts-migrate(2769) FIXME: Property 'fontFamily' is missing in type '{ paddin... Remove this comment to see the full error message */}
- {asterisk}
- {opcodes /* i.e. mov */}
- {instruction}
+
+ {asterisk}
+
+ {opcodes}
+
+ {mnemonic}
+
+
+ {highlightedOperands}
+
{func_name ? (
-
+
{func_name}+{offset}
- ) : (
- ""
- )}
+ ) : ""}
);
}
diff --git a/gdbgui/static/css/gdbgui.css b/gdbgui/static/css/gdbgui.css
index 71ec63f3..136c5c58 100644
--- a/gdbgui/static/css/gdbgui.css
+++ b/gdbgui/static/css/gdbgui.css
@@ -181,9 +181,21 @@ td.assembly {
white-space: nowrap;
}
/* instruction content */
-.instrContent {
- min-width: 250px;
- display: inline-block;
+.asm-mnemonic {
+ color: green;
+ font-weight: bold;
+}
+.asm-register {
+ color: red;
+}
+.asm-immediate {
+ color: #489ce4;
+}
+.asm-other {
+ color: inherit;
+}
+.asm-address {
+ color: #489ce4;
}
#code_table {
font-family: monospace;