Requirements for coding in Assembly Language

Slides:



Advertisements
Similar presentations
Sheet 1 Introduction to Computer Organization and Assembly Language.
Advertisements

1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
The Assembly Language Level
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
Chapter 3 Assembly Language: Part 1. Machine language program (in hex notation) from Chapter 2.
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.
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
ECE 265 – LECTURE 9 PROGRAM DESIGN 8/12/ ECE265.
Joseph L. Lindo Assembly Programming Sir Joseph Lindo University of the Cordilleras.
INTRODUCTION TO IBM PC ASSEMBLY LANGUAGE
INTRODUCTION TO IBM PC ASSEMBLY LANGUAGE
Chapter 2 Software Tools and Assembly Language Syntax.
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 ;
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
1/2002JNM1 Basic Elements of Assembly Language Integer Constants –If no radix is given, the integer is assumed to be decimal. Int 21h  Int 21 –A hexadecimal.
Chapter 3 Elements of Assembly Language. 3.1 Assembly Language Statements.
ASSEMBLY LANGUAGE. Assembler and Compiler Pascal A Program Compiler Version A Assembly Language Versiion A Machine Code Actual version that will be executed.
Debug and Assembler By, B.R.Chandavarkar Lect. COMP Department NITK, Surathkal.
Introduction to 8086 Assembly Language Assembly Language Programming University of Akron Dr. Tim Margush.
The x86 PC Assembly Language, Design, and Interfacing By Muhammad Ali Mazidi, Janice Gillespie Mazidi and Danny Causey © 2010, 2003, 2000, 1998 Pearson.
Ass. Prof. Dr Masri Ayob TK 6123 Lecture 13: Assembly Language Level (Level 4)
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.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Review of Assembly language. Recalling main concepts.
MIPS assembly syntax Home Assignment 3 Assigned. Deadline 2016 February 14, Sunday.
Data Structures Covers Chapter 5, pages 144 – 160 and Chapter 6, pages 198 – 203.
Lecture 2 Chapter 4 –Requirements for coding in Assembly Language 1.
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
Assembly language programming
Format of Assembly language
Assembly Lab 3.
CC410: System Programming
BASIC ELEMENTS OF A COMPUTER PROGRAM
Assembly Language Ms. V.Anitha AP/CSE SCT
Additional Assembly Programming Concepts
Assembler Directives Code generation flow
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Chapter 3 Machine Language and Assembly Language.
Chapter 3 Machine Language and Assembly Language.
MIPS assembly syntax Comments
Microprocessor and Assembly Language
INTRODUCTION ABOUT ASSEMBLY
Computer Organization & Assembly Language
Computer Organization and Assembly Language (COAL)
Microprocessor and Assembly Language
Defining Types of data expression Dn [name] expression Dn [name]
Lecture 6 Assembler Directives.
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
(Array and Addressing Modes)
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Chapter 4 –Requirements for coding in Assembly Language
Introduction to Micro Controllers & Embedded System Design
(Array and Addressing Modes)
Chapter 4 –Requirements for coding in Assembly Language
INTRODUCTION ABOUT ASSEMBLY
Chapter 4 –Requirements for coding in Assembly Language
Chapter 2: Introduction to C++.
The Data Element.
Assembler Directives end label end of program, label is entry point
Computer Architecture and System Programming Laboratory
Chapter 6 –Symbolic Instruction and Addressing
The Data Element.
Lexical Elements & Operators
Computer Organization and Assembly Language
Introduction to 8086 Assembly Language
(Array and Addressing Modes)
Presentation transcript:

Requirements for coding in Assembly Language Lecture 1 Requirements for coding in Assembly Language

Outline Assembly Language Statements Defining Types of data 1

Assembly Language Statements Programs consist of statements, one per line. Statements is either instruction or assembler directive. Instruction , which the assembler translate into machine code. Assembler directive, which instructs the assembler to perform some specific task. Both instructions and directives have up to four fields: [identifier ] operation [operand(s)] [comment] At least one blank or tab character must separate the fields. The fields do not have to be aligned in a particular column, but they must appear in the above order. 4

