I know it's a really sad question, but I'm doing a memory map documentation for my operating system and I need an easy hex-to-physical-location converter. It just takes too long to convert all the addresses (e.g. 0x9000) to the memory locations (e.g. 640KB).
Thanks alot!
LAMER question :D
-
stonedzealot
Re:LAMER question :D
Just use GNOME's gcalc, KDE's kcalc or Window's calculator or X's xcalc...
Just input an offset in "hex" and then click on "dec" (and divide by 1024 or 1024^2 to get to KB or MB).
Just input an offset in "hex" and then click on "dec" (and divide by 1024 or 1024^2 to get to KB or MB).
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:LAMER question :D
0x1000 = 4KB
0x10000 = 64KB
0x100000 = 1MB
0x1000000 = 16MB
once you have those in mind, you can quickly convert.
If what you wish to do is to announce some folk using your OS how much memory you have, try out
and if you want to convert a string "0x12345678" into a string "666MB", just split with show_mem(hextoi("0x12345678"));
The only reason why it could be a string, though, would be that the user entered it manually...
0x10000 = 64KB
0x100000 = 1MB
0x1000000 = 16MB
once you have those in mind, you can quickly convert.
If what you wish to do is to announce some folk using your OS how much memory you have, try out
Code: Select all
if (x>0x100000) print("%iMB",(x>>20));
else print("%iKB",(x>>10));
The only reason why it could be a string, though, would be that the user entered it manually...
-
libber
Re:LAMER question :D
Also if you get bochs from cvs (assuming you are using bochs) it comes with a pretty useful calc command that prints its results in base10 and base16. I have found myself using it for quick hex things, for example 'calc 0xa * 1' would print "10 0xa"
Libber
Libber
-
Curufir
Re:LAMER question :D
I wrote my own converter in small Brainchris wrote: I wrote my own small converter in Python![]()