Presentation is loading. Please wait.

Presentation is loading. Please wait.

ASSEMBLY LANGUAGE. Assembler and Compiler Pascal A Program Compiler Version A Assembly Language Versiion A Machine Code Actual version that will be executed.

Similar presentations


Presentation on theme: "ASSEMBLY LANGUAGE. Assembler and Compiler Pascal A Program Compiler Version A Assembly Language Versiion A Machine Code Actual version that will be executed."— Presentation transcript:

1 ASSEMBLY LANGUAGE

2 Assembler and Compiler Pascal A Program Compiler Version A Assembly Language Versiion A Machine Code Actual version that will be executed Assembler Relation between high level language and low level language

3 Advantage of Assembly Language Programming Supply more control in controlling certain devices Execute more compact and smaller execution module Faster execution time

4 Assembly Language Program Execution Library Editor:Wite assembly language program Source code Assembler Object Code Linker Execution Code Execution

5 Assemble Language Syntax There are two types of statement –Instruction: example MOV and ADD, which translated by assembler into machine code –Pointer : instruct assembler to execute specific work such as create procedure to allocate memory space for variable

6 [LABEL/NAME] OPERATION [OPERANd] [;COMMENT] Statement example: –Pointer: MAINPROC;operation name –Instruction: MOVAX,O;opepration,2 operand Can be seen that assemble language instruction is in a form of OPERATION CODEOPERAND Assemble Language Syntax

7 Name/Label Field Used to name instruction, procedure name or variable name Length from 1-31 character Able to contain character,number and special character like ?. @ _ $ %. Empty space is not allowed and special character must be at the beginning of a name

8 Name/Label Field Example of valid name –KAUNTER1 –@aksara –JUMLAH_DIGIT –$100 –OK? –.CUBA Example of invalid name –DUA PERKATAAN (empty space) –3abc(first character is a number) –A42.05(“.” is not the first character)

9 Operation Field For instruction, contains operation code (opcode) in mnemonics form (combination of unique characters) Assembler will translate the symbolic operation code into machine language operation/opcode Opcode example is MOV, ADD and SUB. For directive, contains pseudo operation code (pseudo-op) Will not be translated into machine code but only inform assembler to do something

10 Operand Field For instruction, operand field specifies data that will be executed by operation Can contain 0, 1 or 2 operand For 2 operand, operand 1 is the destination operand (consist of register or memory location where result is stored) Second operand is the source operand

11 Comment Field Increase program understandability Start with ; sign Can contain printed character including empty space Example: ; this is a comment

12 Program Data Assemble translate all data representation into binary number form In assembly language programming, data can be represented in binary, decimal, hexadecimal and character form

13 Number Written in bit sequence followed by “B” or “b” (optional) Similar for hexa and decimal number Example: Valid representation –11011 (Decimal) –11011B (Binary) –-2322D (Decimal) Invalid representation –1,234 (contains non digit character) –1B4D (there is no B in decimal number)

14 Character Must written in bracket ‘ ’ or “ ” Will be translated by assembler into equivalen ASCII Example: the usage of “A” is similar to 41h (ASCII code for “A”)

15 Pseudo-op Pseudo-op defination Pseudo-opDefined as DBDefine byte DWDefine word DDDefine doubleword (2 words) DQDefine quadword (4 words)

16 Variable Each variable contains data type and address which will be accumulated by program Declared as –name DB first-value –name DW last-value

17 i. Byte Variable –Statement for declaration is in a form of name DB first-value –Eg: ALPHADB4 –One space with 1 byte size will be prepared with ALPHA and started with value 4 –DUP instruction (duplicate) – for copy all character following the given number without repeated writing –Eg: DATA1 DB OFFH,OFFH,OFFH,OFFH is written as DATA1 DB 4 DUP (OFFH)

18 ii. Word Variable Statement for define is in a form of nameDWfirst-value example: WRD DW -2

19 Array One memory sequence whether in byte or word Eg: for 3-byte array definition B_ARRAY which give starting value of 10h, 20h and 30h is written as B_ARRAYDB10H, 20H, 30H

20 Let say an assemble prepare offset address 0200H into B_ARRAY, memory is as below SymbolAddressContent B_ARRAY200H10H B_ARRAY201H20H B_ARRAY202H30H

21 If array DW is used, let say assembler prepare offset address 0300H for W_ARRAY: W_ARRAYDW1000, 40, 50, 523 SymbolAddressContent W_ARRAY0300H1000D W_ARRAY+20302H40D W_ARRAY+40304H50D W_ARRAY+60306H523D

22 Character sequence ASCII code array can be seen as a character sequence Eg: HURUFDB‘ABC’ is equivalent to HURUFDB41H, 42H, 43H The usage of small letter and capital letter is different Eg : HURUF DB ‘ABC’ = HURUF DB 41H,42H,43H HURUF DB ‘abc’ = HURUF DB 61H,62H,63H

23 Character and number combination is allowed Eg: MSGDB‘HELLO’,0AH,0DH,’$’ is equivalent to MSG DB 48H,45H,4CH,4FH,0AH,0DH,24H

24 Constant Symbolic name is given to the used constant EQU (equates) instruction is used Syntax : name EQUconstant Statement example LFEQU0AH This statement accumulate LF name to 0AH (ASCII code) for line feed.

25 All 0AH usage can be replaced with LF and give the same result Example: –MOVDL, 0AH and –MOVDL, LF

26 Symbol at the right of EQU can be character sequence Example: PROMPTEQU “TAIP NAMA ANDA” Statement MSGDBPROMPT give equivalent result as MSGDB “TAIP NAMA ANDA” There is no memory space for EQU instruction

27 Program structure Code, data and stack is structured as program segments Will be translated into memory segment by assembler


Download ppt "ASSEMBLY LANGUAGE. Assembler and Compiler Pascal A Program Compiler Version A Assembly Language Versiion A Machine Code Actual version that will be executed."

Similar presentations


Ads by Google