SlideShare a Scribd company logo
University of Gujrat
1
University of Gujrat
Department of Computer Science
Course Code : CS-252
Computer Organization and Assembly Language
Assembly Language Basics
University of Gujrat
2 Contents
 Assembly Language Syntax
 Program Data
 Variables
 Named Constants
 Program Structure
University of Gujrat
3
Assembly Language Syntax
University of Gujrat
4
Statements
 Programs consists of statements, one per line
 Each statement is either an instruction, or an assembler directive
Syntax:
name operation operand(s) comment
e.g.
START: MOV CX , 5
;initialize counter
University of Gujrat
5 Name Field
 Used for instruction labels, procedure names and variable names
 Names can be from 1 to 31 characters long
 May consist of letters, digits and the special characters ? . @ _ $ %
 If a period (.) is used it must be the first character
 Names may not begin with a digit
 Embedded blanks are not allowed
Legal Names
 @character
 COUNTER1
 SUM_OF_DIGITS
 $1000
 DONE?
 .TEST
Illegal Names
× TWO WORDS
× 2abc
× A45.28
× a&b
University of Gujrat
6 Operation Field
 For an instruction, operation field contains symbolic operation code
(opcode) e.g. MOV, ADD, SUB
 In an assembler directive, operation field contains a pseudo-operation
code (pseudo-op) e.g. PROC
Example
MOV AX,5
MAIN PROC
University of Gujrat
7 Operand Field
 The operand field specifies the data that are to be acted on by the operation
 An instruction may have zero, one or two operands
Example
 INC AX
 ADD WORD1,2
2-operand instruction
s
operation destination operand, source operand
University of Gujrat
8 Comment Field
 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
 Assembler ignores anything typed after the semicolon
 Comments are optional
Example
MOV CX,0 ; CX counts terms, initially 0
University of Gujrat
9
Program Data
The processor operates only on binary data. Thus the assembler must
translate all data representation in binary numbers
University of Gujrat
10 Numbers
 In an assembly language program we may express data as binary,
decimal or hex numbers, and even as characters
 A binary number is written as a bit string followed by the letter “B” or “b”
 A decimal number is a string of decimal digits ending with an optional
“D” or “d”
 A hex number must begin with a decimal digit and end with the letter “H”
or “h”
Number Type
• 11011 decimal
• 11011B binary
• 64223 decimal
• -21843D decimal
• 1,234 illegal
Number Type
• 1B4DH hex
• 1B4D illegal hex
number “H”
• FFFFH illegal hex number
• 0FFFFH hex
University of Gujrat
11 Characters
 Character or character strings must be enclosed in single or double
quotes
 Characters are translated into their ASCII by the assembler
e.g.
MOV AX, “A” is same as MOV AX, 41h
University of Gujrat
12
Variables
Named Memory locations
University of Gujrat
13
Byte Variables
Syntax
name DB initial_value
e.g.
ALPHA DB 4
BYT DB ?
Define Byte
University of Gujrat
14
Word Variables
Syntax
name DW initial_value
e.g.
WRD DW -2
WRD1 DW ?
Define Word
University of Gujrat
15 Arrays
 Sequence of Memory Bytes or Words
Syntax
name pseudo-op initial_values
e.g.
B_ARRAY DB -10H, 20H, 30H
W_ARRAY DW 1000, 40, 29887, 329
DB or DW
W_ARRAY
W_ARRAY+2
W_ARRAY+4
W_ARRAY+6
University of Gujrat
16
Character Strings
 An array of ASCII codes can be initialized with a string
e.g.
LETTERS DB ‘ABC’
is equivalent to
LETTTERS DB 41H, 42H, 43H
 It is possible to combine characters and numbers into one definition;
e.g.
MSG DB ‘HELLO’, 0AH, 0DH, ‘$’
is equivalent to
MSG DB 48H, 45H, 4CH, 4CH, 4FH, 0AH, 0DH, 24H
University of Gujrat
17
Named Constants
To make assembly language code easier to understand, it is often desirable to
use a symbolic name for a constant quantity
University of Gujrat
18
EQU (Equates)
 To assign a name to a constant, we use the EQU pseudo-op
Syntax
name EQU constant
e.g.
LF EQU 0AH
 Strings can also be declared as constants
