Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.

Similar presentations


Presentation on theme: "Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed."— Presentation transcript:

1 Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed

2 DB-define byte DW-define word DD-define double word (two consecutive words) DQ- define quadword (four consecutive words) DT-define ten consecutive bytes.DATA directive

3 Name Type initial_value Var DB 64 ;Declare a byte, referred to as location var, containing the value 64. Var2 DB ? ;Declare an uninitialized byte, referred to as location var2. DB 10 ;Declare a byte with no label, containing the value 10. Its location is var2 + 1. X DW ? ; Declare a 2-byte uninitialized value, referred to as location X. Y DD 30000 ; Declare a 4-byte value, referred to as location Y, initialized to 30000. Declaration of Assembly Language

4 Two Words Contains a blank 2abc Begins with a digit A45.45. Is not allowed You&me contain an illegal character Illegal Variable Names

5 On the bases of operands instructions can be divided into three types – No operands e.g NOP – One operands e.g INC AX – Two operands e.g ADD Word1,2 In two operands instructions first operand is as destination where result is stored Second operand is source operand source is not usually modified after completion of instruction Types of Instructions

6 Programmer use comments to say something about code ; symbol is use to define comment This symbol is use at the start of each statement on which we want to apply comments. Assembler will ignore the statements typed after ; MOV CX,0 ;mov 0 in CX register Comments in Assembly

7 Processor can only operate on binary numbers but Assembler can accept Binary, Decimal and Hex numbers B or b is use at the end to define binary D or d is use at the end to define decimal H or h is use at the end to define Hex Hex number must begin with decimal and end with H Program data (Numbers)

8 Examples 1110101Decimal 1010101BBinary 7672321Decimal -22321DDecimal 1,2212Illegal 173BHHexadecimal FFFFHIllegal 0FFFFHHexadecimal Program data (Numbers)

9 Any 32-bit register (EAX, EBX, ECX, EDX, ESI, EDI, ESP, or EBP) Any 16-bit register (AX, BX, CX, or DX) Any 8-bit register (AH, BH, CH, DH, AL, BL, CL, or DL) Any register A memory address (e.g., [eax], [var + 4], or dword ptr [eax+ebx]) Any 32-bit constant Any 16-bit constant Any 8-bit constant Any 8-, 16-, or 32-bit constant Instructions

10 The mov instruction copies the data item referred to by its second operand (i.e. register contents, memory contents, or a constant value) into the location referred to by its first operand Data Movement Instructions

11 Syntax mov, mov, mov, mov, mov, Examples mov eax, ebx — copy the value in ebx into eax mov byte ptr [var], 5 — store the value 5 into the byte at location var Data Movement Instructions

12 MOV

13 Size of both operand of mov instruction must be same But, in some cases these may be imbegious like, mov [ebx], 2. Size Directives

14 mov BYTE PTR [ebx], 2; Move 2 into the single byte at the address stored in EBX. mov WORD PTR [ebx], 2; Move the 16-bit integer representation of 2 into the 2 bytes starting at the address in EBX. mov DWORD PTR [ebx], 2 ; Move the 32-bit integer representation of 2 into the 4 bytes starting at the address in EBX. Size Directives

15 XCHG, exchange is use to exchange the content of two operands XCHG Destination, Source XCHG instruction

16 The sub instruction stores in the value of its first operand the result of subtracting the value of its second operand from the value of its first operand Syntax add, add, add, add, add, Examples add eax, 10 — EAX ← EAX + 10 add BYTE PTR [var], 10 — add 10 to the single byte stored at memory address var Add Instruction

17 The sub instruction stores in the value of its first operand the result of subtracting the value of its second operand from the value of its first operand Syntax sub, sub, sub, sub, sub, Examples sub al, ah — AL ← AL - AH sub eax, 216 — subtract 216 from the value stored in EAX Sub Instruction

18 The inc instruction increments the contents of its operand by one The dec instruction decrements the contents of its operand by one. inc, dec — Increment, Decrement

19 Syntax inc inc dec dec Examples dec eax — subtract one from the contents of EAX. inc DWORD PTR [var] — add one to the 32-bit integer stored at location var inc, dec — Increment, Decrement

20 ADD, SUB, INC and DEC

21 Thanks


Download ppt "Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed."

Similar presentations


Ads by Google