Segment Definition The CPU has several segment registers:

Slides:



Advertisements
Similar presentations
Programming 8086 – Part IV Stacks, Macros
Advertisements

10-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL Subroutine and Interrupt.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#3) By Dr. Syed Noman.
Lect 3: Instruction Set and Addressing Modes. 386 Instruction Set (3.4) –Basic Instruction Set : 8086/8088 instruction set –Extended Instruction Set :
8086 Assembly Language Programming I
1 Lecture 5: Procedures Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
Chapter 12: High-Level Language Interface. Chapter Overview Introduction Inline Assembly Code C calls assembly procedures Assembly calls C procedures.
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.
Microprocessor Systems Design I
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set.
ICS312 Set 4 Program Structure. Outline for a SMALL Model Program Note the quiz at the next lecture will be to reproduce this slide.MODEL SMALL.586 ;
Computer System A computers system has many distinct parts:  Microprocessor  Memory system  I/O system  Buses The way in which these parts are interconnected.
Introduction to Subroutines. All the combinations in which a subroutine can be written 1. The subroutine may be: a. Internal or b. External 2. The type.
Chapter 3 Elements of Assembly Language. 3.1 Assembly Language Statements.
Today’s topics Parameter passing on the system stack Parameter passing on the system stack Register indirect and base-indexed addressing modes Register.
Low Level Programming Lecturer: Duncan Smeed Overview of IA-32 Part 1.
Faculty of Engineering, Electrical Department,
Chapter Five–80x86 Assembly program development Principles of Microcomputers 2015年11月15日 2015年11月15日 2015年11月15日 2015年11月15日 2015年11月15日 2015年11月15日 1.
Microprocessors The ia32 User Instruction Set Jan 31st, 2002.
26-Nov-15 (1) CSC Computer Organization Lecture 6: Pentium IA-32.
Microprocessors used in Personal Computers. The Memory Map of a Personal Computers Transient Program Area (TPA): Holds the operating system (interrupt.
Chapter 2 The Microprocessor Architecture Microprocessors prepared by Dr. Mohamed A. Shohla.
MOV Instruction MOV destination,source  MOV AX,BX  MOV SUM,EAX  MOV EDX,ARRAY[EBX][ESI]  MOV CL,5  MOV DL,[BX]
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Addressing Modes Dr. Hadi Hassan.  Two Basic Questions  Where are the operands?  How memory addresses are computed?  Intel IA-32 supports 3 fundamental.
Assembly Language Addressing Modes. Introduction CISC processors usually supports more addressing modes than RISC processors. –RISC processors use the.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
EEL 4709C Prof. Watson Herman Group 4 Ali Alshamma, Derek Montgomery, David Ortiz 11/11/2008.
Assembly language programming
Assembly language.
Instruction set Architecture
Format of Assembly language
Addressing Modes in Microprocessors
Assembly Lab 3.
Microprocessor Systems Design I
Introduction to 8086 Microprocessor
COURSE OUTCOMES OF MICROPROCESSOR AND PROGRAMMING
Instruksi Set Prosesor 8088
ADDRESSING MODES.
Microprocessor and Assembly Language
Microprocessor Systems Design I
Microprocessor and Assembly Language
Microprocessor and Assembly Language
Assembly IA-32.
Microcomputer Programming
ADDRESSING MODES.
University of Gujrat Department of Computer Science
Chapter 3 Addressing Modes
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Computer Organization and Assembly Language (COAL)
Microprocessor and Assembly Language
Assembler Design Options
Data Addressing Modes • MOV AX,BX; This instruction transfers the word contents of the source-register(BX) into the destination register(AX). • The source.
Programming 8086 – Part IV Stacks, Macros
8086 Registers Module M14.2 Sections 9.2, 10.1.
Stack Frames and Advanced Procedures
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures
Chapter 3: Addressing Modes
EECE.3170 Microprocessor Systems Design I
Chapter 4 –Requirements for coding in Assembly Language
CNET 315 Microprocessor & Assembly Language
EECE.3170 Microprocessor Systems Design I
Under Address Modes Source: under
Assembler Directives end label end of program, label is entry point
Instruction Set Summary
Computer Organization and Assembly Language
Introduction to 8086 Assembly Language
Computer Architecture and System Programming Laboratory
Presentation transcript:

Segment Definition The CPU has several segment registers: CS (code segment). SS (stack segment). DS (data segment). ES (extra segment). FS, GS (supplemental segments available on 386s, 486s and Pentiums. Every instruction and directive must correspond to a segment. Normally a program consists of three segments: the stack, the data, and the code segments.

Segment Definition Model definition. .MODEL SMALL .MODEL MEDIUM Most widely used memory model. The code must fit in 64k. The data must fit in 64k. .MODEL MEDIUM The code can exceed 64k. .MODEL COMPACT The data can exceed 64k. MEDIUM and COMPACT are opposites.

Segment Definition .MODEL LARGE .MODEL HUGE .MODEL TINY Both code and data can exceed 64k. No single set of data can exceed 64k. .MODEL HUGE A single set of data can exceed 64k. .MODEL TINY Used with COM files. Both code and data must fir in a single 64k segment.

Segment Definition Segment definition formats: Simplified segment definition. Full segment definition. The Simplified segment definition uses the following directives to define the segments: .STACK .DATA .CODE These directives mark the beginning of the segments they represent.

Segment Definition The full segment definition uses the following directives to define the segments: Label SEGMENT [options] ;Statements belonging to the segment. Label ENDS The label must follow naming conventions previously discussed.

Segment Definition

Addressing Modes These are the different ways in which data may be accessed by the microprocessor. Immediate. Register. Memory. Direct. Register indirect. Register relative. Based indexed. Relative based indexed.

Immediate Directly accessible to the EU. The address is part of the instruction. Useful in initializations. MOV EAX,1111000B MOV CL, 0F1H

Register Directly accessible to the EU. Most compact and fastest executing instructions. Operands are encoded in the instruction. MOV EBX,EDX MOV AL,CL

Memory When reading or writing to memory the execution unit passes an offset value, the effective address, to the bus interface unit which then computes the physical address. Memory. Direct. Register indirect. Register relative. Based indexed. Relative based indexed.

Direct Simplest memory addressing mode. Access to simple variables. MOV EAX,DS:SUM MOV CL,DS:COUNT+5 MOV DS:[500H],EDX

Register Indirect MOV EAX, DS:[EBX] MOV DS:[EDI],EDX

Register Relative Access to one dimensional arrays. MOV EAX,DS:ARRAY[EBX] MOV DS:MESSAGE[EDI], DL

Relative Based Indexed Used to access two dimensional arrays or arrays contained in structures. MOV DS:ARRAY[EBX][EDI],EAX

Accessing Arrays One dimensional arrays. Two dimensional arrays. MOV DS:ARRAY[ESI*SF],EDX SF = Scaling factor for data size. Two dimensional arrays. MOV DS:ARRAY[EBX*SF*SR][ESI*SF],EDX SR = Size of row.

Accessing Arrays

Alignment It is best to align words with even numbered addresses, and double words to addresses divisible by four, but this is not necessary. The alignment allows for more efficient memory access, but it is less flexible.

Immediate - Memory When reading or writing to memory using immediate addressing mode, the programmer must specify the data size otherwise the assembler will default to the largest possible data size that processor handles. Use the following directives: Byte ptr. Word ptr. Dword ptr. MOV DS:BYTE PTR VAR,2H

Procedures Also known as subroutines, these sets of instructions usually perform a single task. They are reusable code, that can be executed as often as needed by calling it. Procedures save memory, but the calling of a procedure takes a small amount of time.

Procedures Format Global procedures are defined as FAR. Name PROC [NEAR or FAR] Subroutine code RET ENDP Global procedures are defined as FAR. Local procedures are defined as NEAR.

Procedures CALL destination RET Calls a subroutine at location destination. Different addressing modes may be used for destination. CALL DELAY CALL EBX CALL ARRAY[BX] RET Returns execution of program to location stored in stack. NEAR or FAR is dependent on procedure definition.