You are on page 1of 43

INTRODUCTION TO

MACHINE
LANGUAGE`
BUG

is a mistakes or error in a program or computer system.

DEBUGGING
Methodical process in finding and reducing the number of bug or
defects in a computer program.

DEBUGGER
Program tools provides an environment for testing load module.
LOAD MODULES
Allow us to run machine code programs such a way we can
observe the changes a program makes to register and
memorize. They are executable files that can have extension
of .com or .exe.
Some examples of Debugger include:

a. Code view e. Turbo debugger


b. Debug f. Visual Studio Debugger
c. GNU Debugger
d. T – Bug
DEBUG
Isa software that is classified as debugger, which is
used for testing and debugging executable
programs.
FEATURE OF DEBUG
A. Display all program code and data in hexadecimal
format and any data that you enter into memory
must also be in hex form.
B. Provides a single step mode, which allows you
to execute a program one instruction at a time so
that you can view the effect of each instruction on
memory locations and registers.
ADVANTAGE OF DEBUG
It is free
It is universally available
It is simple to use
It requires relatively little memory
DOS debug.com
The debug can be used to:
a. Provide a controlled testing environment so you
can monitor and control the execution of a
program
b. Load, alter or display any files
c. Execute object files. Object files are executable
programs in machine language format
DEBUG COMMANDS
1. QUIT
finishes the session and exits back to DOS.

2. H (Hex arithmetic)
shows the sum and difference of two 4 digit
hexadecimal numbers as H<hex value> <hex value>
3. R (register)
Allows you to display all register and their values. It also
shows the next instruction and permits you to change the value
of a particular register.
4. E (enter)
Enables you to key in a data or machine instructions
into memory beginning at a specific location address.
5. D (Display or Dump)
Display the contents of apportion memory in hex and
ASCII forms starting with the given address.
6. A (assemble)
Allows you to create a program in mnemonic or
symbolic code. It also relates the assembly source
statements that you create into machine code.
7. T (trace)
Runs the program in single step mode. It also displays
the new values of the registers and the next instruction
to be executed.
8. G (go)
Runs the program as a whole in memory and displays
the output.
9. U ( unassemble )
Command lists all the instructions contained in the
program beginning at the given address. You can also
specify the last address location.
10. N (name)
Gives a name to your program, coded as N <path>
<filename>

11. W (write)
Saves the program into disk storage.
Rules of Debug Commands
It is not case sensitive
It assumes that all given are in hexadecimal format
You can enter a space only when it is needed to
separate parameter of a particular command
You should specify segments and offset with a
colon, in the form <segment>: offset
SAMPLE SESSION WITH
DEBUG
Starting debug
Quitting and closing the DEBUG
environment
Adding and subtracting 4-digit
hexadecimal values
Left most part is the sum and the right most part is
the difference.
Viewing the contents of the
register
Changing the contents of a specific
register
Entering String
1. Convert every character into its hexadecimal
equivalent code using ASCII reference table.
H e l l o , W o R l D !
48 65 6c 6c 6f 2c 20 57 6f 72 6c 64 21
2. Add the last number 24h which is the ASCII for $
symbol. It tells dos that this is the end of the string.

H e l l o , W o R l D ! $
48 65 6c 6c 6f 2c 20 57 6f 72 6c 64 21 24
3. Enter these hexadecimal codes using the command E
0200.

Type E 0200 the debug prompts and press ENTER key.


Key in the first hexadecimal code then press SPACE
bar.
Key in the second hex code then press SPACE bar.
Do it over and over again until you have entered 24 for
the dollar sign
Press ENTER key to end the process.
Displaying the input string
Creating a program in debug
Executing one instruction at a time
Type T and press ENTER key. DEBUG will display
the new values of the registers and the next
instructions to be fetched and executed, Repeat this
process until NOP is displayed. And it means that’s
the end of tracing the program.
MOV AX, 0BEA
MOV BX,0103
ADD AX, BX
INT 20
Running the entire program
Basic Assembly Language used in
Debug
1. MOV (Move Data)
This instruction copy and transfers data between two
register, or between an immediate.
Format: MOV <register>, <register>
MOV<register>, <immediate data>
Example: MOV AX, BX
MOV CX, 5083
MOV CL, DL
MOV BL, 53
2. ADD (Add Data)
This instruction 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
3. SUB (Subtract Data)
This instruction used to get the difference of two integers
or a register and an immediate data, and stores the result
to the left most register.
Format: SUB <register>, <register>
SUB <register>, <immediate data>
Example:SUB CX, BX
SUB AX, 0308
SUB AL, BL
SUB CL, 85
4. MUL (Multiply Data)
This instruction 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
5. DIV (divide data)
This instruction used to divide the value of a given
register and AX register, and stores the quotient to AX and
the remainder to DX register respectively.

Format: DIV<register>
Example:DIV BX
6. INC (Increment by One)
This instruction used to increase the value of the register
by one(1).

Format: INC <register>


Example:INC BX
“ INC CH
7. DEC (Decrement by One)
This instruction is the opposite of INC, instead of
increasing it decrease the value of the register by one(1).

Format: DEC <register>


Example:DEC AX
DEC CH
8. LOOP (loop until complete)
This instructions 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 decrement by one (1).
If CX register is not equal to zero (0)m it is transferred to
its operand address which points to the start of the loop;
otherwise it drops through to the next instruction,
Format: LOOP <offset address>
Example:LOOP 0108

You might also like