Presentation is loading. Please wait.

Presentation is loading. Please wait.

BASIC SYNTAX OF ASSEMBLY LANGUAGE “HELLO WORLD” PROGRAM.

Similar presentations


Presentation on theme: "BASIC SYNTAX OF ASSEMBLY LANGUAGE “HELLO WORLD” PROGRAM."— Presentation transcript:

1 BASIC SYNTAX OF ASSEMBLY LANGUAGE “HELLO WORLD” PROGRAM

2 GROUP # 07 GROUP MEMBERS  03MOHAMMAD ALI ASIF  15FARUKH HAMEED  30MUHAMMAD AZHAR  35 UMAR QURAISHI

3 CONTENTS  Assembly Language Overview  Assemble-Link-Debug Cycle  Assemblers (MASM, NASM, FASM and TASM )  Basic Syntax  Title and Header .code and.data  Comments  Variables definition statements  Define directives  General Purpose Registers  “ Hello World ” Program  “ Basic Arithmetic Operation” Program

4 OVERVIEW  Assembly language is a low-level programming language for a computer or other programmable device specific to a particular computer architecture.  Assembly language is converted into executable machine code by a utility program referred to as an assembler like NASM, MASM, etc.

5 ASSEMBLER  An assembler is a type of computer program that interprets software programs written in assembly language into machine language, code and instructions that can be executed by a computer.

6 TYPES OF ASSEMBLER  MASM Macro Assembler (a Microsoft product)...often mistaken for "Microsoft Assembler". Macro Assembler is the popular assembler for Windows. MASM is for 16-bit and 32-bit applications(x86).  NASM Netwide Assembler is the popular assembler for Linux but is available on Windows too. NASM supports 16-bit, 32 bit and 64 bit programs  FASM Flat Assembler is available for both Windows and Linux. FASM too supports both 32-bit and 64-bit programs.

7 ASSEMBLE- LINK-DEBUG CYCLE Editor write new (.asm ) program Assembler: translate (.asm) file into object (.obj) file in machine language also produce a listing (.lst) file that show the work of assembler. Linker: combine object (.obj) files with library (.lib) files produce executable(.exe) file can produce optional (.map) file (.exe) file can run on windows computer can debug using editor.

8 ASSEMBLER-LINK-DEBUG CYCLE

9 BASIC SYNTAX titleprogram_name (program_name.asm) include Irvine32.inc.data - - - - - - - - -.code main PROC - - - - - - - - - exit main ENDP END main

10 TITLE AND HEADER  TITLE  Title is used in assembly language to give any name for program and file name.  Title is optional  Syntax: titleprogram_name( file_name.asm )  HEADER  In Assembly language header Irvine32 is used just like in C++ we use  Syntax: Include irvine32.inc

11 .CODE AND.DATA .DATA Section  The.data section is used for declaring initialized data or constants. This data does not change at runtime. You can declare various constant values.  Its syntax is.DATA .CODE section  The.CODE section is used for keeping actual code.  Syntax:.CODE

12 COMMENTS  Assembly language comment begins with a semicolon (;). It may contain any printable character including blank. It can appear on a line by itself,  Syntax: ; this program displays a message on screen OR Add eax, 10; add 10 to eax

13 VARIABLE DEFINATION STATEMENT  Variables are defined in.data section  Syntax :  [variable-name] directive initial-value  Examples : choice WORD ‘y’ numberBYTE12345 neg_numberSBYTE -12345

14 DEFINE DIRECTIVES  BYTE/DB 8-bit unsigned integer  SBYTE 8-bit signed integer  WORD/DW 16-bit unsigned integer  SWORD 16-bit signed integer  DWORD 32-bit unsigned integer  SDWORD 32-bit signed integer  QWORD/DQ 64-bit integer  TBYTE/DT 80-bit integer  REAL4  IEEE single precision float  Occupies 4 bytes  Short real  REAL8  IEEE double precision float  Occupies 8 bytes  long real  REAL10  IEEE extended-precision float  Occupies 10 bytes Institute of Electrical and Electronics Engineers

15 GENERAL PURPOSE REGISTERS x86 Architecture has 8 General-Purpose Registers eax Accumulator register Used in arithmetic operations to hold the values edx Data registerIs used to store the address of a variable. ebxBase registerUsed as pointer to data ecxCounter registerCounter for loop operations espStack pointer registerPointer to the top of the stack ebpBase pointer registerUsed to point the base of the stack esiSource index registerUsed as pointer to source in stream operations ediDestination index registerUsed as pointer to source in stream operations

16 HELLO WORLD PROGRAM title Hello World (HelloWorld.asm) ; This program display the message Hello World INCLUDE Irvine32.inc.data message BYTE “Hello World”.code main PROC lea edx, message; load effective address of message in edx call WriteString; Display the value in address, hold by edx exit main ENDP END main

17 BASIC ARITHMETIC PROGRAM title Add and Subtract (AddSub.asm) INCLUDE Irvine32.inc.DATA var1DWORD10000.code main PROC mov eax, var1 ;EAX = 10000 add eax, 40000 ;EAX = 50000 sub eax, 20000 ;EAX = 30000 movresult, eax lea edx, result ;address of result to edx call WriteString ;Display the value exit main ENDP END main


Download ppt "BASIC SYNTAX OF ASSEMBLY LANGUAGE “HELLO WORLD” PROGRAM."

Similar presentations


Ads by Google