Assembly Language Advantages 1. It reveals the secret of your computer’s hardware and software. 2. Speed. 3. Some special applications and occasions. Disadvantages.

Slides:



Advertisements
Similar presentations
Chapter 2 (cont.) An Introduction to the 80x86 Microprocessor Family Objectives: The different addressing modes and instruction types available The usefulness.
Advertisements

CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#3) By Dr. Syed Noman.
COS318 Lec 21 Operating System Structures Vivek Pai Princeton University.
Memory Address Segment-offset address Base location (segment) + logical location (offset) Example: For 32-bits segment-offset address, 08F1:0100 represents.
Lect 3: Instruction Set and Addressing Modes. 386 Instruction Set (3.4) –Basic Instruction Set : 8086/8088 instruction set –Extended Instruction Set :
Lab6 – Debug Assembly Language Lab
COS318 Lec 21 Operating System Structures Vivek Pai Princeton University.
1 Hardware and Software Architecture Chapter 2 n The Intel Processor Architecture n History of PC Memory Usage (Real Mode)
Outline Learning Assembly by an Example.  Program Formats  Some Simple Instructions  Assemble and Execute Learning Another Example  Data Definition.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 2 The Microprocessor and its Architecture.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
Assembly Language Advantages 1. It reveals the secret of your computer’s hardware and software. 2. Speed. 3. Some special applications and occasions. Disadvantages.
CS2422 Assembly Language & System Programming November 2, 2006.
Kip Irvine: Assembly Language for Intel-Based Computers Overview Stack Operations (PUSH and POP) Procedures Procedure Parameters Software Interrupts MS-DOS.
Assembly Language Basic Concepts IA-32 Processor Architecture.
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.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 2 The Microprocessor and its Architecture.
Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set.
An Introduction to 8086 Microprocessor.
The Pentium Processor.
The Pentium Processor Chapter 3 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
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.
BIOS and DOS Programming in DOS INT 10 and 21H. Interrupts There are some extremely useful subroutines within BIOS or DOS that are available to the user.
1 Fundamental of Computer Suthida Chaichomchuen : SCC
Chapter 3 Examining Computer Memory and Executing Instructions.
INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts.
CET 3510 Microcomputer Systems Tech. Lecture 2 Professor: Dr. José M. Reyes Álamo.
ECE291 Computer Engineering II Lecture 3 Josh Potts University of Illinois at Urbana- Champaign.
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.
(-133)*33+44* *33+44*14 Input device memory calculator Output device controller Control bus data bus memory.
Assembly Programming Notes for Practical 1
Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory.
Computers organization & Assembly Language Chapter 1 THE 80x86 MICROPROCESSOR.
ECE291 Computer Engineering II Lecture 3 Dr. Zbigniew Kalbarczyk University of Illinois at Urbana- Champaign.
Microprocessors used in Personal Computers. The Memory Map of a Personal Computers Transient Program Area (TPA): Holds the operating system (interrupt.
University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Internal Programming Architecture or Model
Preliminary to Assembly Language Programming CE 140 A1/A2 28 June 2003.
1 x86 Programming Model Microprocessor Computer Architectures Lab Components of any Computer System Control – logic that controls fetching/execution of.
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.
BITS Pilani Pilani Campus Pawan Sharma Lecture / ES C263 INSTR/CS/EEE F241 Microprocessor Programming and Interfacing.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts.
Homework Reading Lab with your assigned section starts next week
Assembly language.
Format of Assembly language
History – 2 Intel 8086.
Assembly Language Programming Part 3
8086 Microprocessor.
Computer Organization & Assembly Language Chapter 3
Basic Microprocessor Architecture
Assembly IA-32.
Homework Reading Continue work on mp1
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
Introduction to 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
CS 301 Fall 2002 Computer Organization
The Microprocessor & Its Architecture
Symbolic Instruction and Addressing
Computer Architecture CST 250
Unit-I 80386DX Architecture
Chapter 6 –Symbolic Instruction and Addressing
Intel 8086.
Presentation transcript:

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.

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

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

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

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

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 ? ? ?

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 mov ds,ax mov ah,9 mov dx,offset message int 21h mov ax,4C00h int 21h main endp end main

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 * * *

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.

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

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.

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).

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

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]

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

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 E BC 03

The meaning of the line F8 03 F8 02 E8 03 E 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

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

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: F F /30/98 The 4/30/98 would be the date of your computer BIOS.

Check Your Computer’s Video -d c000:0040

Debug Mov si, 0200 Mov ax, [si] Mov [0270], ax Mov ax, 4c00 Int 21 -T

Assembling, linking, And Debugging Debug and Assembler Source File Listing File Object File Link Library Map File Executable Program Output Assembler Linker Loader

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.

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 message main œ ÌRÌvTŽŠ ÁP ^

Target Processor Directives , When using.386, the program can only run on 386 and above processors.

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

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++.