Lecture (03) x86 programming 2

Similar documents
Lecture (05) x86 programming 4

Introduction to Microcontrollers

Assembly Language. Lecture 2 x86 Processor Architecture

Assembly Language. Lecture 2 - x86 Processor Architecture. Ahmed Sallam

COMP2121: Microprocessors and Interfacing. Instruction Set Architecture (ISA)

Microprocessors and Microcontrollers. Assignment 1:

Lecture (02) The Microprocessor and Its Architecture By: Dr. Ahmed ElShafee

Assembly Language Programming Introduction

MICROCONTROLLERS 8051

Computer Hardware Requirements for ERTSs: Microprocessors & Microcontrollers

#include <stdio.h> #include <math.h> int shownum(int digits[], int digitcount);

Module 2: Introduction to AVR ATmega 32 Architecture

Practical Malware Analysis

Lecture (01) Introducing Embedded Systems and the Microcontrollers By: Dr. Ahmed ElShafee

The Instruction Set. Chapter 5

CN310 Microprocessor Systems Design

Introduction to general architectures of 8 and 16 bit micro-processor and micro-controllers

Hardware and Software Architecture. Chapter 2

Embedded Systems. PIC16F84A Internal Architecture. Eng. Anis Nazer First Semester

COMPUTER STRUCTURE AND ORGANIZATION

EC-333 Microprocessor and Interfacing Techniques

ARM Architecture and Assembly Programming Intro

CNIT 127: Exploit Development. Ch 1: Before you begin. Updated

Computer Organization and Microprocessors SYLLABUS CHAPTER - 1 : BASIC STRUCTURE OF COMPUTERS CHAPTER - 3 : THE MEMORY SYSTEM

AVR Microcontrollers Architecture

Micro computer Organization

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...

CPU. Fall 2003 CSE 207 Digital Design Project #4 R0 R1 R2 R3 R4 R5 R6 R7 PC STATUS IR. Control Logic RAM MAR MDR. Internal Processor Bus

COMP3221: Microprocessors and. and Embedded Systems. Instruction Set Architecture (ISA) What makes an ISA? #1: Memory Models. What makes an ISA?

Automation Engineers AB Pvt Ltd, NOIDA Job-Oriented Course on Embedded Microcontrollers & Related Software Stack

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

ELC4438: Embedded System Design Embedded Processor

Week 1. Introduction to Microcomputers and Microprocessors, Computer Codes, Programming, and Operating Systems

ELCT708 MicroLab Session #1 Introduction to Embedded Systems and Microcontrollers. Eng. Salma Hesham

The due date for submitting this assignment has passed. 1) Which of the following statements regarding a microcomputer, a

EXPERIMENT NO.1. A Microcontroller is a complete computer system built on a single chip.

Computer and Hardware Architecture I. Benny Thörnberg Associate Professor in Electronics

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language

DC57 COMPUTER ORGANIZATION JUNE 2013

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-11: 80x86 Architecture

EE 308: Microcontrollers

Segment 1A. Introduction to Microcomputer and Microprocessor

ELCT 912: Advanced Embedded Systems

MICROPROCESSOR TECHNOLOGY

3 Computer Architecture and Assembly Language

PART - B (Answer all five units, 5 X 10 = 50 Marks)

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

8051 microcontrollers

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

1 // Simplex.cpp : Defines the entry point for the console application. 2 // 3 4 #include "stdafx.h" 5 #include <fstream> 6 #include <iostream> 7

Introduction to Computers - Chapter 4

Computer Organization

Midrange 8b PIC Microcontrollers. ECE Senior Design 14 February 2017

Description of the Simulator

Universität Dortmund. ARM Architecture

UNIT 2 (ECS-10CS72) VTU Question paper solutions

EEM336 Microprocessors I. The Microprocessor and Its Architecture

Computer Systems Lecture 9

CSE A215 Assembly Language Programming for Engineers

COSC345 Software Engineering. Basic Computer Architecture and The Stack

Microprocessor Architecture Dr. Charles Kim Howard University

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

Moodle WILLINGDON COLLEGE SANGLI (B. SC.-II) Digital Electronics

INTRODUCTION OF MICROPROCESSOR& INTERFACING DEVICES Introduction to Microprocessor Evolutions of Microprocessor

