Vous êtes sur la page 1sur 6

Introduction to Machine Language DEBUG A software that is classifies as debugger which is used for testing and debugging executable

programs Advantages It is Free It is universally available It is simple to use It requires relatively little memory DEBUG COMMANDS

E (Enter)
-enable you to key in data or machine instruction into memory beginning at a specific location address. E.g -E 0200

D (Display or Dump)
Displays the contents of a portion memory ni hex and ASCII forms starting with the given address E.g. -D 0200

A (Assemble)
Allows you to create a program in mnemonic or symbolic code. E.g. -A 0100

T (Trace)
Runs he program in single-step mode. It also displays the new values of the registers and the next instruction to be executed. E.g -T

G (Go)
Runs the program as a whole in memory an displays the output E.g. -G

U (Unassemble)
Lists all the instructions contained in the program beginning at the given address. You can also specify the last address location. E.g. -U 0100 -U 0100 0109

N (Name)
Gives a name to your program, coded as N <path> <filename> Extention nae is .COM E.g. -N A:SAMPLE.COM

W (Write)
Saves the program onto disk storage E.g. -W BASIC ASSEMBLY INSTRUCTIONS USED IN DEBUG

MOV (Move Data)

Copies and transfers data between two registers, or between an immediate data to a register Format: MOV <register>, <register> MOV <register>, <immediate data> Example: MOV AX, BX MOV CX, 5083 MOV CL, DL MOV BL, 33

ADD (Add Data)


Used to get the sum of two registers or a register and an immediate data, and stores the result to the left most register Format: ADD <register>, <register> ADD <register>, <immediate data> Example: ADD CX, BX ADD AX, 0308 ADD AL, BL ADD DH, 85

MUL (Multiply Data)


It is used to get the product of a given register and AX register, and stores the result to AX register. If the product is greater than 16 bits, the overflow is stored in DX register. Format: MUL <register> Example: MUL CX

DIV (Divide Data)


Used to divide the value of a given register and AX register, stores the quotient to AX and the remainder to DX registers respectively Format: DIV <register> Example DIV BX

INC (Increment by One)


Used to increase the value of the register by one (1). Format: INC register Example: INC AX INC CH

DEC (Decrement by One)


Opposite of INC, decreases the value of the register by one (1). Format: DEC <register> Example: DEC AX DEC CH

LOOP (Loop Until Complete)


It controls the execution of a program segment in a specified number of times. The CX register should contain a count value before starting the loop and automatically decrements by one (1) If CX is not equal to zero (0), it transfers to its operand address which points to the start of the loop; otherwise it drops to the nest instruction. Format: LOOP <offset address> Example: LOOP 0108

CODING ASSEMBLY LANGUAGE IN TASM


Comment
Ignored by the assembler. Can improve programs readability and clarity Begins with a semicolon ( Ways to include comment Any statement whose first non-block character is a semicolon Example: ; This program displays Hello, World! At the end of an instruction Example: MOV AX, 8053H ;initializes the value of AX to 8053

Reserved Words
Words in which the assembler assigns a special meaning and it cannot be used as identifiers Using reserved words for a wrong purpose causes the assembler to generate an error message Categories of reserved words Instructions Statements that will be translated into machine language and executed by the computer. Examples: MOV ADD SUB MUL DIV INC DEC LOOP CMP

Directives Statements that give information to the assembler Sometimes called pseudo-ops Examples: TITLE DOSSEG .MODEL .STACK .DATA .CODE Rules in Constructing Valid identifier It must use letters (A...Z, az), number (09) and/or special characters like underscore (_), question mark (?) and at sign (@). It must always start with a letter It must not use reserved words It must not exceed to 31 character. Examples of valid identifiers: neym r2d2 num_1 msg8 Examples of invalid identifiers: title num-1 4ever

Statement May begin anywhere on the line Each line can only contain one statement Assembly is not case sensitive Examples: ADD AX, BX ; uses 2 operands DEC CX ; uses RET ; no operand

Most common directives


TITLE It creates a title (up to 60 characters) of a source listing. Format: TITLE <TEXT> Examples: TITLE This program displays Kumusta, BUPC! TITLE PROGRAM1.ASM .MODEL It specifies and initializes the memory model before defining any segment Format: .MODEL <memory-model> Examples: .MODEL TINY .MODEL SMALL .MODEL MEDIUM .STACK It defines the size of the attack. The default stack size is 1,024 bytes which you can overrule. Format: .STACK <size> Example: .STACK 0100h .DATA It defines and marks the beginning of data segment Format: .DATA Example: .DATA .CODE It defines and marks the code segment which consists of a set of instructions. Format:

.CODE Example: .CODE START: Defines the start of program execution Format: START: Examples: START: END It is placed at the last line of the source code Format: END Example: END START STRING Used for descriptive data such as persons name or simply a message. It must end with dollar ($) symbol and defined in double quotation marks ( ). DB is the conventional format for defining string of any length. Example: neym db Louis Vuitton$ Numeric Constant Used to define arithmetic values and memory address. It is defined with a radix specifier such as d for decimal, b for binary and h for hexadecimal. Example: msg db Bon jour, monsieur!, 0Ah, 0Dh, $ msg db Bon jour, monsieur!, 10d, 13d, $ msg db Bon jour, monsieur!, 00001010b, 00001101b, $

Screen Processing
The monitor A typical video screen has 80 columns numbered form 0 to 79 and 25 rows numbered from 0 to 24. Clearing the screen in Assembly Approach Interrupt 10h and function 06h handles the process of clearing the screen and scrolling Clear all or part of display beginning at any screen location and ending at any higher-numbered location. Sample code shows how to clear screen code in assembly MOV AX, 0600h ; AH = 00h (scroll), AL, 00h (Full screen) MOV BH, 07h ; 0 (BLACK BACKGROUND), 7 (WHITE TEXT COLOR)

MOV CX, 0000h ; CH = 00H (ROW), CL, 00H (COLUMN) MOV DX, 184Fh ; DH = 18H (ROW), DL=4FH (COLUMN) INT 10h ; CALL INTERRUPT SERVICE SETTING THE CURSOR FUNCTION

Interrupt 10h is the BIOS operation for screen handling and function 02h tells the operation to set the cursor Its position determines where the next character is to be displayed. MOV AH, 02H ; REQUEST TO SET THE CURSOR POSITION MOV BH, 00H ; PAGE NUMBER 0 MOV DH, 0AH ; ROW - 10 IN DECIMAL MOV DL, 08H ; COLUMN = 8 IN DECIMAL INT 10H

Vous aimerez peut-être aussi