Assembly Language Instructions and MS-DOS Functions
Classified in Computers
Written on in English with a size of 3.39 KB
Data Transfer Instruction:
LEA
Gets source effective address and stores it in the target. Source segment address is stored in DS. Example: LEA DX, OPERANDO1
Control Transfer Instructions
Loops
Operation (IP decrement) + Conditional jump on operation result.
Example:
MOV CX, 4
Bucle:
INC BX
ADD BX, CX
LOOP Bucle
Compare Instruction:
CMP
Compares source and target operands and properly modifies the flag register. It internally works by subtracting the target from the source operand. Operands are equal if the result is zero. Source is greater than target if the result is negative. Target is greater than source otherwise. Example: CMP AX, DX
; Compares AX and DX.
Interrupt Instructions:
INT
INT jumps to a specified interrupt address. i8086 interrupt addresses are calculated by multiplying interrupt_type
by 4. interrupt_type
is an unsigned number between 0 and 255. The interrupt array is composed of two words: the offset is the first one, and the segment address is the second word. Example: INT 21h
.
IRET
Flag register is restored, and IP gets the returning address from the top of the stack. It is used to finish an interrupt procedure. Example: IRET
.
MS-DOS Interrupt Services: INT 21h Functions
- 01h: Program waits until a key is depressed on the keyboard. The read character's ASCII code is returned in AL and echoed on the screen.
- 02h: Write a single character to the screen. The character's ASCII code must be stored in DL.
- 08h: Program waits until a key is depressed on the keyboard. The read character's ASCII code is returned in AL without echoing on the screen.
- 09h: Display a memory-stored string character on the screen. The string must end with '$'. The string address must be stored in DS:DX.
- 0Ah: Read a string of characters from the keyboard and store it in memory. The memory storage address must be stored in DS:DX.
- 4Ch: Function number must be stored in AH. The ERRORLEVEL number to be returned must be stored in AL. The returned ERRORLEVEL can be processed by MS-DOS using:
IF ERRORLEVEL n action
.
BIOS: INT 10h:
- 00h: Set video mode.
- 02h: Position the cursor on the text mode screen using specified coordinates.
- 06h: Window scroll up.
- 07h: Window scroll down.
- 09h: Write character and attribute at the current position.
- 0Ah: Write character and the last attribute at the current position.
- 0Eh: Teletype writing character mode (write a character and position the cursor on the next column).
BIOS: INT 16h:
- 00h/10h: Read a character from the keyboard buffer. Wait until a key is depressed if the buffer is empty.
- 01h / 11h: Expanded keyboards. Returns buffer state. The read character is not removed from the keyboard buffer. To flush the buffer, functions 00h or 10h must be used.