Chapter 3 Examining Computer Memory and Executing Instructions.

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

DOS and BIOS Interrupts DOS and BIOS interrupts are used to perform some very useful functions, such as displaying data to the monitor, reading data from.
COMP 2003: Assembly Language and Digital Logic
More about procedures and Video Processing. Lesson plan Review existing concepts More about procedures and boolean expression Video processing.
Video systems (continue). Practice Modify the program to get a string from a keyboard to display the input string on the middle of the screen with reverse.
Flow Diagram: Push flags, CS, IP Pop IP,CS,flags Push AX,BX,CX,DX,ES,DS,SI,DI,BP POP BP,DI,SI,DS,ES,DX,CX,BX,AX.
Azir ALIU 1 What is an assembly language?. Azir ALIU 2 Inside the CPU.
Handout 2 Digital System Engineering (EE-390)
Stack Memory H H FFFFF H FFFFE H SS 0105 SP 0008 TOS BOS BOS = FFFF = 1104F H H 1104F H.
CHAPTER 5 INTRODUCTION TO ASSEMBLY LANGUAGE
CS2422 Assembly Language & System Programming November 2, 2006.
Chapter 7 Programming with DOS and BIOS Function Calls Objectives: The use of DOS and BIOS function call How to read the PC’s keyboard How to send text.
Kip Irvine: Assembly Language for Intel-Based Computers
Introduction to Computer Engineering by Richard E. Haskell Interrupts Module M17.3 Sections 11.3, 14.1.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#8) By Dr. Syed Noman.
Micro-Computer Applications: Procedures & Interrupts Dr. Eng. Amr T. Abdel-Hamid ELECT 707 Fall 2011.
Chapter 1: Basic Concepts
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.
1 Screen and Keyboard Operations Suthida Chaichomchuen
Types of Registers (8086 Microprocessor Based)
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.
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.
Video systems. Lesson plan Review the code for the previous exercise Video systems Review for midterm exam.
8086 Microprocessor Interrupts By: Vijay Kumar. K Reference From Slide Share.
10H Interrupt. Option 0H – Sets video mode. Registers used: – AH = 0H – AL = Video Mode. 3H - CGA Color text of 80X25 7H - Monochrome text of 80X25 Ex:
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 Tehran 1 Microprocessor System Design Omid Fatemi Machine Language Programming
1 เครื่องมือในการพัฒนาภาษา แอสเซมบลี้. 2 Tools Assembly language vs. machine code Edit and debugging tools Debug, program you can use to test and debug.
3.4 Addressing modes Specify the operand to be used. To generate an address, a segment register is used also. Immediate addressing: the operand is a number.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Internal Programming Architecture or Model
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.
File Operations. FILE PROCESSING For the purposes of the following discussion, reading means copying all or part of an existing file into memory Writing.
Intel MP Organization. Registers - storage locations found inside the processor for temporary storage of data 1- Data Registers (16-bit) AX, BX, CX, DX.
ΜComputer Structure μProcessor Memory Bus System I/O Ports.
Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts.
1 Chapter 1: Introduction Appendix A: Binary and Hexadecimal Tutorial Assembly Language for Intel-Based Computers, 3rd edition Kip R. Irvine.
Instruction set Architecture
Assembly Language Programming Part 3
8086 Microprocessor.
Computer Organization & Assembly Language Chapter 3
Instruction Execution Cycle
ADDRESSING MODES.
16.317: Microprocessor System Design I
Assembly IA-32.
Assembly Language Programming Part 2
ADDRESSING MODES.
Intel 8088 (8086) Microprocessor Structure
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
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.
Intel 8088 (8086) Microprocessor Structure
8086 Registers Module M14.2 Sections 9.2, 10.1.
CS-401 Computer Architecture & Assembly Language Programming
DEBUG.
Interrupt Mechanism Interrupt Compared With Procedures Call MyProc
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
The Microprocessor & Its Architecture
Symbolic Instruction and Addressing
CNET 315 Microprocessor & Assembly Language
Unit:08 Software Interrupts
Computer Architecture CST 250
Microprocessor and Assembly Language
Chapter 6 –Symbolic Instruction and Addressing
Presentation transcript:

Chapter 3 Examining Computer Memory and Executing Instructions

DEBUG Commands: A Assemble symbolic instruction into machine code D Display the contents of an area of memory in hex form E Enter data into memory, beginning at a specific location G Run the executable program in memory ( G means “go”) H Perform hexadecimal arithmetic N Name a program P Proceed, or execute a set of related instructions Q Quit the DEBUG session R Display the contents of one or more registers in hex format T Trace the execution of one instruction U Un-assemble machine code into symbolic code

