200 likes | 469 Views
Assembly Language – Lab 2. Registers, Instructions, ASCII Table. Registers. Data Registers: Accumulator Register (AX), Base Register (BX), Count Register (CX), Data Register (DX). Address Registers:
E N D
Assembly Language – Lab 2 Registers, Instructions, ASCII Table
Registers • Data Registers: Accumulator Register (AX), Base Register (BX), Count Register (CX), Data Register (DX). • Address Registers: • Segment Registers: Code Segment (CS), Data Segment (DS), Stack Segment (SS), Extra Segment (ES). • Pointer and Index Registers: Stack Pointer (SP), Base Pointer (BP), Source Index (SI), Destination Index (DI). • Instruction Pointer (IP).
Note: any register can be used except CS & IP Before After 00 00 00 2A DH DLDH DL MOV Instruction • Syntax: MOV destination, source • Example: MOV DL,42 ; 42 in decimal is ‘*’
MOV Syntax – Legal form • list of possible combination of MOV operands:MOV <REG>,<REG>MOV <REG>,<MEM>MOV <MEM>,<REG>MOV <REG>,<CONST>MOV <MEM>,<CONST> • Example: MOV VAR1, AX MOV AX, BX
Before After 3E 00 02 00 AH AL AH AL 00 02 00 3E BH BL BH BL XCHG Instruction • Used to exchange the contents of: • Two registers. • A register and a memory location. • Syntax: XCHG destination, source • Example: XCHG AH, BL
Basic Arithmetic Instruction • ADD • SUB • INC • DEC
Before After Before After 01BD 03C8 01AC 01AC AX AX AX AX 0585 0585 043205DE BXBX WORD1 WORD1 ADD and SUB Instructions • Syntax: ADD destination, source SUB destination, source • Examples ADD WORD1, AX SUB AX, BX
Before After Before After 00070008 FFFFFFFE VAR1 VAR1 VAR2 VAR2 INC and DEC Instructions • Syntax: INC destination DEC destination • Examples: INC VAR1 DEC VAR2
INT Instruction • Invoke a DOS or BIOS routine. When one wants to read from the keyboard or disk or mouse, or write to the screen, an INT (interrupt) is used. • Format: INT interrupt_number
INT 21h • A particular function is requested by placing a function number in the AH register and invoking INT 21h. • Some of the functions are: Function number Routine 1 single-key input 2 single-character output 9 character string output