1 / 27

ASSEMBLY LANGUAGE

ASSEMBLY LANGUAGE. Assembler and Compiler. Pascal A Program. Compiler. Version A Assembly Language. Assembler. Versiion A Machine Code. Actual version that will be executed. Relation between high level language and low level language. Advantage of Assembly Language Programming.

slone
Download Presentation

ASSEMBLY LANGUAGE

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ASSEMBLY LANGUAGE

  2. Assembler and Compiler Pascal A Program Compiler Version A Assembly Language Assembler Versiion A Machine Code Actual version that will be executed 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 Editor:Wite assembly language program Source code Assembler Object Code Library 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. Assemble Language Syntax • [LABEL/NAME] OPERATION [OPERANd] [;COMMENT] • Statement example: • Pointer: MAIN PROC ;operation name • Instruction: MOV AX,O ;opepration,2 operand • Can be seen that assemble language instruction is in a form of OPERATION CODE OPERAND

  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. 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) Name/Label Field

  9. 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 Operation Field

  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. 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) 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

  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: ALPHA DB 4 • 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 name DW first-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_ARRAY DB 10H, 20H, 30H

  20. Let say an assemble prepare offset address 0200H into B_ARRAY, memory is as below

  21. If array DW is used, let say assembler prepare offset address 0300H for W_ARRAY: W_ARRAY DW 1000, 40, 50, 523

  22. Character sequence • ASCII code array can be seen as a character sequence • Eg: HURUF DB ‘ABC’ is equivalent to HURUF DB 41H, 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: MSG DB ‘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 EQU constant • Statement example LF EQU 0AH • 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: • MOV DL, 0AH and • MOV DL, LF

  26. Symbol at the right of EQU can be character sequence • Example: PROMPT EQU “TAIP NAMA ANDA” • Statement MSG DB PROMPT give equivalent result as MSG DB “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

More Related