1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| section .data
msga db 'Saisir A : '
la equ $ - msga
msgb db 'Saisir B : '
lb equ $ - msgb
op db 'Operation 1-Add 2-Sub : '
lop equ $ - op
resv db 'resultat : '
lr equ $ - resv
section .bss
numa resb 2
numb resb 2
numop resb 2
res resb 1
section .text
global _start
_start:
;Saisir A
mov eax,4
mov ebx,1
mov ecx,msga
mov edx,la
int 80h
;Lire A
mov eax,3
mov ebx,2
mov ecx,numa
mov edx,2
int 80h
;Saisir B
mov eax,4
mov ebx,1
mov ecx,msgb
mov edx,lb
int 80h
;Lire B
mov eax,3
mov ebx,2
mov ecx,numb
mov edx,2
int 80h
;Saisir op
mov eax,4
mov ebx,1
mov ecx,op
mov edx,lop
int 80h
;Lire po
mov eax,3
mov ebx,2
mov ecx,numop
mov edx,1
int 80h
;Afficher le resultat
mov eax,[numa]
sub eax,'0'
mov ebx,[numb]
sub ebx,'0'
cmp ecx,'1'
je op_add
cmp ecx,'2'
je op_sub
op_add:
add eax,ebx
jmp _exit
op_sub:
sub eax,ebx
jmp _exit
_exit:
;mov [res],ecx
add eax,'0' ;convertir vers ASCII
mov [res],eax
mov eax,4
mov ebx,1
mov ecx,res
mov edx,2
int 80h
mov eax,1
int 80h |
Partager