question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Option to convert constants to hex in asm output (other than binary mode)

See original GitHub issue

It would be great if there was an option to filter the compiler-output asm and replace bare numbers with their hex equivalent. gcc and clang have the annoying habit of using decimal output for everything, including constants that have a nice pattern in hex but are just nonsense in decimal.

This is my main use for binary mode, since the objdump output uses hex for all constants. It doesn’t show the data / rodata sections, though, and is generally less nice than compiler asm output if you aren’t looking at the instruction encodings / alignments.

For signed decimal integers, -0x8 is a lot easier to read than 0xFFFFFFF8, though. objdump’s output is a bit inconsistent in its choices:

int foo(int n) { return n-0x1257; }
int bar(){ return -0x1257; }

foo:  lea    eax,[rdi-0x1257]   / ret
bar:  mov    eax,0xffffeda9    / ret

I guess it’s choosing based on the fact that it’s a relative displacement.

Maybe some clever heuristics could choose between the signed hex and the hex representation of their 2’s complement encoding? Choosing based on context like objdump does is harder for a text filter. Maybe have an option to make output like mov eax, 0xffffeda9 (-4695) which is no longer valid asm, but which has constants in hex and decimal?

A good first step would be an option to hex everything. That would be plenty useful in a lot of cases.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
pcordescommented, Mar 21, 2017

I think having them only in tooltips is a lot less good for some use-cases than as an extra comment, or replacing the decimal constant with hex. With multiple nearby constants, your eye can’t really scan down them if you have to mouseover them one at a time.

Of course, having a floating-point interpretation as well as hex is very nice.

This is much better than nothing, and a nice improvement. I’ll have to see whether I still really miss having all constants in hex.

1reaction
RubenRBScommented, Mar 10, 2017

I’ve become somewhat familiar with Monaco implementing the linking of code and I want to try this one now. Just to make sure, we want a tooltip for numeric constants that converts hex to decimal, and decimal to hex? If it’s not hex nor decimal, (binary?) should both be displayed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Option to convert constants to hex in asm output (other than ...
This is my main use for binary mode, since the objdump output uses hex for all constants. It doesn't show the data /...
Read more >
How to convert a binary integer number to a hex string?
To use this for more than 64 bits of input, use vpmovzxdq to zero-extend each input dword into a qword, setting up for...
Read more >
Chapter 2 HCS12 Assembly Language
Convert binary to decimal before output. – Option 2 (simplifies I/O conversion). - Save the decimal inputs in binary-coded-decimal (BCD) code.
Read more >
Chapter 3 Assembly Language Fundamentals
3.2.1 Alternative Version of AddSub 60 ... constants, and string constants in assembly language ... binary, decimal, hexadecimal, or octal digits.
Read more >
Guide to x86 Assembly - Yale FLINT Group
This guide describes the basics of 32-bit x86 assembly language programming, covering a small but useful subset of the available instructions and assembler...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found