Good O'l Assembly

I want to really learn low-level programming, but the problem with that is I don't know how to use hex numbers, and I know its almost essential to know those in order to use (You guessed it) Good O'l Assembly.

Can someone point me in the right direction?
closed account (Dy7SLyTq)
ummm..... no, i don't think hex is essential. i dont know assembly but i tried learning it and it didnt require hex. how long have you been programming? since ur twelve im guessing not that long. you probably want to stick with c++ for a while and anyways its pretty low level also:
Last edited on
closed account (3qX21hU5)
What are you having trouble with understanding when it comes to hexadecimal numbers?

It uses 16 symbols (1-9 and A-F) the order being 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. So for example "13" in hex would be "d" (The 13th symbol) or "127" would be "7f".

I admit it is quite hard to understand in the beginning but just start looking at some multiplication tables for hex and other tables and you will get the hang of it. Print a few out and put them by your computer for reference, and most operating systems come with scientific calculators that can deal with hex numbers so use that also or download a good calculator application.
Last edited on
You do need to be able to understand hex. You don't need to be able to know it as you know decimal though.

Hex is actually not that hard to learn. You can convert any number to decimal from any base like this:

1. Separate the number into digits with their position in the number starting from zero, working from right-to-left:
position: | 3 | 2 | 1 | 0 |
   digit: | 5 | F | A | 6 |

2. Multiplty each digit by the base you're converting from (16) to the power of the position of the digit in the number:
0x6 * 16^0
0xA * 16^1
0xF * 16^2
0x5 * 16^3

3. Sum the results:
0x5FA6 = 0x6 * 16^0 + 0xA * 16^1 + 0xF * 16^2 + 0x5 * 16^3
       =          6 +    10 * 16 +   15 * 256 +   5 * 4096
       =          6 +        160 +       3840 +      20480
       = 24486

This works for every numeric base, thus for binary:
position: | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
   digit: | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 1 |

10110011 = 1 * 2^0 + 1 * 2^1 + 0 * 2^2 + 0 * 2^3 + 1 * 2^4 + 1 * 2^5 + 0 * 2^6 + 1 * 2^7
         =   1 * 1 +   1 * 2 +                      1 * 16 +  1 * 32 +           1 * 128
         =       1 +       2 +                          16 +      32 +               128
         = 179

You can make the process easier with binary by skipping the 0s out as I did above, because 0 * x = 0. Also, you don't need to write "1 *" every time because 1 * x = x.
Knowing Hex, Oct, and Binary aren't essential, but they are fun to learn. Though, at some point you will want to learn them anyways, so better to do it now and get it over with.
DTS, I've been programming C++ for a year now. I made like 5 games. Also, I've been learning Ruby since I was 10.

I'm not new.
Last edited on
closed account (Dy7SLyTq)
FredBill: I have been programming for about three years. ive made like five games, two encryption algorithims, and i can memorize about 300 lines of code and rewrite on paper by just reading it line by line once. ive learned ruby. it is nothing like assembly
There is absolutely nothing in assembly that would require learning hex. You should have some understanding of binary though, but only about as mush as to understand that shift left is multiplication by 2 and etc. Decimal is a bit awkward though. For example, (from os development) pages start at multiples of 212 = 0x1000, so if an error happens and I see that my instruction pointer was at 0x60C2, I know it's on page 6. If instead it was printed as 24770, I'd have to divide it by 4096 first. In other words, it's just a thing of comfort.
Of course you need to know hex - no self respecting author of assembly books/datasheets/ micrprocessor documentation etc is going to write it in decimal.

He/She should learn hex and binary (or expect to be ridiculed)
Last edited on
@guestgulkan, no <...> is going to write what in decimal? Also, I don't think he (it's a he) is completely baffled by 0xABC, it's just that he needs a converter to get the decimal value (the big revelation to be had here is that you don't need the decimal value, usually all you need it to subtract 4, or drop some digits or something trivial like that). And there is nothing wrong with that. I feel that you're just propagating the stereotype of ASM being some kind of complex-math-hacker thing, while in reality it is just totally uncomfortable and somewhat boring.
If you're interested, the instruction set for the 68000 chip is reasonably simple once you get going. I'd advise using the Easy68k editor/assembler.

I've been doing this all week and I'm sick of it now. The plus side is that it's all fresh in my mind if you need a hand.

As for hex, you'd best understand how it works and have a dec to hex calculator handy. Mastery isn't really required, but it is definitely handy to know. There are situations in 68k that rely on it, such as giving cursor coordinates in hex as it allows 256 values in just one byte.

Also, all of your memory addresses are in hex, so it's a good idea to have a grounding on it.

As for binary, I haven't had much interaction with it on this endeavour, but it'd be handy to know. As chrisname pointed out, neither of them of particularly difficult.
Last edited on
Thanks, but I still wonder if I can get an emulator and IDE for The first 32 bit intel chip (I don't really remember its name currently)
All AMD and Intel x86 processors are backwards-compatible all the way back to the original 8086. They start in a processing mode called "real-mode" which is identical to the original 8086. The software can then explicitly enable "protected mode" which is the 32-bit operating mode introduced with the 80386. On 64-bit processors, software can then enable 64-bit "long mode". These are all layers built on top of each other. In short, you don't need an emulator specifically for the 80386 (the first 32-bit Intel CPU), you just need any Intel emulator (or real CPU), they're all compatible.
Surprised I haven't seen Paul Carter's Assembly PDF recommended here like it has been in almost every other assembly thread that has appeared on here.
Topic archived. No new replies allowed.