Presentation is loading. Please wait.

Presentation is loading. Please wait.

Irvine, Kip R. Assembly Language For Intel-Based Computers TYPE and SIZE Operators TYPE –returns the size, in bytes of a single element of a data label.

Similar presentations


Presentation on theme: "Irvine, Kip R. Assembly Language For Intel-Based Computers TYPE and SIZE Operators TYPE –returns the size, in bytes of a single element of a data label."— Presentation transcript:

1 Irvine, Kip R. Assembly Language For Intel-Based Computers TYPE and SIZE Operators TYPE –returns the size, in bytes of a single element of a data label (variable) LENGTH –returns a count of the number of individual elements in a data label that uses the DUP operator SIZE –returns the product of TYPE * LENGTH

2 Irvine, Kip R. Assembly Language For Intel-Based Computers.data myByte db 1,2,3,4 myWord dw 1000h,2000h,3000h myDouble dd 12345678h myQuad dq 1,2,3.code mov ax,TYPE myByte ; 1 mov ax,TYPE myWord ; 2 mov ax,TYPE myDouble ; 4 mov ax,TYPE myQuad ; 8 TYPE TYPE returns the size attribute:

3 Irvine, Kip R. Assembly Language For Intel-Based Computers.data myByte db 20 dup(?) myWord dw 5 dup(0).code mov ax,LENGTH myByte ; 20 mov ax,LENGTH myWord ; 5 LENGTH Returns a count of the number of individual elements in a data label that uses the DUP operator:

4 Irvine, Kip R. Assembly Language For Intel-Based Computers.data myByte db 20 dup(?) myWord dw 5 dup(0).code mov ax,SIZE myByte ; 20 (20 * 1) mov ax,SIZE myWord ; 10 (5 * 2) SIZE Returns TYPE multiplied by LENGTH:

5 Irvine, Kip R. Assembly Language For Intel-Based Computers JMP and LOOP Instructions JMP is an unconditional jump to a code label LOOP creates a counting loop, using CX as the default counter –LOOPD uses ECX as the counter register –LOOPW uses CX as the counter register (only necessary in 32-bit mode programming)

6 Irvine, Kip R. Assembly Language For Intel-Based Computers JMP: Distance Modifiers –JMP SHORT destination +/- 127 bytes –JMP NEAR PTR destination same code segment (default in the small and compact memory models) –JMP FAR PTR destination different code segment (default in the large, medium, and huge memory models)

7 Irvine, Kip R. Assembly Language For Intel-Based Computers JMP Example Label1:. jmp Label1 Unconditional Transfer of control to a label:

8 Irvine, Kip R. Assembly Language For Intel-Based Computers LOOP Instruction Automatically uses CX as the counter –decrements it automatically If CX > 0, LOOP transfers control to a label –otherwise, excecution drops through

9 Irvine, Kip R. Assembly Language For Intel-Based Computers mov cx,5 ; loop counter mov bx,1 ; value to be added mov ax,0 ; holds the sum L1: add ax,bx inc bx Loop L1 ; AX=000F, BX=0006, CX=0000 LOOP Example Task: sum the integers { 1,2,3,4,5 }

10 Irvine, Kip R. Assembly Language For Intel-Based Computers Indirect Addressing Indirect Operands [si]. [di], [bx], [bp] Based and Indexed Operands array[si], array[di], array[bx] Base-Index Operands [bx+si], [bx+di] Base-Index with Displacement array[bx+si], array[bx+di]

11 Irvine, Kip R. Assembly Language For Intel-Based Computers Indirect Operand Example.data aString db "ABCDEFG“.code mov bx,offset aString add bx,5 mov dl,[bx]

12 Irvine, Kip R. Assembly Language For Intel-Based Computers.data aList db 10h,20h,30h sum db 0.code mov bx,offset aList mov al,[bx] ; AL = 10h inc bx add al,[bx] ; AL = 30h inc bx add al,[bx] ; AL = 60h mov si,offset sum ; get offset of sum mov [si],al ; store the sum Adding 8-bit Integers If you want to paste a code example such as this into a program, remember that the code segment must always begin with the following statements: mov ax,@data mov ds,ax

13 Irvine, Kip R. Assembly Language For Intel-Based Computers.data wordList dw 1000h,2000h,3000h, 0.code mov bx,offset wordList mov ax,[bx]; first number add ax,[bx+2]; second number add ax,[bx+4]; third number mov [bx+6],ax; store the sum Adding 16-bit Integers

14 Irvine, Kip R. Assembly Language For Intel-Based Computers 32-Bit Registers.386 mov ax,[ebx+3] mov dl,string[edx] mov ecx,[esi] mov ebx,[eax] The.386 directive permits any of the following registers to be used as indirect operands: EAX, EBX, ECX, EDX, ESI, EDI, EBP


Download ppt "Irvine, Kip R. Assembly Language For Intel-Based Computers TYPE and SIZE Operators TYPE –returns the size, in bytes of a single element of a data label."

Similar presentations


Ads by Google