1 ; File: add2.asm 2 ; 3 ; Various addressing modes with the add operation. 4 ; 5 6 section .data 7 8 00000000 2A000000 x: dd 42 ; 4-byte word 9 10 11 section .text 12 global _start 13 14 00000000 90 _start: nop 15 16 ; initialize 17 18 00000001 B811000000 start: mov eax, 17 ; eax := 17 19 00000006 BB[00000000] mov ebx, x ; ebx := address of x 20 0000000B B909000000 mov ecx, 9 ; ecx := 9 21 22 00000010 0503000000 add eax, 3 ; add immediate 23 00000015 01C8 add eax, ecx ; add 32-bit registers 24 00000017 6601C8 add ax, cx ; add 16-bit registers 25 0000001A 0305[00000000] add eax, [x] ; add memory 26 00000020 0303 add eax, [ebx] ; add register indirect 27 00000022 8105[00000000]0500- add [x], dword 5 ; add immediate to mem 28 0000002A 0000 29 0000002C 0105[00000000] add [x], eax ; add register to mem 30 31 ; these two are not allowed (commented out): 32 ; add [x], [x] ; add mem to mem 33 ; add [x], [ebx] ; add reg indirect to mem 34 35 36 00000032 BB00000000 exit: mov ebx, 0 ; exit code, 0=normal 37 00000037 B801000000 mov eax, 1 ; Exit. 38 0000003C CD80 int 080H ; Call kernel.