Data and Registers

Hexadecimal data and the registers that hold them.

Hexadecimal data and the registers that hold them.

Now we're starting to get into real assembly. Bits and Bytes Data is raw information. Computers will store their data as binary digits, as we have seen earlier. A bit is a single binary 1 or 0. The binary number 11010 contains 5 bits.A byte is a number made of 8 bits. The binary number 01111011 contains 8 bits, which means it must be a byte.A byte is also able to hold exactly 2 hexadecimal digits. This is also what a typical byte might look like: B6 (it has 2 hexadecimal digits) Now, I'll be giving you a list of the common data units: Bit = A single 1 or 0. Nibble = 4 bits = 1 hexadecimal digit Byte = 8 bits = 2 hexadecimal digits Word = 16 bits = 4 hexadecimal digits Dword = 32 bits = 8 hexadecimal digits Qword = 64 bits = 16 hexadecimal digits We are going to work mainly with Dwords, numbers that are 8 hexadecimal digits long. The "nibble" is just for trivia purposes. We're rarely going to use it, if ever. A nibble is just half a byte, because whenever you take a nibble of some food, you're taking half a bite (haha... really bad joke). Dword stands for "double word" and Qword stands for "quad word". This makes sense. A word is 4 hexadecimal digits. A dword (8 hex digits) is twice the size of a word and a qword (16 hex digits) is four times the size of a word. Registers Numbers are great and all, but they're not too useful if we have no place to put them. The registers are designed to hold numbers, so they are indeed like little "boxes" that can store numerical data. Registers are similar to variables that you use in math or computer programming. Variables hold numbers - or at least they represent numbers. However, registers are not considered true variables. List of Registers: EAXECXEDXEBX ESP EBP ESI EDI But wait, you cannot use all of them! Only EAX, ECX, and EDX can be used to store numbers for your own personal use. The other registers hold important stuff, as in stuff that you don't want to mess with yet. Why is it so dangerous to store your own numbers into something like ESP? Well, ESP is the top of the stack pointer. That means it defines the location of the top value of the stack. If you change ESP randomly, you just messed up the stack! (Ok, I realize that I haven't explained what the stack is yet, but we'll get to that later). Each three-letter register is able to hold a 32-bit value. That means, it holds exactly 8 hexadecimal digits (but some of those digits can be 0, so you can store small numbers). Like EAX could be holding the number 00003105, or 006C03A4, or the number FEEDBEEF. All those hex numbers are 8 digits long. Registers are not the only place that can hold numbers. Each address refers to a memory location, so addresses can be used to hold numbers too. We'll talk about this in future lessons. Integers This is important: the regular registers (EAX, ECX, EDX, and so on) can only hold integers. The integers: ... -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6 ... As you can see, the integers include the positive whole numbers, the negative whole numbers, and zero. Integers do not include fractions or anything with a decimal point. So, you cannot store numbers like 12.55 and 2/3 into something like EAX. Numbers that have decimal points are known as floating point numbers. They will be dealt with later. Previous Lesson: Firecracker Next Lesson: Instructions Table of Contents |