D DS:200 1380:0200 00 00 00 00 00 00 00 00 – 00 00 00 00 00 00 00 00 ……………. 1380:0210 00 00 00 00 00 00 00 00 – 00 00 00 00 00 00 00 00 ……………. 1380:0220 00 00 00 00 00 00 00 00 – 00 00 00 00 00 00 00 00 ……………. 1380:0230 00 00 00 00 00 00 00 00 – 00 00 00 00 00 00 00 00 ……………. 1380:0240 00 00 00 00 00 00 00 00 – 00 00 00 00 00 00 00 00 ……………. 1380:0250 00 00 00 00 00 00 00 00 – 00 00 00 00 00 00 00 00 ……………. 1380:0260 00 00 00 00 00 00 00 00 – 00 00 00 00 00 00 00 00 ……………. 1380:0270 00 00 00 00 00 00 00 00 – 00 00 00 00 00 00 00 00 ……………. ASCII representation Hex representation of the displayed area

Viewing Memory Locations Exercise 1: Checking the serial and parallel ports at memory location 40:00 D 40:00 < Enter> 0040:0000 F8 03 F8 02 E8 03 E8 02-BC 03 78 03 78 02 C0 9F ……….x.x… ... Serial ports COM1,…,COM4 Parallel ports LPT1,…,LPT4 COM1 at 03F8 COM2 at 02F8

Checking System Equipment at Locations 410H-411H D 40:10 <Enter> 0040:0010 23 44… Binary value: 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 1 Bit position: 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Bits Device 15, 14 Number of parallel printer ports attached = 1 (binary 01) 11-9 Number of serial ports attached = 2 7,6 Number of diskette devices = 1 (00=1, 01=2, 10=3, 11=4) 5,4 Initial video mode = 10 (01=40x25 color,10=80x25 color, 11=80x25 monochrome) 1 1 = numeric coprocessor is present 0 1=diskette drive is present Others not used

Checking the Keyboard Shift Status at Location 417H D 40:17 <Enter> 0040:0017 00 00… Checking the video status at location 449H D 40:49 <Enter> The first byte: current video mode (03 for color) The second byte: number of columns on the screen (50H = 80) you can find number of rows at location 40:84H

Exercise 2: Examining ROM BIOS Checking copyright notice and serial number at location FE000H (7-digit serial number follows the copyright notice) D FE00:0 <Enter> Checking ROM BIOS date at location FFFF5H recorded as mm/dd/yy D FFFF:5 <Enter>

Machine Language Example 1: Using Immediate Data Machine instruction symbolic code explanation B82301 MOV AX,0123 move value 0123H to AX 052500 ADD AX,0025 add value 0025H to AX 8BD8 MOV BX,AX move contents of AX to BX 03D8 ADD BX,AX add contents of AX to BX 8BCB MOV CX,BX move contents of BX to CX 2BC8 SUB CX,AX subtract content of AX from CX 2BC0 SUB AX,AX subtract AX from AX (clear AX) EBEE JMP 100 go back to the start

Keying in Program Instructions: E CS:100 B8 23 01 05 25 00 <enter> E CS:106 8B D8 03 D8 8B CB <enter> E CS:10C 2B C8 2B C0 EB EE <enter> Executing Program Instructions: -R: view the initial contents of the registers and flags AX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=21C1 ES=21C1 SS=21C1 CS=21C1 IP=0100 NV UP EI PL NZ NA PO NC 21C1:0100 B82301 MOV AX,0123 -T AX=0123 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=21C1 ES=21C1 SS=21C1 CS=21C1 IP=0103 NV UP EI PL NZ NA PO NC 21C1:0103 052500 ADD AX,0025

-T AX=0148 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=21C1 ES=21C1 SS=21C1 CS=21C1 IP=0106 NV UP EI PL NZ NA PE NC 21C1:0106 8BD8 MOV BX,AX AX=0148 BX=0148 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=21C1 ES=21C1 SS=21C1 CS=21C1 IP=0108 NV UP EI PL NZ NA PE NC 21C1:0108 03D8 ADD BX,AX AX=0148 BX=0290 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=21C1 ES=21C1 SS=21C1 CS=21C1 IP=010A NV UP EI PL NZ AC PE NC 21C1:010A 8BCB MOV CX,BX

-T AX=0148 BX=0290 CX=0290 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=21C1 ES=21C1 SS=21C1 CS=21C1 IP=010C NV UP EI PL NZ AC PE NC 21C1:010C 2BC8 SUB CX,AX AX=0148 BX=0290 CX=0148 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=21C1 ES=21C1 SS=21C1 CS=21C1 IP=010E NV UP EI PL NZ AC PE NC 21C1:010E 2BC0 SUB AX,AX AX=0000 BX=0290 CX=0148 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=21C1 ES=21C1 SS=21C1 CS=21C1 IP=0110 NV UP EI PL ZR NA PE NC 21C1:0110 EBEE JMP 0100 Displaying memory contents: view the machine language program in the code segment D CS:100

Machine Language Example 2: Using Defined Data DS offset Hex contents 0200H 2301H 0202H 2500H 0204H 0000H 0206H 2A2A2AH Instruction Explanation A10002 move the word at DS:0200H into AX 03060202 add the contents of the word at DS:0202H into AX A30402 move the contents of AX to the word at DS:0204H EBF4 jump to the start of program

