Computer Organization & Assembly Language

Slides:



Advertisements
Similar presentations
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.
Advertisements

CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#4)
Lecture 2 Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU.
Irvine: Assembly Language for Intel-Based Computers (1999) Symbolic Constants Equal-sign Directive EQU Directive TEXTEQU Directive.
Assembly Language for Intel-Based Computers Chapter 3: Assembly Language Fundamentals Kip Irvine.
6.1) Assembly Language Program Format 6.2) Features of Assembly Language 6.3) Data Definition CHAPTER 6 ASSEMBLY LANGUAGE PROGRAM FORMAT AND DATA DEFINITION.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#8) By Dr. Syed Noman.
Joseph L. Lindo Assembly Programming Sir Joseph Lindo University of the Cordilleras.
INTRODUCTION TO IBM PC ASSEMBLY LANGUAGE
INTRODUCTION TO IBM PC ASSEMBLY LANGUAGE
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#6)
Fundamentals of Assembly language
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 ;
ASSEMBLY LANGUAGE. Assembler and Compiler Pascal A Program Compiler Version A Assembly Language Versiion A Machine Code Actual version that will be executed.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Introduction to 8086 Assembly Language Assembly Language Programming University of Akron Dr. Tim Margush.
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.
21/11/2005CAP2411 Input & Output Instructions CPU communicates with the peripherals through I/O registers called I/O ports. There are 2 instructions, IN.
Assembly Language. Symbol Table Variables.DATA var DW 0 sum DD 0 array TIMES 10 DW 0 message DB ’ Welcome ’,0 char1 DB ? Symbol Table Name Offset var.
Review of Assembly language. Recalling main concepts.
B ASIC INSTRUCTIONS. I NTRODUCTION There are over a hundred instructions in the instruction set for the 8086 CPU; there are also instructions designed.
Lecture 2 Chapter 4 –Requirements for coding in Assembly Language 1.
Computer Organization & Assembly Language 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.
Assembly Language Lecture 2. Lecture Outline Program Structure Memory models Data Segment Stack Segment Code Segment Input and Output Instructions INT.
Sheet 2 Introduction to Computer Organization and Assembly Language.
Program Structure Example for Data Segment CRLF EQU 0DH, 0AH PROMPT DB 'Enter a digit between 0 and 9', 0 VAR1 DB ? ARRAY DW 1234h, 23h, 0FF54h.
Assembly language programming
Instruction set Architecture
Format of Assembly language
Presentation on Real Mode Memory Addressing
1st prog! Q: Read a char – from a keyboard & display it at the beginning of the next line! ====== A.
Assembly Language programming
Additional Assembly Programming Concepts
Microprocessor and Assembly Language
Microprocessor and Assembly Language
INTRODUCTION ABOUT ASSEMBLY
Microprocessor and Assembly Language
Microprocessor & Interfacing
(The Stack and Procedures)
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
Introduction to Assembly Language
BIC 10503: COMPUTER ARCHITECTURE
8086 Registers Module M14.2 Sections 9.2, 10.1.
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
(Array and Addressing Modes)
Chương 4: Lập trình hợp ngữ
(The Stack and Procedures)
Chapter 4 –Requirements for coding in Assembly Language
Symbolic Instruction and Addressing
(Array and Addressing Modes)
Chapter 4 –Requirements for coding in Assembly Language
Morgan Kaufmann Publishers Computer Organization and Assembly Language
INTRODUCTION ABOUT ASSEMBLY
Chapter 4 –Requirements for coding in Assembly Language
University of Gujrat Department of Computer Science
Requirements for coding in Assembly Language
Assembler Directives end label end of program, label is entry point
Computer Architecture and System Programming Laboratory
UNIT-II Assembly Language Programs Involving Logical
Chapter 6 –Symbolic Instruction and Addressing
(The Stack and Procedures)
Introduction to 8086 Assembly Language
Procedures & Macros Introduction Syntax Difference.
(Array and Addressing Modes)
Presentation transcript:

Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed

