; File: add.asm ; ; Various addressing modes with the add operation. ; section .data x: dd 42 ; 4-byte word array: dd 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 section .text global _start _start: nop ; initialize start: mov eax, 17 ; eax := 17 mov ebx, x ; ebx := address of x mov ecx, 9 ; ecx := 9 add eax, 3 ; add immediate add eax, ecx ; add 32-bit registers add ax, cx ; add 16-bit registers add eax, [x] ; add memory add eax, [ebx] ; add register indirect add [x], dword 5 ; add immediate to mem add [x], eax ; add register to mem ; these two are not allowed (commented out): ; add [x], [x] ; add mem to mem ; add [x], [ebx] ; add reg indirect to mem mov esi, array ; esi := address of array mov ecx, 2 ; ecx := 2 add eax, [4*ecx+array] ; add array[2] to eax add eax, [esi+4*ecx] ; add array[2] to eax add eax, [esi+4*ecx+4] ; add array[3] to eax exit: mov ebx, 0 ; exit code, 0=normal mov eax, 1 ; Exit. int 080H ; Call kernel.