ллллллл л л ллллллллл л лллллллл л л л л л ллл лл л л л л л л лл ллллллллллл л л л л л л л л л л л л л л л л л л лллллл ллллллллл л ллл ллл лллл ллллллл лллл лллллллл л л л ллллллл л ллл л л л л л л лл л лл л л л л л л л лллл л л лл л л л л ллллл л л лллллллл л лл лллллллл лл л л л л л л л л л ллллллл л л лллллллл л л лл ллллллл Distributed By Amateur Virus Creation & Research Group (AVCR) ФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФФ An introduction to ASM THE BASE OF 10 When most people see the number 10 they think of ten, or X. This is because we are not computers, and we like small numbers. In our numbering system, to go from 1 to 10 we multiply by 10, and to go from 10 to 100 we multiply by ten again, refer to the chart below: 1 10 100 1000 10000 1 *10 *10 *10 *10 THE BASE OF 2 Your microprocessor has around 12 psudomemory locations which can store a number, called a register. Each register contains a high, and a low portion, each having an 8 bit capacity, thus you could have up to 24 8 bit memory locations if you do not need the whole register's memory capacity. The register has either an on (true) or an off (false), and because of this we can not have the luxury of a number higher than 1, for 0 is false and 1 is true. Each person has to work with 0's and 1's to make every number imaginable! The art of converting 1's and 0's into recognizable numbers and working with these numbers is called binary arithmatic. Before we delve into binary arithmatic lets look something more familiar: Base --> 10§ <-- Exponent We look at numbers with a BASE of 10, while binary arithmitic looks at numbers with a base of 2: 128 64 32 16 8 4 2 1 BASED on 2--> 2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0 Keeping the above in mind, lets count to ten in binary arithmatic, and a more familiar base 10 arithmatic: 0 = 0000 1 = 0001 2 = 0010 3 = 0011 4 = 0100 5 = 0101 6 = 0110 7 = 0111 8 = 1000 9 = 1001 10 = 1010 Are we excited yet? Well if not, then you will be soon, because now we are going to operate with binary numbers: Lets add 2 and 3 in base 10 and binary: 1 2 0010 +3 +0011 --- ------ 5 0101 Confused yet? Well lets take this step by step. To add 0010 (2) and 0011 (3) we need to add up the digits as we would in base 10. 1+0 is 1, and we make a 1 in binary with 0001, easy. Now, lets take 1+1=2, how do we make a two in binary? A two in binary is 0010, so the last number goes in the answer space, and the 1 is carried. 1+0+0=1 and a 1 in binary is 0001, so just a 1 is needed. Finally 0+0 in binary is 0000 so a 0 is needed. Thats not so hard, is it? Alright, now we must subtract numbers in binary. Lets take 3 and 2: 3 0011 -2 -0010 --- ------ 1 0001 Nice and easy, you deserve a break after the adding , so the subtracting is exactly the opposite of adding, not much to learn! INCREMENT \ DECREMENT To increment something is to add 1 to it, so if we increment the base 10 number 3 we get 4, much the same way, if we increment the binary number 0011 we get 0100. The ASM instruction to increment is: INC # # could be a binary number, but it also could be a register. If the number 0001 is stored in the AH register then "INC AH" would store 0010 in the AH register. To decrement something is to subtract 1 from it, so if we decrement the base 10 number 3 we get 2, much the same way, if we increment the binary number 0011 we get 0010. The decrement syntax is: DEC # The processor can only increment to the # 9999, and then it goes back to 0000, BUT a flag is set explaining that we are not at 0000 but rather at 10,000d (I would rather not figure out how to write 10,000 in binary so I just put a d after it to indicate decimal, that is a valid ASM argument)! MOV IN ALL ITS GLORY: The MOV statement moves a number from the register to memory, or from the memory to a register, or even within each. The syntax for the MOV statement is: MOV dest,source Thus, if I type "MOV AX,BX" the processor will move the contents of the BX register into the AX register. If I type "MOV [AX],BX" then the processor will move what is in the BX register into the number location in your RAM corisponding to the number in the AX register. INT IT THE EASY WAY: The INT argument calls a dos software interrupt or a hardware interrupt, but lets first talk about the software interrupt. A software interrupt is very similar to a subroutine, in that the program is written for you, and you only have to put in the information explaining where everything is. The syntax for the INT argument is: INT # Lets take an example, we will park the hard disk heads using a dos software interrupt: MOV AH,19h ; puts 19 hexidecimal in the AH (A high) register. MOV DL,80h ; puts 80 hexidecimal in the DL (D low) register. INT 13h ; calls the interrupt See how easy it is to use software interrupts? Each interrupt has its own command set, so you need to get a list of interrupts, and what arguments you need in which registers. PUSH AND POP: The PUSH statement pushes a register into memory and the POP statement pops it back into the register: PUSH AH MOV AH,19h MOV DL,80h INT 13h POP AH This simple program saves the AH register, then it parks the heads, and lastly it restores the AH register. This is the end of issue one of an Introduction to ASM, in our next issue we will discuss the functions of all of the ASM codes, and explain hardware interrupts, and MUCH more, so look for the next issue of AVCR Magazine and look for AVCR-01.006! Written By: Th Patron