Download presentation
Presentation is loading. Please wait.
1
Assembly Language Advantages 1. It reveals the secret of your computer’s hardware and software. 2. Speed. 3. Some special applications and occasions. Disadvantages 1. Not as easy to do the programming. 2. Debug is not as easy compared with high- level language. 3. Not transferable between different CPUs.
2
Registers Intel 16-bits registers AH AL BH BL CH CL DH DL AX BX CX DX Flag IP BP SP SI DI CS SS DS ES Status and Control RegistersSegment Registers Date Registers Index Registers
3
Registers Intel 32-bits registers AX BX CX DX FLAGS IP EAX EBX ECX EDX EFLAGS EIP EBP ESP ESI EDI CS SS DS ES Status and Control RegistersSegment Registers Date Registers Index Registers FS GS
4
Flag Register 16-bits Flag Register The most common used flag bits x x x x O D I T S Z x A x P x C O D I S Z A P C O—Overflow D--- Direction I-----Interrupt S----Sign Z---Zero A---Auxiliary Carry P----Parity C----Carry
5
General Rules about Flags “1”---Set the flag. “0”---Clear the flag. “?”---May change the flag to an undetermined value (Blank)---The flag is not changed * ----Change the flag to specific rules associated with the flag
6
Examples * * * ADD --- Instruction O D I S Z A P C HLT---Stop the CPU until a hardware interrupt occurs. O D I S Z A P C IDIV---Signed Integer Division ? ? ?
7
The Hello World Program title Hello World Program (hello.asm) ; This program displays "Hello, world!".model small.stack 100h.data message db "Hello, world!",0dh,0ah,'$'.code main proc mov ax,@data mov ds,ax mov ah,9 mov dx,offset message int 21h mov ax,4C00h int 21h main endp end main
8
Arithmetic Instructions ADD and SUB instructions ADD reg, reg ADD mem, reg ADD reg, mem ADD reg, immed ADD mem, immed ADD accum, immed Flag O D I S Z A P C SUB has the similar instruction format * * *
9
MS -Debug Debug is a MS-DOS command which can be used to enter machine language into the computer either to create programs or test computer peripherals by receiving back various computer machine code.
10
ABOUT DEBUG Debug is a method of looking at portions of your computer and writing assembly code to perform certain tasks on your computer. MS-DOS 2.x - 4.x uses debug.com MS-DOS 5.x and above uses debug.exe
11
A History of MS-DEBUG In 1980, Tim Paterson began working on a 16-bit OS for the 8086 S-100 Bus card he had designed for SCP (Seattle Computer Products) the previous year. To help in getting QDOS (later called 86-DOS) to work correctly, Tim created a debugger in a ROM chip; the code for that ROM version was released into the Public Domain. Later, Tim adapted the code to run as a.COM program under QDOS, and also added the ability to disassemble 8086 machine code.
12
In the meantime, Microsoft® had been busy purchasing the rights to sell Tim's QDOS to IBM® for their 'secret' PC project. Tim was hired by Microsoft as the primary author of their first OS. When he completed his work on IBM's Personal Computer™ DOS 1.00 in 1981, his DEBUG.COM utility was included with it. All the functionality that Tim put into DEBUG is still there and little has been added to it (the major exception being the Assemble command; added under DOS 2.0).
13
Debug Availability AVAILABILITYThe debug command is an external command and is available in the below Microsoft Operating Systems. external command All Versions of MS-DOS Windows 95 Windows 98 Windows ME Windows NT Windows 2000 Windows XPAll Versions of MS-DOS Windows 95 Windows 98 Windows ME Windows NT Windows 2000 Windows XP
14
Debug Commands ? assemble A [address]assemble A [address] Compare C range address dump D [range] enter E address [list] fill F range list go G [=address] [addresses] hex H value1 value2 (Learn 2's Complement!)hex H value1 value2 input I port load L [address] [drive] [firstsector] [number] move M range address name N [pathname] [arglist] output O port byte Proceed P [=address] [number] quit Q......... (Learn this first!)quit Q Register R [register] search S range list trace T [=address] [number] unassemble U [range] write W [address] [drive] [firstsector] [number]
15
Debug -F -D -E -T----Make sure you check the IP to see if its counts is pointing the right location. -R IP to change it -A 100 Mov dl, [0200] Mov [0201], dl Mov ax, 4c00(h) Int 21
16
Example Under Windows XP: 1. Click run and type cmd 2. type debug 3. type D40:0 and you will get a display screen with the first line looks as: 0040:0000 F8 03 F8 02 E8 03 E8 02 - 78 03 78 02 BC 03
17
The meaning of the line F8 03 F8 02 E8 03 E8 02 78 03 7802 BC03 COM1 COM2 COM3 COM4 LPT1 LPT2 LPT3 The above graph shows you what the feed back means as far as port, so if you see F8 03, this would be an indication that COM1 is being detected; if you see 00 00, this is an indication that it is not being detected, which could mean that hardware is bad or that it is disabled in CMOS.CMOS
18
Some Debug Routine Applications TESTING PORTS CLEAR CMOS PRINTER TEST JOYSTICK TEST ERASE SECTOR 2 ERASE ALL HDD INFORMATION ERASE HDD AND CLEAR CMOS DISCHARGE OLD LAPTOP BATTERIES REBOOT YOUR COMPUTER CREATE A SLEEP FILE FOR DOS CHECK BIOS DATE VIDEO CARD TYPETESTING PORTS CLEAR CMOS PRINTER TEST JOYSTICK TEST ERASE SECTOR 2 ERASE ALL HDD INFORMATION ERASE HDD AND CLEAR CMOS DISCHARGE OLD LAPTOP BATTERIES REBOOT YOUR COMPUTER CREATE A SLEEP FILE FOR DOS CHECK BIOS DATE VIDEO CARD TYPE
19
CHECK BIOS DATE The below debug routine is to check the date of your BIOS. All BIOS dates on PC compatible computers is stored at memory address FFFF5h. To display the date of your BIOS do the following: At the C:\> type debug - d FFFF:5 L 8 After typing the above command you should receive a string similar to: FFFF:0000 30 34 2F-33 30 2F 39 38 4/30/98 The 4/30/98 would be the date of your computer BIOS.
20
Check Your Computer’s Video -d c000:0040
21
Debug Mov si, 0200 Mov ax, [si] Mov [0270], ax Mov ax, 4c00 Int 21 -T
22
Assembling, linking, And Debugging Debug and Assembler Source File Listing File Object File Link Library Map File Executable Program Output Assembler Linker Loader
23
Start Stop Length Name Class 00000H 004D0H 004D1H _TEXT CODE 004D2H 00665H 00194H _DATA DATA 00670H 0076FH 00100H STACK STACK Origin Group 004D:0 DGROUP Program entry point at 0000:0000 A typical Map File (From Hello.asm) The main feature for the map file is that it list all the information about each program segments.
24
Object File (From Hello.asm) € C:\IRVINE\CH01\HELLO.asm! ˆ ¡CV7–K STACK_DATADGROUP _TEXT$$TYPES $$SYMBOLSDEBTYP DEBSYMSTACKDATACODEø˜H ö˜ H ú˜ t ß™ !† ¦™! š ÿÿY Hello, world!$† ¸ ŽØ´º Í!¸ LÍ!Õœ ÈUÄX” ¨ òñ, Š HELLO.obj6 /Microsoft (R) Macro Assembler Version 6.13.7299 message main œ ÌRÌvTŽŠ ÁP ^
25
Target Processor Directives.8086----8086, 8088.186---.286---.386.486.586.287.387 When using.386, the program can only run on 386 and above processors.
26
Floating-Point Unit 80-bit Registers ST(0) ST(1) ST(7) FPU Instruction Pointer FPU Data Pointer Tag Register Control Register Status Register 48-bit Pointer Register 16-bit Control Register Opcode Register
27
Debug and Debugger MASM supplies a good 16-bit debugger named Code View. TASM supplies one named Turbo Debugger. For 32-bit Windows Console programs, the preferred debugger is Microsoft Visual Studio (msdev.exe), part of Microsoft Visual C++.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.