ARM Cortex-M4 Programming Model

Chapter 1 : Introduction

ADVANCE MICROPROCESSOR & INTERFACING

Lecture Objectives. Introduction to Computing Chapter 0. Topics. Numbering Systems 04/09/2017

AVR MICROCONTROLLER ARCHITECTURTE

Computer Architecture Dr. Charles Kim Howard University

ET355 Microprocessors Thursday 6:00 pm 10:20 pm

Diploma in Embedded Systems

Chapter 2 Lecture 1 Computer Systems Organization

Faculty of Engineering Computer Engineering Department Islamic University of Gaza Assembly Language Lab # 2 Assembly Language Fundamentals

CC411: Introduction To Microprocessors

What Are The Main Differences Between Program Counter Pc And Instruction Register Ir

University of Alexandria Faculty of Engineering Division of Communications & Electronics

b. List different system buses of 8085 microprocessor and give function of each bus. (8) Answer:

What is Superscalar? CSCI 4717 Computer Architecture. Why the drive toward Superscalar? What is Superscalar? (continued) In class exercise

Programming I Assignment 04. Branching I. # Student ID Student Name Grade (10) -

Module 3 Instruction Set Architecture (ISA)

EC6504 MICROPROCESSOR AND MICROCONTROLLER

CPE/EE 421 Microcomputers

Computer Architecture

ARM ARCHITECTURE. Contents at a glance:

Robotic Systems ECE 401RB Fall 2006

MicroProcessor. MicroProcessor. MicroProcessor. MicroProcessor