Keying in Program Instructions and Data E CS:100 A1 00 02 03 06 02 02 <enter> E CS:107 A3 04 02 EB F4 <enter> E DS:0200 23 01 25 00 00 00 <enter> E DS:0206 2A 2A 2A <enter> ASCII code for * Executing the Program Instructions -R: view the initial contents of the registers and flags AX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=21C1 ES=21C1 SS=21C1 CS=21C1 IP=0100 NV UP EI PL NZ NA PO NC 21C1:0100 A10002 MOV AX,[0200] DS:0200=0123

-T AX=0123 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=21C1 ES=21C1 SS=21C1 CS=21C1 IP=0103 NV UP EI PL NZ NA PO NC 21C1:0103 03060202 ADD AX,[0202] DS:0202=0025 AX=0148 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=21C1 ES=21C1 SS=21C1 CS=21C1 IP=0107 NV UP EI PL NZ NA PE NC 21C1:0107 A30402 MOV [0204],AX DS:0204=0000 DS=21C1 ES=21C1 SS=21C1 CS=21C1 IP=010A NV UP EI PL NZ NA PE NC 21C1:010A EBF4 JMP 0100 D DS:0200, 0208 21C1:0200 23 01 25 00 48 01 2A 2A - 2A

Reset offset value in the IP register 1. Key in R IP to display the contents of IP, and 2. Type in the value 100 ( or address of another instruction), <enter>

An Assembly Language Program A 100 <enter> xxxx:0100 MOV CL,42 xxxx:0102 MOV DL,2A xxxx:0104 ADD CL,DL xxxx:0106 JMP 100 xxxx:0108 <enter> U 100, 107 <enter> xxxx:0100 B142 MOV CL,42 xxxx:0102 B22A MOV DL,2A xxxx:0104 00D1 ADD CL,DL xxxx:0106 EBF8 JMP 100 xxxx:0108 Type R to display registers , and T to trace instructions. When you get to JMP, you will find IP=106H, CL=6CH

Using the INT Instructions 1. Getting the Current Date, INT 21H, function code 2AH A 100<enter> MOV AH, 2A <enter> INT 21 <enter> JMP 100 <enter>, <enter> Type R to display the registers T to execute the MOV P to proceed(進行) directly through the interrupt routine The operation stop at the JMP The registers contain this information in hex format: AL: Day of the week, where 0 = Sunday CX: Year ( for example, 07D4H = 2004) DH: Month (01H through 0CH) DL: Day of the month (01H through 1FH)

2. Getting the Current time: INT 21H, function code 2CH First use R IP to reset IP to 100 and then key in A 100, and MOV AH, 2C ,<enter> INT 21 <enter> JMP 100 <enter>, <enter> The operation delivers hours to CH (00 = midnight) minutes to CL, seconds to DH hundredths of second to DL

3. Determining Installed Equipment: INT 11H Type in A 100, then INT 11 JMP 100<enter>, <enter> Press R to display the registers and T to trace repeatedly to see the BIOS instruction execute. JMP EE53 ; PUSH DS ;save DS address in stack MOV AX, 0040 ;get segment address MOV DS, AX ;move it to DS MOV AX,[0010] ;get data from 40:10 into AX POP DS ;restore address in DS IRET ;return from interrupt The last T command exits from BIOS and returns to DEBUG. AX now contains the record of installed equipment.

4. Using INT for Displaying: INT 21H, function code 09H Type A 100, then 100 MOV AH,09 102 MOV DX,109 105 INT 21 107 JMP 100 109 DB ‘your name’, ‘$’ <enter>, <enter> Define byte dollar sign tell INT 21 to end the display.

5. Using INT for Keyboard Input: INT 16H, function code 10H Type A 100, then 100 MOV AH, 10 102 INT 16 104 JMP 100 <enter>, <enter> When you type in P for INT 16H, the system waits for you to press a key. If you press the number 1, you’ll see the operation delivers 31H (hex for ASCII 1) to AL

Using the PTR Operator to indicate number of bytes 顯示 100 MOV AX,[11A] ;move contents at memory location 11AH-11BH to AX 103 ADD AX,[11C] ;add contents of memory location 11CH-11DH to AX 107 ADD AX,25 ;add immediate value 25H to AX 10A MOV [11E],AX ;move contents of AX to memory locations 11EH-11FH 10D MOV WORD PTR [120], 25 ;move a word of value 25H to 120H-121H 113 MOV BYTE PTR [122], 30 ;move a byte of value 30H to location 122H 118 JMP 100 11A DB 14 23 ;define values 14H and 23H. DB: define byte 11C DB 05 00 11E DB 00 00 120 DB 00 00 00 D 110 to view the changed contents of AX (233E) location 11EH-11FH (3E23) 120H-121H (2500) 122H (30)

Exercises: 3.4 (a) Use debug to enter the following: E CS:100 B8 45 01 05 25 00 (b) Use E command to change 45 to 54 3.10 Use debug’s A command (A 100) to enter the following instructions: MOV DX, 2E ADD DX, 1F SHL DX, 1 SUB DX, BA JMP 100 Un-assemble the instructions and trace their execution. Check the value in DX. 3.12 Use debug to create and run a program to display the sentence “Coffee Break.” Start with A 100 for entering the instructions and use A 120 for the sentence ( remember the $ delimiter)