Instruction set

    Assembler commands are used to be called instructions. Every instruction has its meaning (really logical), mnemonics or form (can be with no parameters or with one, two three parameters, which have to be mutual compatible, i.e. byte - byte, word - word) and its code number, which isn't important to us. Many instructions have also an output, mostly transfered to a particular register or the result can be read from the flag register (or both).

    In most cases the parameters are registers or memory cells. This can be defined using a label outside the executed part of the program using its name and content, the most popular is the DB directive used for defining a byte for a "byte acces" or DW used for defining a word for a "word acces". Examples:

variable DB 1
text_var DB "This is a text stored byte by byte beginning with this position",2,5,"A"
var001  dw 2,27,32768,-32768

    You can acces them using expression [variable] for getting or changing its value or variable for getting its address.

Data move instructions

    Data move instruction are used for filling registers with numbers, exchanging data between registers or exchanging data between a register and memory.

MOV: possibly the most important instruction. In general, it's designed store a value into a register. It has two parameters - destination and source. E.g. MOV CX,AX moves the content of AX into CX register.
    This instruction has no influence to the flag register, it has two parameters, registers or memory cells. The second parameter can also be a number. Examples:

MOV AH,CL
MOV DX,[var001]
MOV AL,[text_var]
MOV BH,27

STOS: designed to write data into memory in a simple way. Instruction STOSB - store string - byte (STOSW - store string - word) writes a byte (word) into address DI of segment ES, thus ES:DI. Then this pointer is increased by one (two) bytes.
    This instruction has no influence to the flag register. If we write in front of this instruction the REP prefix, instruction is executed as many times as the number in CX. Examples:

STOSB
REP STOSW

Arithmetic instructions

    Arithmetic instructions resemble basic operations known from mathematics like addition, subtraction, multiplication, division. But there is also something more - comparison.
    Overflow (or underflow as a special case of overflow) occurs when the result doesn't fit into the memory cell used for the result, e.g. by adding bytes 150 and 150 the result should be 300, but this number can't fit in a byte, thus the result overflows (indicated by the Carry flag) and instead of the correct result we read number 44 (=300-256). Similar occurs by subtraction.

ADD: is addition. It has two parameters - both addends. The result is stored into the place determined by the first parameter.
    This instruction influences the ZF (if the result is zero) and CF (if overflow occurs). Examples:

ADD AL,AH
ADD [var001],44
ADD DX,[var001]
ADD BH,27

SUB: is subtraction. It has two parameters, subtrahend and minuend. The result is stored into the place determined by the first parameter
    This instruction influences the ZF (if the result is zero) and CF (if overflow occurs). Examples:

SUB BX,CX
SUB [var001],44
SUB AL,0FFh
SUB CX,01011000b

MUL: is multiplication. It multiplies the AL register (or AX if the parameter is not a byte but a word) with the chosen register or memory cell and stores the result into AX (or into DX the higher, more significant part, into AX the lower, less signioficant part). The multiplication is for unsigned numbers.
    This instruction influences the CF (if the higher half of the result is not zero), it has one parameter. Examples:

MUL CL
MUL BX
MUL [DI]
MUL [variable]

DIV: is division. It divides the AX register (or DX as the higher part and AX as the lower part, if the parameter is not a byte but a word) by the chosen register or memory cell and stores the result into AL (or AX) and the remainder is stored into AH (DX). The division is for unsigned numbers.
    This instruction has no influence to the flag register, it has one parameter other than zero. Example:

DIV CH
DIV AX
DIV [var001]

CMP: is comparison. It compares the content of the first parameter with the content of the second one. If the first is higher (speaking about unsigned numbers) both ZF and CF are set to zero, if they are equal is ZF=1 and CF=0 and if the second is higher is CF=1 and ZF=0.
    This instruction sets the flags as though a subtraction occured without changing the content of the parameters. It has two parameters. Examples:

CMP AL,DH
CMP AX,CX
CMP [var],BH

Logic instructions

    Logic instructions are used for working with data as real physical data, not as with a numbers.

AND: is the bit-level logic multiplication. That means for each couple of according bits in the content of both parameters a conjunction is calculated (so both bits have to be set to set the result, in other case the result bit is zero) and the result is stored into the place determined by the first parameter.
    This instruction influences the ZF (if the result is zero) and resets the CF. Example:

MOV AH,00110100b
MOV AL,10011101b
AND AL,AH
;AL<-00010100b

OR: is the bit-level logic addition. That means for each couple of according bits in the content of both parameters a disjunction is calculated (so both bits have to be zero to reset the result, in other case the result bit is set) and the result is stored into the place determined by the first parameter.
    This instruction influences the ZF (if the result is zero) and resets the CF. Example:

MOV BL,00110100b
MOV CH,10011101b
OR BL,CH
;BL<-10111101b

XOR: is the bit-level logic exclusive addition. That means for each couple of according bits in the content of both parameters an alternative is calculated (so both bits have to be different to set the result, in other case the result bit is zero) and the result is stored into the place determined by the first parameter.
    This instruction influences the ZF (if the result is zero) and resets the CF. Example:

MOV DH,00110100b
MOV CLL,10011101b
XOR DH,CL
;DH<-10101001b

Jumps instructions

    Jumps instructions are used for branching programs and influencing their course. They are divided in two groups, unconditional (JMP) and conditional jumps (JC, JNC, JZ, JNZ), which will finally enable us to test the flag register.

JMP: is an unconditional jump. It has just one parameter - a label. After its execution the program will continue beyond this label.
    This instruction has no influence to the flag register. It has one parameter - destination of the jump. Example:

JMP contin1
........
contin1: MOV AH,20h
;the program will continue in its execution right here

JC: is a conditional jump. It has just one parameter - a label. After its execution, if CF=1, the program will continue beyond this label.
    This instruction has no influence to the flag register. It has one parameter - destination of the jump. Example:

JC contin2
........
contin2: MOV AH,20h
;only if CF=0 the part of program with "stops" was executed

JNC: is a conditional jump. It has just one parameter - a label. After its execution, if CF=0, the program will continue beyond this label.
    This instruction has no influence to the flag register. It has one parameter - destination of the jump. Example:

JNC contin3
........
contin3: MOV AH,20h
;only if CF=1 the part of program with "stops" was executed

JZ: is a conditional jump. It has just one parameter - a label. After its execution, if ZF=1, the program will continue beyond this label.
    This instruction has no influence to the flag register. It has one parameter - destination of the jump. Example:

JZ contin4
........
contin4: MOV AH,20h
;only if ZF=0 the part of program with "stops" was executed

JNZ: is a conditional jump. It has just one parameter - a label. After its execution, if ZF=0, the program will continue beyond this label.
    This instruction has no influence to the flag register. It has one parameter - destination of the jump. Example:

JNZ contin5
........
contin5: MOV AH,20h
;only if ZF=1 the part of program with "stops" was executed

    So, I hope you haven't died because of boredom... These instructions are just a little part of all instructions, but they will be enough for us now. If there is something new in the examples part, it will be explained on-place.