Microprocessor and Assembly Language

Slides:



Advertisements
Similar presentations
Lecture 13: 10/8/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Advertisements

There are two types of addressing schemes:
Assembly Language Lecture BY SHERY KHAN
CS2422 Assembly Language & System Programming September 19, 2006.
Lab6 – Debug Assembly Language Lab
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
1/2002JNM1 Positional Notation (Hex Digits). 1/2002JNM2 Problem The 8086 has a 20-bit address bus. Therefore, it can access 1,048,576 bytes of memory.
Debug and Assembler By, B.R.Chandavarkar Lect. COMP Department NITK, Surathkal.
INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
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.
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 4 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
UHD:CS2401: A. Berrached1 The Intel x86 Hardware Organization.
INTRODUCTION TO MICROPROCESSOR Engr. Ammar Anwar Khan.
University of Tehran 1 Microprocessor System Design Omid Fatemi Machine Language Programming
University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Preliminary to Assembly Language Programming CE 140 A1/A2 28 June 2003.
Computer and Information Sciences College / Computer Science Department CS 206 D Computer Organization and Assembly Language.
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
1 Chapter 1: Introduction Appendix A: Binary and Hexadecimal Tutorial Assembly Language for Intel-Based Computers, 3rd edition Kip R. Irvine.
Computer Architecture & Operations I
Computer Architecture & Operations I
Assembly language.
Instruction set Architecture
Control Unit Lecture 6.
Assembly Language Programming Part 3
Computer Organization & Assembly Language Chapter 3
16.317: Microprocessor System Design I
Microprocessor and Assembly Language
Microprocessor Systems Design I
Chapter 4 Addressing modes
Microprocessor and Assembly Language
Assembly Language Programming Part 2
University of Gujrat Department of Computer Science
Microprocessor and Assembly Language
Microprocessor Lab CSL1543 0:0:2
CS 301 Fall 2001 – Chapter 3 Slides by Prof. Hartman, following “IBM PC Assembly Language Programming” by Peter Abel 9/17/2018.
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Microprocessor and Assembly Language
Arithmetic Instructions
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
and Executing Programs
Introduction to Assembly Language
Data Addressing Modes • MOV AX,BX; This instruction transfers the word contents of the source-register(BX) into the destination register(AX). • The source.
Data Transfers, Addressing, and Arithmetic
8086 MICROPROCESSOR PROGRAMMING – INTEGER INSTRUCTIONS AND COMPUTATIONS Amar Saraswat.
Microprocessor and Assembly Language
8086 Registers Module M14.2 Sections 9.2, 10.1.
CS-401 Computer Architecture & Assembly Language Programming
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
(Array and Addressing Modes)
Shift & Rotate Instructions)
Symbolic Instruction and Addressing
(Array and Addressing Modes)
CNET 315 Microprocessor & Assembly Language
Lecture 06 Programming language.
University of Gujrat Department of Computer Science
University of Gujrat Department of Computer Science
8051 ASSEMBLY LANGUAGE PROGRAMMING
Chapter 6 –Symbolic Instruction and Addressing
Microprocessor and Assembly Language
Chapter 8: Instruction Set 8086 CPU Architecture
Microprocessor and Assembly Language
Part I Data Representation and 8086 Microprocessors
(The Stack and Procedures)
(Array and Addressing Modes)
Presentation transcript:

Microprocessor and Assembly Language Lecture-4-Introduction to Assembly Language Programming with Debug Utility Muhammad Hafeez Department of Computer Science GC University Lahore

Today’s Agenda Introduction to Assembly Language Programming Debug Utility

.COM and .EXE File DOS allows two types of executable in its command shell .COM --- Max. Program Size 64K Directly converted into binary If a .com file takes 10 bytes, actual size of file will be 10 bytes Debug deals with .COM Same Value in SS, DS, ES and SS .EXE ---- Max. Program Size all available memory Minimum Size 640 Bytes

.COM and .EXE File

Assembly Language Instructions Data Movement Instructions Arithmetic Instructions Logic Instructions Control Instructions

Data Movement Instructions MOV Instruction XCHG Instruction

MOV Instruction Move Byte/ Word to Syntax is, Register-to-Register Register-to-Memory Memory-to-Register Immediate [common error is trying to move larger constants than destination size] Syntax is, Size of the operands must be same MOV Destination, Source Source is from where we pick data Destination is where we put data CS and IP must never be destination

Legal Combinations of MOV Instruction Destination Source General Register Segment Register Memory Location Constant Yes No

