LAMER question :D

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
St8ic

LAMER question :D

Post 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!
stonedzealot

Re:LAMER question :D

Post 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).
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:LAMER question :D

Post 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...
libber

Re:LAMER question :D

Post 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
chris

Re:LAMER question :D

Post by chris »

I wrote my own small converter in Python :D
Curufir

Re:LAMER question :D

Post by Curufir »

chris wrote: I wrote my own small converter in Python :D
I wrote my own converter in small Brain :D
chris

Re:LAMER question :D

Post by chris »

Hehe :P
Post Reply