Assembly Language Statements An example of an instruction: START: MOV CX,5 ; initialize counter An example of an assembler directive: MAIN PROC

Identifier field The identifier is used for instruction labels, procedure names and variable name. Can be from 1 to 31 characters long (not case sensitive). May consist of letters, digits, and the special characters ? . @ _ $ % (Thus, embedded blanks are not allowed). Names may not begin with a digit. If a dot is used, it must be the first character. The assembler does not differentiate between uppercase and lowercase.

Identifiers Examples: COUNTER1 2abc Begins with a digit @CHARACTER . Not first character TWO WORDS Contains a blank STD_NUM .TEST YOU&ME Contains an illegal character 8

Operation field For an instruction, the operation field contains a symbolic operation code (opcode). The assembler translates a symbolic opcode into machine language. For example: mov, add , sub. For an assembler directive, the operation field contains a pseudo-operation code (pseudo-op). pseudo-op are not translated into machine code, they simply tell assembler to do something. For example: DB , DW , PROC.

Operand field For an instruction, the operand fields specifies the data that are to be acted on by the operation. An instruction may have zero, one, two operands. For an assembler directive, the operand fields usually contains more information about the directive.

Comment field The comment field of a statement is used by the programmer to say something about what the statement does. A semicolon marks the beginning of this field, and the assembler ignores anything typed after the semicolon. It is almost impossible to understand an assembly language program without comments. Good programming practice dictates a comment on almost every line. Examples: MOV CX, 0 ; CX counts terms, initially 0 13

Defining Types of data expression Dn [name] expression Dn [name] Name: a program that references a data item does so by means of name Dn (Directive): define the data item – see next slide— Expression: is an operand may specify an uninitialized value or constant value an uninitialized value defined by item ? EXAMPLE : DATAX DB ?

Defining Types of data (Directive): Pseudo-op Stands for DB Define Byte DW Define Word DD Define Doubleword DQ Define Quadword DT Define Tenbytes

Defining Types of data -Examples a memory byte is associated with the name ALPHA, and initialized to 4 ALPHA DB 4 A memory byte is associated with the name BYT, and uninitialized. BYT DB ? a memory word is associated with the name WRD, and initialized to -2. WRD DW -2

High and Low Bytes of a Word WORD1 DW 1234H high byte WORD1+1 low byte WORD1

Defining Types of data The decimal range (fit a byte): Unsigned representation: 0 to 255 Signed representation: -128 to 127 The decimal range (fit a word): Unsigned representation: 0 to 65535 Signed representation: -32768 to 32767

Defining Types of data – Array byte an array is a sequence of memory bytes or words. Example: B_ARRAY DB 10H,20H,30H Symbol Address Contents B_ARRAY 200H 10H B_ARRAY+1 201H 20H B_ARRAY+2 202H 30H

Defining Types of data – Array word Example: W_ARRAY DW 1000,40,29887,329 Symbol Address Contents W_ARRAY 0300H 1000D W_ARRAY+2 0302H 40D W_ARRAY+4 0304H 29887D W_ARRAY+6 0306H 329D

Defining Types of data :The DUP Operator It is possible to define arrays whose elements share a common initial value by using the DUP (duplicate) operator. Syntax: Example: Repeat-count(exp) Dn [name] creates an array of 212 uninitialized bytes. DELTA DB 212 DUP (?) set up an array of 100 words, with each entry initialized to 0. GAMMA DW 100 DUP (0)

Character String ASCII codes can be initialized with a string of characters using single quotes like ‘PC’ or double quotes like “PC”. Example: LETTERS DB 'ABC' = LETTERS DB 41H,42H,43H Inside a string, the assembler differentiates between upper and lowercase. It is possible to combine characters and numbers in one definition: Example: MSG DB 'HELLO',0AH,0DH, '$'

Exercises: Q1. Which of the following names are legal ? a. ?1 b. T = c. LET’S_GO Q2. If it is legal, give data definition pseudo-op to define each of the following. A word variable A initialized to 52. A byte variable C initialized to 300. A word variable WORD1,unintialized. A byte variable B initialized to -129.