Page 1 of 1

LAMER question :D

Posted: Wed Jan 28, 2004 6:28 pm
by St8ic
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!

Re:LAMER question :D

Posted: Wed Jan 28, 2004 9:52 pm
by stonedzealot
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).

Re:LAMER question :D

Posted: Thu Jan 29, 2004 2:24 am
by Pype.Clicker
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

Code: Select all

   if (x>0x100000) print("%iMB",(x>>20));
   else print("%iKB",(x>>10));
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...

Re:LAMER question :D

Posted: Thu Jan 29, 2004 4:37 am
by libber
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

Re:LAMER question :D

Posted: Thu Jan 29, 2004 3:56 pm
by chris
I wrote my own small converter in Python :D

Re:LAMER question :D

Posted: Thu Jan 29, 2004 4:04 pm
by Curufir
chris wrote: I wrote my own small converter in Python :D
I wrote my own converter in small Brain :D

Re:LAMER question :D

Posted: Thu Jan 29, 2004 5:43 pm
by chris
Hehe :P