Legal Combinations of XCHG Instruction Destination Source General Register Memory Location Yes No

Arithmetic Instructions ADD Instruction SUB Instruction INC Instruction DEC Instruction

ADD & SUB Instructions ADD Syntax SUB Syntax ADD Source, Destination SUB Source, Destination

Legal Combinations of ADD & SUB Instructions Destination Source General Register Memory Location Yes No Constant

INC & DEC Instructions INC Syntax DEC Syntax INC Destination DEC Destination INC add 1 to the destination DEC subtract 1 to the destination

NEG Instructions NEG instruction negate the contents of memory or Register Does this my taking 2’s complement of content NEG Syntax DEC Destination NOTE: In all the Instructions Size/ Type of Operands must be same, however, assembler accepts MOV al,’C’ and MOV ax,’C’

Examples: A = A -1 A = B A = B + 2*A B = B-1 Using Debug

Install DosBox DOSBox is an Emulator which emulate old 8086/88 and 80286/386 environment on your current i3/i5/i7 processor. Follow the steps given in online post ”Installing MASM on Windows 7”

Debug Utility A debugger displays the content of memory quickly and easily, showing registers and variables. You can step through a program one line at a time (called tracing). Some debugging functions are: Assemble short program View a program’s source code, along with its machine code View the CPU registers and flags Trace or execute a program, watching variables for changes Enter new values in memory Fill a block of memory load and write disk files

Debug Utility Debug assume all the numbers in HEX C:\Masm>Debug [Press Enter] R [to see the Registers] R Register name to change the content R AX A Start Address [Assemble the Code] A 0100 U Start Address End Address U Start Address L #of bytes U 0100 010D U 0100 LD

Debug Utility G [Run a program till breakpoint] G=start Address End Address G [press enter] G=0100 010D R [to see the Registers] T [Trace, to run a program step by step] T = Start Address # of instruction T [press Enter] T=0100 2 [Run Two instructions] T 3 [only number of instructions, assume IP=0100]

Debug Utility Common Errors with Register Usage MOV AH,FF3 MOV AX,12345 MOV DS,1240 MOV SI,DH MOV BX,AH MOV AL,CX [Errors]

Data Manipulation in Debug Utility F [fill the block of memory with data] F [start address] [end address] [data] F [start address] [L no of bytes] [data] F 0 10 FF F 0 LD EF F 0 20 20 41 [alternate pattern] D [Dump command, examine the content of memory] D [start address] [end address] D [start address] [L no. of bytes] Variation of D

Data Manipulation in Debug Utility D [dump will be shown from DS:0100 to 128 bytes] D offset [D will assume DS as segment] Fill and look up the Dump Enter Command and Use Dump to examine machine code E [Enter Data with E command] E [start address] data E Start Address E DS:0 41 42 43 44 E DS:0 ‘Adam Smith’ E CS:0100

Data Manipulation in Debug Utility Alter data using E E 106 [press enter] P [Procedure], used to execute procedure P [start address] [no. of instructions] M [start address], [end address] [dest. Address] C , Check block of memory for difference C [start address] [end address] [compare address]

Debug Utility Debug assume all the numbers in HEX C:\Masm>Debug [Press Enter] R [to see the Registers] R Register name to change the content R AX A Start Address [Assemble the Code] A 0100 U Start Address End Address U Start Address L #of bytes U 0100 010D U 0100 LD

Debug Utility D CS:0100 110 D 100 110 F 100 110 Either Enter program through E E100 E 101 to put another char to print Or Assemble with A G to run the program U 100 106 HEX numbers back to mnemonic codes See unassembled HEX numbers Stack first CS is loaded then IP is loaded

Debug Utility D CS:0100 110 D 100 110 F 100 110 Either Enter program through E E100 E 101 to put another char to print Or Assemble with A G to run the program U 100 106 HEX numbers back to mnemonic codes See unassembled HEX numbers Stack first CS is loaded then IP is loaded

Debug Utility R to manipulate Registers Rax to change AX register Stack first CS is loaded then IP is loaded

Debug Utility Save program on disk from debug utility Three step process -Nfilename.com Name of the File How many bytes the program has taken CX, BX register will be used to hold bytes to save CX lower order of this number, BX high order of this number Use only CX register to hold number of bytes, put no of bytes in CX -W

Debug Utility - Summary

Little Endian and Big Endian If low byte is stored at lower memory address called little endian Used in INTEL processors If low byte is stored at high memory address called big endian Used in Motorola processors

Questions ??????????????????????????