Assembly Language Programming Part 3

Slides:



Advertisements
Similar presentations
Register In computer architecture, a processor register is a small amount of storage available on the CPU whose contents can be accessed more quickly than.
Advertisements

Registers of the 8086/ /2002 JNM.
Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU
Lab6 – Debug Assembly Language Lab
ICS312 Set 3 Pentium Registers. Intel 8086 Family of Microprocessors All of the Intel chips from the 8086 to the latest pentium, have similar architectures.
8051 ASSEMBLY LANGUAGE PROGRAMMING
80x86 Processor Architecture
Gursharan Singh Tatla Block Diagram of Intel 8086 Gursharan Singh Tatla 19-Apr-17.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Chapter 2 Software Tools and Assembly Language Syntax.
An Introduction to 8086 Microprocessor.
Chapter 3 Elements of Assembly Language. 3.1 Assembly Language Statements.
1 Fundamental of Computer Suthida Chaichomchuen : SCC
Debug and Assembler By, B.R.Chandavarkar Lect. COMP Department NITK, Surathkal.
Chapter 3 Examining Computer Memory and Executing Instructions.
Types of Registers (8086 Microprocessor Based)
Faculty of Engineering, Electrical Department,
Debuggers A program needed when writing any type of code Displays the contents of memory Lets you view registers and variables and see how they change.
UHD:CS2401: A. Berrached1 The Intel x86 Hardware Organization.
Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory.
1 เครื่องมือในการพัฒนาภาษา แอสเซมบลี้. 2 Tools Assembly language vs. machine code Edit and debugging tools Debug, program you can use to test and debug.
6-4 CPU-Registers, effective address General registers vs Segment registers Computer Studies (AL)
The Assemble, Unassemble commands of the debugger: U Command for converting machine code language source Equivalent machine code instructions Equivalent.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Microprocessor Fundamentals Week 2 Mount Druitt College of TAFE Dept. Electrical Engineering 2008.
Internal Programming Architecture or Model
Preliminary to Assembly Language Programming CE 140 A1/A2 28 June 2003.
Intel 8086 MICROPROCESSOR ARCHITECTURE
ΜComputer Structure μProcessor Memory Bus System I/O Ports.
Chapter 12 Processor Structure and Function. Central Processing Unit CPU architecture, Register organization, Instruction formats and addressing modes(Intel.
Assembly language programming
The Little man computer
COURSE OUTCOMES OF Microprocessor and programming
Format of Assembly language
An Introduction to 8086 Microprocessor.
Microprocessor and Assembly Language
Part of the Assembler Language Programmers Toolbox
Introduction to 8086 Microprocessor
8086 Microprocessor.
Instruction Execution Cycle
ICS312 SET 7 Flags.
ADDRESSING MODES.
Microprocessor and Assembly Language
Microprocessor and Assembly Language
ADDRESSING MODES.
Intel 8088 (8086) Microprocessor Structure
..
CS 301 Fall 2001 – Chapter 3 Slides by Prof. Hartman, following “IBM PC Assembly Language Programming” by Peter Abel 9/17/2018.
Basic of Computer Organization
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
Introduction to Assembly Language
Intel 8088 (8086) Microprocessor Structure
CS-401 Computer Architecture & Assembly Language Programming
DEBUG.
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
CS 301 Fall 2002 Computer Organization
University of Gujrat Department of Computer Science
The Microprocessor & Its Architecture
Symbolic Instruction and Addressing
CNET 315 Microprocessor & Assembly Language
Lecture 06 Programming language.
File Analysis with MicroSoft DEBUG
Microprocessor and Assembly Language
8051 ASSEMBLY LANGUAGE PROGRAMMING
Chapter 6 –Symbolic Instruction and Addressing
Intel 8086.
Computer Operation 6/22/2019.
Part I Data Representation and 8086 Microprocessors
Presentation transcript:

Assembly Language Programming Part 3 Windows Debugger Debug Subcommands Writing and Executing Assembly Code Using Debugger

a <Assemble> d <Dump> Assembles 8086/8087/8088 mnemonics directly into memory. Used without parameters, a starts assembling where it last stopped. Syntax Parameters Examples a [address] Address Specifies the location where you type assembly-language mnemonics. Use hexadecimal values for address and type each value without the trailing h character. - a CS:100 - a 100 d <Dump> Displays the contents of a range of memory addresses. Used without parameters, d displays the contents of 128 bytes, starting at the end of the address range specified in the previous d subcommand. d [range] range Specifies the starting and ending addresses, or the starting address and length, of the memory area whose contents you want to display. - d CS:100 10C - d DS:100 L12 - d 100 10C - d 100 L12

e <Enter> f <Fill> Enters data into memory at the address you specify. Syntax Parameters Examples e address [list] address Required. Specifies the first memory location where you want to enter data. list Specifies the data you want to enter into successive bytes of memory. - e DS:200 5 - e DS:200 5 6 7 - e DS:200 2,1,4,7 - e 100 “Ahmed” - e 102 ‘r’ f <Fill> Fills addresses in the specified memory area with values you specify. f range list range Required. Specifies the starting and ending addresses, or the starting address and length, of the memory area you want to fill. Required. Specifies the data you want to enter. - f DS:100 103 1 2 3 4 - f 100 L6 1 2 3 4 - f 100 110 66 - f 100 L100 “HI”

g [=address] [breakpoints] g <Go> Runs the program currently in memory. Used without parameters, g starts running at the current address in the CS:IP registers. Syntax Parameters Examples g [=address] [breakpoints] address Specifies the address in the program currently in memory where you want to begin running the program. breakpoints Specifies 1 to 10 temporary breakpoints that you can set as part of the g subcommand. - g = CS:100 10f h <Hexadecimal> Performs hexadecimal arithmetic on two parameters that you specify. h value1 value2 value1 Required. Represents any hexadecimal number in the range 0 through FFFFh. value2 Required. Represents a second hexadecimal number in the range 0 through FFFFh. - h 19f 10a

q <Quit> r <Register> Syntax Parameters Examples Stops the Debug.exe session, without saving the file currently being tested, and returns to the command prompt. Syntax Parameters Examples q - r <Register> Displays or alters the contents of one or more CPU registers. Used without parameters, the r command displays the contents of all registers and flags in the register storage area, the status of all flags, and the decoded form of the instruction at the current location. Syntax Parameters Examples r [Register] Register Specifies the name of the register containing the information you want to display. - r AX - r CS - r DS - r f Flag name Set Clear Overflow ov nv Direction dn (decrement) up (increment) Interrupt ei (enabled) di (disabled) Sign ng (negative) pl (positive) Zero zr nz Auxiliary Carry ac na Parity pe (even) po (odd) Carry cy nc

t <Trace> u <Unassemble> Syntax Parameters Examples Executes one instruction and displays the contents of all registers, the status of all flags, and the decoded form of the instruction that is executed. Used without parameters, t begins tracing at the address specified by your program's CS:IP registers. Syntax Parameters Examples t [=address] [number] address Specifies the address at which Debug.exe is to start tracing instructions. number Specifies the number of instructions to be traced. This value must be a hexadecimal number. The default value is 1. - t = CS:100 4 - t = 200 5 u <Unassemble> Disassembles bytes and displays their corresponding source statements, including addresses and byte values. The disassembled code looks like a listing for an assembled file. Used without parameters, u disassembles 20h bytes (the default number), beginning at the first address after the address displayed by the previous u subcommand. u [range] range Specifies the starting and ending addresses, or the starting address and length, of the code you want to disassemble. - u CS:100 CS:110 - u CS:200 20f - u 100 10a

Notes CS is the default segment for the following debug subcommands: a, g, l, t, u and w. DS is the default segment for all subcommands. All numeric values are in hexadecimal format. You must include a colon between the segment name and the offset value. Example: The following are valid addresses: CS:0100 04BA:0100

How to use Debug

Type cmd (command Line) How to use Debug Type cmd (command Line)

How to use Debug This Local path changes from one computer to another

How to use Debug Write debug then hit enter This prompt indicates that debug is ready to accept commands, always remember that no assembly instructions are accepted when this prompt is shown up

How to use Debug Debug command a <assemble> followed by offset 100 (CS:0100) 0100 is the chosen offset number (specified by the programmer as part of a command), it indicates where your assembly instructions resides within the code segment in main memory 0AE2 is the Code Segment Number which is stored in register CS

How to use Debug Simple program that uses the instruction MOV to set register AL to 1 and Register AH to 2 Notice that, to exit instruction entering mode don’t type any thing and hit enter, you should see the dash prompt again which indicates that you can type debug instructions

How to use Debug To run your program you should use g <go> command, without it, your code will remain in memory, but nothing would actually happen (Register AL and AH would keep their old values). After executing your program, a list of registers and the values they are holding are displayed. Our program only deals with two registers AL and AH. AL and AH together forms the register AX. From the register list AX = 0201 (the first two bytes represents AH and the second two bytes represents AL).

How to use Debug Segment Registers DS <Data Segment>, ES <Extra Segment>, SS<Stack Segment>, and CS <Code Segment> are all set to one segment 0AE2 (normally they point to different segments but for simplicity debug use one segment for all of them) which means that you should be careful not to overlap your code with any existing data that is present in that segment.

How to use Debug IP <Instruction Pointer> a special purpose register that holds part of the logical address (offset) of the instruction to be executed (the full logical address is IP:CS).

How to use Debug These are some of the individual bit values that resides within the FLAGS register. They reflect some event that my occur while the execution of your program like arithmetic overflow and division by zero

How to use Debug These are some of the individual bit values that resides within the FLAGS register. They reflect some event that my occur while the execution of your program like arithmetic overflow and division by zero

How to use Debug Debug command u <unassemble>, which displays the machine code (in hexadecimal) corresponding to the assembly instructions in the memory range you specify. B001 is the machine code (in hex) corresponding to the assembly instruction mov al,01. In the same way B402 corresponds to mov ah,2

How to use Debug mov al,2 is typed instead of mov ah,2

How to use Debug To correct this line after it is already been written to memory, simply type nothing and hit enter. Now next to the dash prompt type a 102 (CS:0102 is the address of the instruction to be replaced ). Now you can run your program and every thing will work fine.

How to use Debug Debug command r <register> display a list of known registers and their current values. Default value for IP <Instruction Pointer> is 0100. All offsets from 0000 to 00FF are reserved by the operating system. When command r is followed by register e.g. r AX the value within this specific register is displayed then a colon “:”prompt is displayed which allow you to change the value within the register, if left blank no change is applied to the register

How to use Debug 8-bit registers are not accessed via debug command r. You must use assembly instructions in order to change the value within them

How to use Debug Letters String Numbers (in hex) Debug command e <enter> which is used to enter data into specific memory address (in this example DS:0200)

How to use Debug String (hex ASCII code) Since numbers 1,2,A, and E are not representing ASCII code of a character, a dot is displayed. Letters (hex ASCII code) Numbers (in hex) Debug command d <dump> which is used to dump the content of specific memory address range (in this example DS:0200  DS:020a)

How to use Debug Debug command f <fill> which is used to enter a pattern of data into specific range of memory address (e.g. DS:0100  DS:0104 and the pattern is “1,2”)