* ------------------------------------------------------------------------------------------- * ChaoZers 98/04/23 Assembler Tutorial #01 ------------------------------------------------------------------------------------------Bits, Bytes, Words

, Longwords & The Binary&Hexadecimal systems *---------------------------------------------------------------------------------------------* Introduction -----------This is an assembler tutorial for amiga 68K computers, I am going to try to make it as "easy" as possible... This assembler tutorial will be for you guys/girls who really want to learn but dont get a thing from thoose old tutorials that already are available. I will start the tutorial from the bottom, and then i really mean it! Though, i really recommend that you have programmed in some language before, lik e Basic, C++ or maybe Pascal? If you havent, i strongly suggest you do, because le arning assembly as the first language will be hard for most people i think. There is an excercise at the bottom of the text, so you can check if you know th e things you have learned :).. The Binary System ----------------This is the computers "decimal system", its not like the decimal system that we use, let me show you an example of the difference. The DECIMAL System can use the values 0-9. The BINARY System can use the values 0-1. Example. 64 Example. 01000000

Theese two above values are the same. 01000000 in the binary system is the same as 64 in the decimal system! In the binary system a 0 means OFF and a 1 means ON. Get it? If not, here is what i mean. %00000010=#2 The binary value here is 2. If we switch the 1 OFF and change it into a 0 the binary value will be 0 to. Here is another example. %00000110=#6 The binary value is now 6, because the digit that stands for a 4 is now ON. 2+4= 6. Argh! Isnt this a bit hard to get used to!? You scream?:) It isnt. Here is an example again.

$00001000=#8 Do you see a pattern by now? If not i can tell you that the first digit to the right in the binary system sta nds for a 1 in the decimal system. Lets make a bigger table this time. The HEXADECIMAL System can use the values 0-F Strange?? Here is a table on what i mean... beacuse next up is the hexadecimal sy stem! The hexadecimal system is a bit easier to understand i think. eh?:) Can you see the % and # signs? These tell the assembler what type of system it is. Now i hope you know the binary system. So the # stands for the decimal system. # 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 $ 0F 0E 0D 0C 0B 0A 09 08 07 06 05 04 03 02 01 But what happens if you have a value as for example the decimal value 23? Heres another table to show you just that. % 0 0 0 0 0 0 0 0 0 # 32768 16384 8192 4096 2048 1024 512 2 1 0 256 0 128 0 64 0 32 0 16 0 8 0 4 In the above table we have 16 digits(0-15). try for yourself. % 0 0 0 0 # 128 64 32 16 0 8 0 4 0 2 0 1 Binary system. With all theese values you can get almost any value you want. with more values . and the % stands for the binary system. # 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 $ 17 16 15 14 13 12 11 10 0F 0E 0D 0C 0B 0A 09 As you probably figured out the sign $ stands for the hexadecimal system in the Example. Here is a more clear description. For the ones knowing a bit math i can tell that the values in a binary systems a re powers of 2. The DECIMAL System can use the values 0-9. So if you want to know what value the 13th digit in a binary system stands for y ou just caclulate it! Its done like this. So if you write #01001000 you will get the decimal value 1001000. So if there were for example 10 digits in the binary value the digit to the left would stand for #512 in the decimal system. 64 Example. FF . As you can see the value always keep s doubling itself. 2^13=8192 Easy. Lets start with an example. Decimal system. Hexadecimal System -----------------Ok.

A WORD has the maximum value of 65536.What is the decimal value of $93 ? 08.#7 (1+2+4) 03. Here are some examples of hexadecimal values! $FF=#255 $0FFE=#4094 $FFEE=#65518 Dont be concerned about the "hardness" of transforming between theese two system s. and togehter they can form diffrent values. so for example %0101101011100001 is a word. the word&longword&bytes are the things the computer calculates with. So a BIT can be either 1 or 0.What is the decimal value of $40 ? 07. so for example %01111001 is a Byte. as it consists of 8 bits. 01. A longword has the maximum value of 2147483647. and that bytes are the fastest to use.What is the decimal value of %11000001 ? *04.#144 (128+16) 02. (%11111 111) Lets go on and ask ourselves what a WORD is!? A word consists of 16bits. A BYTE has the maximum value of 255. this is when all the digits are ON. so yo u have probably already figured out that longwords are slower than words. Yes. a byte consists of 8 bits. But what are theese things?? Well.#193 (128+64+1) .What is the binary value of #12 ? *09. So for example %1110001010111110100010101011111 i s a longword. So what the hell is a BYTE? Well. There you have it its as simple as that! Bits&Words&Longwords&Bytes -------------------------Bits are the values used in the binary system. A LONGWORD consists of 32bits.What is the decimal value of %0000001100000001 ? 05.How many bytes does a longword have ? Answers to Exercises --------------------01.What is the hexadecimal value of %00100101 ? 10.What is the decimal value of %10010000 ? 02. as se en in the section about the binary system. because moste modern assemblers have built in calculators for this kind of thing.How many bits does a longword have ? *11.assembler.What is the decimal value of $ff ? 06.What is the decimal value of %00000111 ? 03. Exercises --------*Theese ones are a bit harder than the other. the 0s and 1s.

%00001100 09. under the nickname ChaoZer.$25 10.#769 05.#255 06.4 Bytes (256+512+1) (16*15+15) (16*4) (16*9+3) (8+4) (First get the decimal value and then transform it to hex. .se/~chaozer/" You can also find me on IRC. My homepage is at "http://www.32 Bits 11.) Email&More ---------Want to get in touch with me? My email is "chaozer@algonet.se".algonet.04.#64 07.#147 08. almost everywhere.

Sign up to vote on this title
UsefulNot useful