acret Ameya Centre for Robotics & Embedded Technology Syllabus for Diploma in Embedded Systems (Total Eight Modules-4 Months -320 Hrs.

Real instruction set architectures. Part 2: a representative sample

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 2: IA-32 Processor Architecture Included elements of the IA-64 bit

DERTS Design Requirements (1): Microcontroller Architecture & Programming

Choosing a Micro for an Embedded System Application

SARDAR RAJA COLLEGES SARDAR RAJA COLLEGE OF ENGINEERING ALANGULAM

FIFTH SEMESTER B.TECH DEGREE EXAMINATION MODEL TEST QUESTION PAPER, NOVEMBER CS 305: Microprocessor and Microcontrollers PART A

Architectures & instruction sets R_B_T_C_. von Neumann architecture. Computer architecture taxonomy. Assembly language.

omputer Design Concept adao Nakamura

Computer Hardware Requirements for Real-Time Applications

CS 24: INTRODUCTION TO. Spring 2015 Lecture 2 COMPUTING SYSTEMS

Microprocessor and Microcontroller question bank. 1 Distinguish between microprocessor and microcontroller.

SOEN228, Winter Revision 1.2 Date: October 25,

Transcription:

Lecture (03) x86 programming 2 By: Dr. Ahmed ElShafee ١ TOC The 80x86 Registers The Flag Register 80x86 Modes of operation ٢

Types of instruction set Complex instruction set computer (CISC): Large instruction set; Complex operations; Complex addressing modes; Complex hardware, long execution time; Minimum number of instructions needed for a given task; Easy to program, simpler compiler. ٣ Reduced instruction set computer (RISC): Small instruction set; Simple instructions to allow for fast execution (fewer steps); Large number of registers; Only read/write (load/store) instructions should access the main memory, one MM access per instruction; Simple addressing modes to allow for fast address computation; Fixed length instructions with few formats and aligned fields to allow for fast instruction decoding; increased compiler complexity and compiling time; ٤ simpler and faster hardware implementation, pipelined architecture.

> Memory Architecture Von Neumann: Common memory for data and instructions Harvard: Separate data and instruction memories ٥ > Von Neumann Memory Architecture ٦

> Harvard Memory Architecture ٧ > Difference between microcontroller and microprocessor Most of the microprocessors use CISC architecture and Von Neumann architecture, where as microcontroller used Harvard and RISC architecture most probably. But there are some microcontroller uses CISC architecture like 8051. But popularly microprocessor uses CISC architecture as our desktop computer (x86 architecture). Microprocessor has ROM, RAM, secondary storage memory I/O peripherals, timers; counters etc are placed on a board and connected through buses where as in the microcontroller all these peripherals are combined in a single integrated circuit (IC). ٨

The Memory Map of a Personal Computers Transient Program Area (TPA): Holds the operating system (interrupt vectors, DOS BIOS, devices drivers, Command.com) and application programs. ٩ System Area: Holds the ROM BIOS, the video buffer area, and the BASIC language ROM. ١٠

Extended Memory: Memory above the 1M conventional memory found in AT compatible computers. Its size depends on the RAM installed on the motherboard, and is limited by the size of the processor s address bus. ١١ The 80x86 Registers ١٢

The Flag Register Z (zero): This flag is set to one if the result of the last arithmetic or logic instruction is zero. S (sign): This flag is set to one if the MSBit of the result of the last arithmetic or logic instruction is one, indicating a negative number. C (carry): This flag is set to one if the last arithmetic instruction gave a carry out or a borrow in. O (overflow): This flag is set to one if the result of the last arithmetic operation on signed numbers exceeded the capacity of the destination register. ١٣ 80x86 Modes of operation Protected mode Programs are given separate memory areas (segments) Programs are not allowed to access memory outside of their segments ١٤

Real address mode Environment of 8086 processor Direct access to system memory and hardware devices The operating system could crash ١٥ System management mode Provides an operating system for implementing power management and system security functions (computer manufacturers) ١٦

Program 01 // Program 01.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "stdio.h" #include "conio.h" #include "iostream" unsigned int add(unsigned int n1, unsigned int n2) unsigned int result = n1+n2; return result; int _tmain(int argc, _TCHAR* argv[]) unsigned int x,y,z; printf("enter x :");scanf("%d",&x); printf("enter y :");scanf("%d",&y); z=add(x,y); printf("%d + %d = %d\n",x,y,z); printf("press any key to continue,..."); getch(); return 0; ١٧ Program 02 // Program 01.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "stdio.h" #include "conio.h" #include "iostream" unsigned int add(unsigned int n1, unsigned int n2) _asm mov eax, n1 _asm mov edx, n2 _asm add eax, edx unsigned int result; _asm mov result,eax Return result; ١٨ int _tmain(int argc, _TCHAR* argv[]) unsigned int x,y,z; printf("enter x :");scanf("%d",&x); printf("enter y :");scanf("%d",&y); z=add(x,y); printf("%d + %d = %d\n",x,y,z); printf("press any key to continue,..."); getch(); return 0;

Program 03 // Program 01.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "stdio.h" #include "conio.h" #include "iostream" unsigned short int add(unsigned short int n1, unsigned short int n2) _asm mov ax,n1 _asm mov bx,n2 _asm add ax,bx Unsigned short int res; _asm mov res,ax return res ١٩ #include "stdafx.h" #include "stdio.h" #include "conio.h" #include "iostream" unsigned short int add(unsigned short int n1, unsigned short int n2) _asm mov ax,n1 _asm mov bx,n2 _asm add ax,bx unsigned short int res; _asm mov res,ax return res; unsigned short int sub(unsigned short int n1, unsigned short int n2) _asm mov ax,n1 _asm mov bx,n2 _asm sub ax,bx unsigned short int res; _asm mov res,ax return res; ٢٠ int _tmain(int argc, _TCHAR* argv[]) unsigned short int x,y,z; printf("enter x :");scanf("%d",&x); printf("enter y :");scanf("%d",&y); z=add(x,y); printf("%d + %d = %d\n",x,y,z); printf("press any key to continue,..."); getch(); return 0; unsigned short int mul(unsigned short int n1, unsigned short int n2) _asm mov ax,n1 _asm mov dx,n2 Program 04 _asm mul dx unsigned short int res; _asm mov res,ax return res; int _tmain(int argc, _TCHAR* argv[]) unsigned short int x,y,z; printf("enter x :");scanf("%d",&x); printf("enter y :");scanf("%d",&y); z=add(x,y); printf("%d + %d = %d\n",x,y,z); z=sub(x,y); printf("%d %d = %d\n",x,y,z); z=mul(x,y); printf("%d * %d = %d\n",x,y,z); printf("press any key to continue,..."); char ch = getch(); return 0;

Thanks,.. ٢١