PROMPT EQU ‘TYPE YOUR NAME’
University of Gujrat
19
Program Structure
Include irvine32.inc
.DATA
; data definitions go here
.CODE
MAIN PROC
; instructions go here
MAIN ENDP
; other procedures go here
END MAIN

More Related Content

PPT
Assembly Language Basics
PPTX
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
DOC
PPTX
C Programming - Basics of c -history of c
PPTX
Introduction%20C.pptx
PPTX
PDF
C PADHLO FRANDS.pdf
PPTX
Module 3 Computer Organization Data Hazards.pptx
Assembly Language Basics
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
C Programming - Basics of c -history of c
Introduction%20C.pptx
C PADHLO FRANDS.pdf
Module 3 Computer Organization Data Hazards.pptx

Similar to COAL-8.pptx coal assignment ppt number 2 (20)

PDF
CS 3251 Programming in c all unit notes pdf
ODP
CProgrammingTutorial
PDF
Programming for Problem Solving Unit 2
PPTX
C introduction
ODP
Ppt of c vs c#
PPTX
6 assembly language computer organization
PDF
C programming language
PPTX
Unit 1.1 - Introduction to C.pptx
PPT
Getting started with c++
PPT
Getting started with c++
PPTX
datatypes and variables in c language
DOCX
C programming tutorial
PPTX
Mca i pic u-2 datatypes and variables in c language
PPTX
Bsc cs i pic u-2 datatypes and variables in c language
PPTX
Diploma ii cfpc u-2 datatypes and variables in c language
PPTX
Btech i pic u-2 datatypes and variables in c language
PDF
Week 02_Development Environment of C++.pdf
PDF
The New Yorker cartoon premium membership of the
CS 3251 Programming in c all unit notes pdf
CProgrammingTutorial
Programming for Problem Solving Unit 2
C introduction
Ppt of c vs c#
6 assembly language computer organization
C programming language
Unit 1.1 - Introduction to C.pptx
Getting started with c++
Getting started with c++
datatypes and variables in c language
C programming tutorial
Mca i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c language
Diploma ii cfpc u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c language
Week 02_Development Environment of C++.pdf
The New Yorker cartoon premium membership of the
Ad

More from itxdevilmehar (11)

PPT
Lecture No-19.ppt lecture number 19 ppt .
PPTX
COAL-8.pptx lecture number 19 Ppt number
PPTX
Research-Ethics-ppt.pptx research ethics
PPTX
Procedure.lecture number pptx slide form
PPT
Management lecture number 14-3.ppt slide
PPTX
Lecture 9 (DS) - Tree, Tree Traversal.pptx
PPTX
Lecture No-14.pptx Lecture No-14.pptx xx
PPTX
Conditional Flow Control Directive.pptxx
PPTX
Database ppt[}}.pptx database system and
PPTX
transaction management.pptx isolationand
PPT
Multimedia and ict projecg and assignmen
Lecture No-19.ppt lecture number 19 ppt .
COAL-8.pptx lecture number 19 Ppt number
Research-Ethics-ppt.pptx research ethics
Procedure.lecture number pptx slide form
Management lecture number 14-3.ppt slide
Lecture 9 (DS) - Tree, Tree Traversal.pptx
Lecture No-14.pptx Lecture No-14.pptx xx
Conditional Flow Control Directive.pptxx
Database ppt[}}.pptx database system and
transaction management.pptx isolationand
Multimedia and ict projecg and assignmen
Ad

Recently uploaded (20)

PPTX
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
PDF
Soil Improvement Techniques Note - Rabbi
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PDF
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
PPTX
Current and future trends in Computer Vision.pptx
PPTX
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PPTX
communication and presentation skills 01
PPTX
Information Storage and Retrieval Techniques Unit III
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PPTX
"Array and Linked List in Data Structures with Types, Operations, Implementat...
PPT
Total quality management ppt for engineering students
PPTX
Safety Seminar civil to be ensured for safe working.
PDF
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
PDF
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
PPTX
Software Engineering and software moduleing
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PDF
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
Soil Improvement Techniques Note - Rabbi
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
Current and future trends in Computer Vision.pptx
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
communication and presentation skills 01
Information Storage and Retrieval Techniques Unit III
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
"Array and Linked List in Data Structures with Types, Operations, Implementat...
Total quality management ppt for engineering students
Safety Seminar civil to be ensured for safe working.
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
Software Engineering and software moduleing
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf

