There are 4 math instructions, aptly named ADD,SUB,MUL,and DIV.## ADD is used such as the following: add ax,bx ; will add the value in BX + the value in AX and put the result in AX. AX = AX + BX SUB is similar: sub dx,cx ; will subtract the value in DX - the value in CX and put the result in DX. DX = DX - CX Easy.

ADD and SUB## MUL and DIV are somewhat more complicated and should be avoided if possible. However many times, you do need to do multiplication and division, so you have to use MUL and DIV (there are actually better instructions, these are just the basic ones). MUL works like so: mul bx ; will multipy AX * BX and put the result in AX. Note that one of the factors is always AX and the result is always put into AX. Also, DX will contain the upper 16bits if the multiplication uses an X register (AX,BX,CX,DX) and AX will contain the lower 16bits. Realize that you can do all these math instructions with the High and Low 8bit parts also, provided that you don't so something like sub ah,bx ; won't assemble because you can't subtract a 16bit thing from an 8bit thing. DIV works similarly like so: div cx ; will divide AX/CX and put the result in AX with the remainder in DX. Easy, just remember that AX and DX get changed.

MUL and DIV## With what you know now, you can write a program to output the alphabet. It'll be (very) long, but you can do it! Tomorrow, Functions in assembly! Happy coding!, -Mike H

This Day In ReviewIntro - Day 5

Contact