EQU Statment This statement is use to declare constant in assembly language Name EQU constant LF EQU 0AH We can use LF any where in the code instead of OAH E.g Mov AH, LF

Arrays in Assembly Language In assembly array is just a sequence of memory bytes or words For example to define three bytes array B_array with initial values 10H, 20H, 30H we can write B_array DB 10H, 20H, 30H B_array is associated with first address B_array+1 with second and B_array+2 with third element

Arrays in Assembly Language In the same way we can define word W_array DW 1000, 40, 2020, 100 Initial word is associated with W_array, Next is associated with W_array+2, then W_array+4 then W_array+6

Arrays in Assembly Language High and Low Byte of the word Sometime we need to refer High and Low bytes of the word like Word1 DW 1234H Low byte contain 34H High byte contain 12H Low byte have address Word1, and High byte have address Word1+1

Arrays in Assembly Language Character String Array of ASCII codes can be initialized with a string of characters like: Letter DB ‘ABC’ Is equivalent to Letter DB 41H, 42H, 43H Letter DB 65, 66, 67

Arrays in Assembly Language It is also possible to combine character and number in one defination MSG DB ‘HELLO’,0AH, 0DH, ‘$’ Is equivalent to MSG DB 48h, 45h, 4Ch, 4Ch, 4Fh, 0Ah, 0Dh, 24h

Arrays in Assembly Language MONTHS DW 12 MONTHS DW 0CH MONTHS DW 0110B ;Declare 6 Bytes Array bytes  DB 10 DUP(?) ; Declare 10 uninitialized bytes starting at location bytes. Arr DD 100 DUP(0) ; Declare 100 4-byte words starting at location arr, all initialized to 0

Array in Assembly Language my_arr db 5, 2, 8, 9, 1, 7, 3, 0, 4, 6 To load the first element of the array into register al is like this: mov al, [my_arr] Accessing the second, the third, and the forth element is like this: mov al, [my_arr+1] mov bl, [my_arr+2] Mov [my_arr+3], cl

Translation of High level language to Assembly Language Usually High level language instructions are first transferred into Assembly statements and than to machine language By using MOV, ADD, SUB, INC, DEC, and NEG we will transfer some High level instructions E.g. B=A MOV AX,A MOV B, AX

Examples A=5-A MOV AX, 5 SUB AX, A MOV A, AX OR NEG A ADD A,5 Student Exercise : A=B-2xA

Examples A=B-2xA Mov AX,B Sub AX,A Mov A,AX

Program Structure Machine Language programs consist of code, data and stack segment Each part occupies memory segment Each segment is translated into memory segment by Assembler

Memory Segment .Model Small (Code in One Segment, Data in One Segment) Medium (Code in more than One Segment, Data in One Segment) Compact (Code in One Segment, Data in more than One Segment) Large (Code in more than One Segment, Data in more than One Segment, No array is more than 64K) Huge (Code in more than One Segment, Data in more than One Segment, Array may be more than 64K)

Data Segment .Data Data Segment contain all variable definitions Constant definition are often made here Constant can also declare else where in the program Word1 DW 2 Word2 DW 5 MSG DB ‘This is Message’ Mask EQU 10010010 B

Stack Segment Stack Segment is use to declare stack area in the memory Stack area should be big enough to contain the stack at maximum size .Stack size Stack size is optional if not declared it 1K is set for stack area Stack 100H Stack 200H

Code Segment The code segment contain the program instructions The declaration syntax is .Code name Name is optional, there is no need to write name in small program Inside the code segment instruction are organized in procedure

Code Segment Simplest procedure definition is Name PROC ; body of procedure Name ENDP .code MAIN PROC ; main procedure instructions MAIN ENDP ; other procedure go here

Example Program .model small .stack 100h .data .code main proc mov ax, @data mov ds,ax mov ah,01 int 21h mov dl,'x' mov ah,2 main endp end main

Thanks