COAL-8.pptx coal assignment ppt number 2

  • 1. University of Gujrat 1 University of Gujrat Department of Computer Science Course Code : CS-252 Computer Organization and Assembly Language Assembly Language Basics
  • 2. University of Gujrat 2 Contents  Assembly Language Syntax  Program Data  Variables  Named Constants  Program Structure
  • 4. University of Gujrat 4 Statements  Programs consists of statements, one per line  Each statement is either an instruction, or an assembler directive Syntax: name operation operand(s) comment e.g. START: MOV CX , 5 ;initialize counter
  • 5. University of Gujrat 5 Name Field  Used for instruction labels, procedure names and variable names  Names can be from 1 to 31 characters long  May consist of letters, digits and the special characters ? . @ _ $ %  If a period (.) is used it must be the first character  Names may not begin with a digit  Embedded blanks are not allowed Legal Names  @character  COUNTER1  SUM_OF_DIGITS  $1000  DONE?  .TEST Illegal Names × TWO WORDS × 2abc × A45.28 × a&b
  • 6. University of Gujrat 6 Operation Field  For an instruction, operation field contains symbolic operation code (opcode) e.g. MOV, ADD, SUB  In an assembler directive, operation field contains a pseudo-operation code (pseudo-op) e.g. PROC Example MOV AX,5 MAIN PROC
  • 7. University of Gujrat 7 Operand Field  The operand field specifies the data that are to be acted on by the operation  An instruction may have zero, one or two operands Example  INC AX  ADD WORD1,2 2-operand instruction s operation destination operand, source operand
  • 8. University of Gujrat 8 Comment Field  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  Assembler ignores anything typed after the semicolon  Comments are optional Example MOV CX,0 ; CX counts terms, initially 0
  • 9. University of Gujrat 9 Program Data The processor operates only on binary data. Thus the assembler must translate all data representation in binary numbers
  • 10. University of Gujrat 10 Numbers  In an assembly language program we may express data as binary, decimal or hex numbers, and even as characters  A binary number is written as a bit string followed by the letter “B” or “b”  A decimal number is a string of decimal digits ending with an optional “D” or “d”  A hex number must begin with a decimal digit and end with the letter “H” or “h” Number Type • 11011 decimal • 11011B binary • 64223 decimal • -21843D decimal • 1,234 illegal Number Type • 1B4DH hex • 1B4D illegal hex number “H” • FFFFH illegal hex number • 0FFFFH hex
  • 11. University of Gujrat 11 Characters  Character or character strings must be enclosed in single or double quotes  Characters are translated into their ASCII by the assembler e.g. MOV AX, “A” is same as MOV AX, 41h
  • 13. University of Gujrat 13 Byte Variables Syntax name DB initial_value e.g. ALPHA DB 4 BYT DB ? Define Byte
  • 14. University of Gujrat 14 Word Variables Syntax name DW initial_value e.g. WRD DW -2 WRD1 DW ? Define Word
  • 15. University of Gujrat 15 Arrays  Sequence of Memory Bytes or Words Syntax name pseudo-op initial_values e.g. B_ARRAY DB -10H, 20H, 30H W_ARRAY DW 1000, 40, 29887, 329 DB or DW W_ARRAY W_ARRAY+2 W_ARRAY+4 W_ARRAY+6
  • 16. University of Gujrat 16 Character Strings  An array of ASCII codes can be initialized with a string e.g. LETTERS DB ‘ABC’ is equivalent to LETTTERS DB 41H, 42H, 43H  It is possible to combine characters and numbers into one definition; e.g. MSG DB ‘HELLO’, 0AH, 0DH, ‘$’ is equivalent to MSG DB 48H, 45H, 4CH, 4CH, 4FH, 0AH, 0DH, 24H
  • 17. University of Gujrat 17 Named Constants To make assembly language code easier to understand, it is often desirable to use a symbolic name for a constant quantity
  • 18. University of Gujrat 18 EQU (Equates)  To assign a name to a constant, we use the EQU pseudo-op Syntax name EQU constant e.g. LF EQU 0AH  Strings can also be declared as constants PROMPT EQU ‘TYPE YOUR NAME’
  • 19. University of Gujrat 19 Program Structure Include irvine32.inc .DATA ; data definitions go here .CODE MAIN PROC ; instructions go here MAIN ENDP ; other procedures go here END MAIN