begin process at 2012 05 24 02:12:49
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

68xxx

 > CALCULETTE À DEUX OPÉRANDES

CALCULETTE À DEUX OPÉRANDES


 Information sur la source

Note :
8 / 10 - par 1 personne
8,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :68xxx Niveau :Débutant Date de création :28/08/2002 Date de mise à jour :28/08/2002 14:22:53 Vu :8 706

Auteur : ThameurSupcom

Ecrire un message privé
Commentaire sur cette source (2)
Ajouter un commentaire et/ou une note

 Description

Addition, Soustraction, Multiplication et division de deux entiers

Source

  • dosseg
  • .model small
  • .stack 100h
  • .data
  • x_out db 8 dup (0)
  • invite db 13,10," Operation > $"
  • espace db " $"
  • result db 13,10," Resultat > $"
  • depas db 13,10," Resultat > 1$"
  • titre db 13," ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»",13,10
  • db 13," º CALCULATRICE º",13,10
  • db 13," º PROGRAMMEES PAR º",13,10
  • db 13," ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹",13,10
  • db 13," º Thameur BELGHITH º Fahima HAMDI º",13,10
  • db 13," ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ",13,10
  • db 13,"ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ",13,10,"$"
  • tab1 db 8 dup (1)
  • tab3 db 8 dup (0)
  • ct db (0)
  • x db (0)
  • y db (0)
  • nbr1 dw ?
  • nbr3 dw 2 dup (0)
  • reste db 13,10," ==> Reste = $"
  • quot db 13,10," ==> Quotient = $",10,13
  • revoir db " Au revoir ... ",13,10
  • db 13,"ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ",13,10,10,"$"
  • n db 5 dup (0)
  • m db 5 dup (0)
  • l db 5 dup (0)
  • k db 5 dup (0)
  • c1 db (0)
  • .code
  • ;**************************
  • ;Procedure pour l'affichage
  • ;**************************
  • affichage proc far
  • affich:
  • mov dl,x_out[si]
  • add dl,48
  • cmp dl,48 ;non affichage de zero
  • jne bou1
  • jmp o
  • bou1: mov ah,6
  • int 21h
  • mov c1,5
  • jmp bou2
  • o: cmp c1,5
  • je bou1
  • bou2: inc si
  • inc cx
  • cmp cx,4
  • pushf
  • jne w
  • cmp c1,0
  • jne w
  • mov dl,48
  • mov ah,6
  • int 21h
  • w: popf
  • js affich
  • ret
  • affichage endp
  • ;**************************
  • ;Procedure pour la division
  • ;**************************
  • division proc far
  • mov cx,0
  • mov cl,x_out[7]
  • push cx
  • mov al,x_out[6]
  • mov bl,10
  • mul bl
  • pop cx
  • add cx,ax
  • push cx
  • mov al,x_out[5]
  • mov bl,100
  • mul bl
  • pop cx
  • add cx,ax
  • push cx
  • mov ah,0
  • mov al,x_out[4]
  • mov bx,1000
  • mul bx
  • pop cx
  • add cx,ax
  • mov nbr1,cx
  • mov cx,0
  • mov cl,x_out[3]
  • push cx
  • mov al,x_out[2]
  • mov bl,10
  • mul bl
  • pop cx
  • add cx,ax
  • push cx
  • mov al,x_out[1]
  • mov bl,100
  • mul bl
  • pop cx
  • add cx,ax
  • push cx
  • mov ah,0
  • mov al,x_out[0]
  • mov bx,1000
  • mul bx
  • pop cx
  • add ax,cx
  • mov dx,0
  • div nbr1
  • mov nbr3[0],ax
  • mov nbr3[2],dx
  • ;******************************
  • ;conversion du quotient en hexa
  • ;******************************
  • mov dx,0
  • mov ax,nbr3[0]
  • mov bx,1000
  • div bx
  • mov m[0],al
  • mov ax,dx
  • mov bl,100
  • div bl
  • mov m[1],al
  • mov al,ah
  • mov ah,0
  • mov bl,10
  • div bl
  • mov m[2],al
  • mov m[3],ah
  • ;*******************
  • ;conversion du reste
  • ;*******************
  • mov dx,0
  • mov ax,nbr3[2]
  • mov bx,1000
  • div bx
  • mov k[0],al
  • mov ax,dx
  • mov bl,100
  • div bl
  • mov k[1],al
  • mov al,ah
  • mov ah,0
  • mov bl,10
  • div bl
  • mov k[2],al
  • mov k[3],ah
  • mov dx,offset result
  • mov ah,09
  • int 21h
  • mov dx,offset quot
  • mov ah,9
  • int 21h
  • mov si,0
  • mov cx,0
  • mov c1,0
  • ;******************
  • ;affichage du reste
  • ;******************
  • affich0:mov dl,m[si]
  • add dl,48
  • cmp dl,48
  • jne aff
  • jmp affic
  • mov dl,10 ;retour a la ligne
  • mov ah,6
  • int 21h
  • mov dl,13 ; debut de la ligne
  • mov ah,6
  • int 21h
  • aff: mov ah,6
  • int 21h
  • mov ct,5
  • jmp j0
  • affic: cmp ct,5
  • je aff
  • j0: inc si
  • inc cx
  • cmp cx,4
  • pushf
  • jne jo10
  • cmp ct,0
  • jne jo10
  • mov dl,48
  • mov ah,6
  • int 21h
  • jmp t
  • jo10: popf
  • js affich0
  • t: mov dl,10
  • mov ah,6
  • int 21h
  • mov dl,13
  • mov ah,6
  • int 21h
  • mov dx,offset reste
  • mov ah,09
  • int 21h
  • mov si,0 ;affichage du reste
  • mov cx,0
  • mov ct,0
  • affich1:mov dl,k[si]
  • add dl,48
  • cmp dl,48
  • jne af00
  • jmp af100
  • af00: mov ah,6
  • int 21h
  • mov ct,5
  • jmp j00
  • af100: cmp ct,5
  • je af00
  • j00: inc si
  • inc cx
  • cmp cx,4
  • pushf
  • jne jo100
  • cmp ct,0
  • jne jo100
  • mov dl,48
  • mov ah,6
  • int 21h
  • jo100: popf
  • js affich1
  • jmp fin
  • division endp
  • ;**********************
  • ;procedure soustraction
  • ;**********************
  • soustraction proc far
  • mov al,x_out[0]
  • cmp al,x_out[4]
  • ja positif
  • jb negatif
  • mov al,x_out[1]
  • cmp al,x_out[5]
  • ja positif
  • jb negatif
  • mov al,x_out[2]
  • cmp al,x_out[6]
  • ja positif
  • jb negatif
  • mov al,x_out[3]
  • cmp al,x_out[7]
  • jae positif
  • negatif:
  • mov x,10
  • mov si,0
  • mov di,4
  • mov cx,4
  • boucle:
  • mov bl,x_out[si]
  • mov al,x_out[di]
  • mov m[si],al
  • mov m[di],bl
  • inc si
  • inc di
  • loop boucle
  • positif:
  • mov al,x_out[7]
  • sub x_out[3],al
  • pushf
  • jnc change0
  • not x_out[3]
  • add x_out[3],1
  • mov al,10
  • sub al,x_out[3]
  • mov x_out[3],al
  • change0:
  • mov al,x_out[6]
  • popf
  • sbb x_out[2],al
  • pushf
  • jnc change1
  • not x_out[2]
  • add x_out[2],1
  • mov al,10
  • sub al,m[2]
  • mov x_out[2],al
  • change1:
  • mov al,x_out[5]
  • popf
  • sbb x_out[1],al
  • pushf
  • jnc change2
  • not x_out[1]
  • add x_out[1],1
  • mov al,10
  • sub al,x_out[1]
  • mov x_out[1],al
  • change2:
  • mov al,x_out[4]
  • popf
  • sbb x_out[0],al
  • pushf
  • jnc change3
  • not x_out[0]
  • add x_out[0],1
  • mov al,10
  • sub al,x_out[0]
  • mov x_out[0],al
  • change3:
  • mov si,0
  • mov cx,0
  • popf
  • jnc change4
  • change4:
  • cmp x,10
  • jne change5
  • mov dx, offset result
  • mov ah,09
  • int 21h
  • mov dl,45
  • mov ah,6
  • int 21h
  • call affichage
  • jmp fin
  • change5:
  • mov dx,offset result
  • mov ah,09
  • int 21h
  • mov c1,0
  • call affichage
  • jmp fin
  • soustraction endp
  • ;*************************
  • ;Procedure pour l'addition
  • ;*************************
  • addition proc far
  • mov al,x_out[7]
  • add x_out[3],al
  • mov al,x_out[3]
  • mov ah,0
  • mov cl,10
  • div cl
  • mov x_out[3],ah
  • add x_out[2],al
  • mov al,x_out[6]
  • add x_out[2],al
  • mov al,x_out[2]
  • mov ah,0
  • mov cl,10
  • div cl
  • mov x_out[2],ah
  • add x_out[1],al
  • mov al,x_out[5]
  • add x_out[1],al
  • mov al,x_out[1]
  • mov ah,0
  • mov cl,10
  • div cl
  • mov x_out[1],ah
  • add x_out[0],al
  • mov al,x_out[4]
  • add x_out[0],al
  • mov al,x_out[0]
  • mov ah,0
  • mov cl,10
  • div cl
  • mov x_out[0],ah
  • cmp al,1
  • je dep
  • jne resl
  • dep: mov dx,offset depas
  • mov ah,09
  • int 21h
  • mov si,0
  • mov cx,0
  • mov c1,0
  • call affichage
  • jmp fin
  • resl:
  • mov dx,offset result
  • mov ah,09
  • int 21h
  • mov si,0
  • mov cx,0
  • mov c1,0
  • call affichage
  • jmp fin
  • addition endp
  • ;******************************
  • ;Procedure de la multiplication
  • ;******************************
  • multiplication proc far
  • mov si,4
  • a:
  • mov al,x_out[7]
  • mov bl,x_out[si-1]
  • mul bl
  • mov cl,10
  • div cl
  • add n[si],ah
  • add n[si-1],al
  • dec si
  • cmp si,0
  • jne a
  • mov si,4
  • b:
  • mov al,x_out[6]
  • mov bl,x_out[si-1]
  • mul bl
  • mov cl,10
  • div cl
  • add m[si],ah
  • add m[si-1],al
  • dec si
  • cmp si,0
  • jne b
  • mov si,4
  • c:
  • mov al,x_out[5]
  • mov bl,x_out[si-1]
  • mul bl
  • mov cl,10
  • div cl
  • add l[si],ah
  • add l[si-1],al
  • dec si
  • cmp si,0
  • jne c
  • mov si,4
  • d:
  • mov al,x_out[4]
  • mov bl,x_out[si-1]
  • mul bl
  • mov cl,10
  • div cl
  • add k[si],ah
  • add k[si-1],al
  • dec si
  • cmp si,0
  • jne d
  • mov al,n[4]
  • add tab3[7],al
  • mov al,0
  • add al,n[3]
  • add al,m[4]
  • mov ah,0
  • mov cl,10
  • div cl
  • mov tab3[6],ah
  • add al,n[2]
  • add al,m[3]
  • add al,l[4]
  • mov ah,0
  • mov cl,10
  • div cl
  • mov tab3[5],ah
  • add al,n[1]
  • add al,m[2]
  • add al,l[3]
  • add al,k[4]
  • mov ah,0
  • mov cl,10
  • div cl
  • mov tab3[4],ah
  • add al,n[0]
  • add al,m[1]
  • add al,l[2]
  • add al,k[3]
  • mov cl,10
  • mov ah,0
  • div cl
  • mov tab3[3],ah
  • add al,m[0]
  • add al,l[1]
  • add al,k[2]
  • mov cl,10
  • mov ah,0
  • div cl
  • mov tab3[2],ah
  • add al,l[0]
  • add al,k[1]
  • mov cl,10
  • mov ah,0
  • div cl
  • mov tab3[1],ah
  • add al,k[0]
  • mov tab3[0],al
  • mov dx,offset result
  • mov ah,09
  • int 21h
  • mov si,0
  • mov cx,0
  • affichage1:
  • mov dl,tab3[si]
  • add dl,48
  • cmp dl,48 ;pour eliminer les zeros
  • jne e
  • jmp f
  • e: mov y,5
  • mov ah,6
  • int 21h
  • jmp comp
  • f: cmp y,5
  • je e
  • comp: inc si
  • inc cx
  • cmp cx,8
  • pushf
  • jne g
  • cmp y,0
  • jne g
  • mov dl,48
  • mov ah,6
  • int 21h
  • g: popf
  • js affichage1
  • jmp fin
  • multiplication endp
  • ;****************************
  • ;debut de programme principal
  • ;****************************
  • start: mov ax,@data
  • mov ds,ax
  • mov cx,5
  • bouc1:
  • mov dl,13 ; debut de la ligne
  • loop bouc1
  • mov dx,offset titre
  • mov ah,9
  • int 21h
  • mov dx,offset invite
  • mov ah,9
  • int 21h
  • lea bx,tab1
  • call lire_4 ;saisie de 1er nbre
  • cmp tab1[3],1
  • jne suite1
  • cmp tab1[2],1
  • jne suite2
  • cmp tab1[1],1
  • jne suite3
  • mov al,tab1[0]
  • mov tab1[3],al
  • mov tab1[0],30h
  • mov tab1[1],30h
  • mov tab1[2],30h
  • jmp suite1
  • suite3:
  • mov al,tab1[1]
  • mov tab1[3],al
  • mov al,tab1[0]
  • mov tab1[2],al
  • mov tab1[0],30h
  • mov tab1[1],30h
  • jmp suite1
  • suite2:
  • mov al,tab1[2]
  • mov tab1[3],al
  • mov al,tab1[1]
  • mov tab1[2],al
  • mov al,tab1[0]
  • mov tab1[1],al
  • mov tab1[0],48
  • suite1:
  • mov dx,offset espace
  • mov ah,09
  • int 21h
  • debut1:
  • mov dl,255
  • mov ah,6
  • int 21h
  • cmp al,45
  • je soust
  • cmp al,43
  • je addit
  • cmp al,47
  • je divvv
  • cmp al,42
  • je multi
  • jmp debut1
  • soust:
  • mov dl,45 ;affichage de '-'
  • mov ah,6
  • int 21h
  • mov x,45
  • jmp application
  • addit:
  • mov dl,43 ;affichage de '+'
  • mov ah,6
  • int 21h
  • mov x,43
  • jmp application
  • divvv: ;affichage de '/'
  • mov dl,47
  • mov ah,6
  • int 21h
  • mov x,47
  • jmp application
  • multi: ;affichage de '*'
  • mov dl,42
  • mov ah,6
  • int 21h
  • mov x,42
  • jmp application
  • mov dx,offset espace
  • mov ah,09
  • int 21h
  • application:
  • mov dx,offset espace
  • mov ah,09
  • int 21h
  • lea bx,tab1
  • add bx,4
  • call lire_4 ; saisie du nombre 2
  • cmp tab1[7],1
  • jne suite4
  • cmp tab1[6],1
  • jne suite5
  • cmp tab1[5],1
  • jne suite6
  • mov al,tab1[4]
  • mov tab1[7],al
  • mov tab1[4],48
  • mov tab1[5],48
  • mov tab1[6],48
  • jmp suite4
  • suite6:
  • mov al,tab1[5]
  • mov tab1[7],al
  • mov al,tab1[4]
  • mov tab1[6],al
  • mov tab1[4],48
  • mov tab1[5],48
  • jmp suite4
  • suite5:
  • mov al,tab1[6]
  • mov tab1[7],al
  • mov al,tab1[5]
  • mov tab1[6],al
  • mov al,tab1[4]
  • mov tab1[5],al
  • mov tab1[4],48
  • suite4:
  • mov dl,10
  • mov ah,6
  • int 21h
  • mov dl,13
  • mov ah,6
  • int 21h
  • mov si,0 ; convertion de code ascii en decimal
  • mov cx,8
  • bouc2: sub tab1[si],48
  • mov al,tab1[si]
  • mov x_out[si],al
  • inc si
  • loop bouc2
  • cmp x,45
  • je sous
  • cmp x,43
  • je addi
  • cmp x,47
  • je divn
  • cmp x,42
  • je multip
  • addi: call addition
  • sous: call soustraction
  • divn: call division
  • multip: call multiplication
  • ;**********************
  • ;Procedure de la saisie
  • ;**********************
  • lire_4 proc
  • push cx
  • push ax
  • push dx
  • mov cx,0
  • debut:
  • mov dl,255
  • mov ah,6
  • int 21h
  • jz debut
  • cmp al,13
  • je fin1
  • cmp al,30h
  • js debut
  • cmp al,3ah
  • jns debut
  • mov [bx],al
  • inc bx
  • inc cx
  • cmp cx,5
  • jns debut
  • mov dl,al
  • mov ah,6
  • int 21h
  • jmp debut
  • fin1: pop dx
  • pop ax
  • pop cx
  • ret
  • lire_4 endp
  • fin:
  • mov dl,10 ;retour . la ligne
  • mov ah,6
  • int 21h
  • mov dl,10 ;retour . la ligne
  • mov ah,6
  • int 21h
  • mov dl,13 ; debut de la ligne
  • mov ah,6
  • int 21h
  • mov dl,10 ;retour . la ligne
  • mov ah,6
  • int 21h
  • mov dl,13 ; debut de la ligne
  • mov ah,6
  • int 21h
  • mov dx,offset revoir
  • mov ah,9
  • int 21h
  • mov dl,10 ;retour . la ligne
  • mov ah,6
  • int 21h
  • mov dl,13 ; debut de la ligne
  • mov ah,6
  • int 21h
  • mov ah,4ch
  • int 21h
  • end start
dosseg
.model	small
.stack	100h
.data
	x_out	db	8 dup (0)
	invite	db	13,10," Operation > $"
	espace	db	"   $"
	result	db	13,10," Resultat  > $"
	depas	db	13,10," Resultat  > 1$"

	titre	db	13,"                   ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»",13,10
		db	13,"                   º               CALCULATRICE            º",13,10
		db	13,"                   º              PROGRAMMEES PAR          º",13,10
		db	13,"                   ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹",13,10
		db	13,"                   º   Thameur BELGHITH  º  Fahima HAMDI   º",13,10
		db	13,"                   ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ",13,10
		db	13,"ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ",13,10,"$"


	tab1	db	8 dup (1)
	tab3	db	8 dup (0)
	ct	db	(0)
	x		db (0)
	y	db	(0)
	nbr1	dw	?
	nbr3	dw	2 dup (0)
	reste	db	13,10,"                   ==> Reste    = $"
	quot	db	13,10,"                   ==> Quotient = $",10,13
	revoir	db	"                                         	         	Au revoir ... ",13,10
		db	13,"ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ",13,10,10,"$"
	n	db	5 dup (0)
	m	db	5 dup	(0)
	l	db	5 dup	(0)
	k	db	5 dup	(0)
	c1 	db	 (0)

.code


	;**************************
	;Procedure pour l'affichage
	;**************************
	
affichage	proc	far	
affich:
	mov	dl,x_out[si]
	add	dl,48
	cmp	dl,48		;non affichage de zero
	jne	bou1
	jmp	o
bou1:	mov	ah,6
	int	21h
	mov	c1,5
	jmp	bou2
o:	cmp	c1,5
	je	bou1
bou2:	inc	si
	inc	cx
	cmp	cx,4
	pushf
	jne	w
	cmp	c1,0
	jne	w
	mov	dl,48
	mov	ah,6
	int	21h
w:	popf
	js	affich
	ret
	affichage	endp


		;**************************
		;Procedure pour la division
		;**************************
division	proc	far	
	mov	cx,0
	mov	cl,x_out[7]
	push	cx
	mov	al,x_out[6]
	mov	bl,10
	mul	bl
	pop	cx
	add	cx,ax
	push	cx
	mov	al,x_out[5]
	mov	bl,100
	mul	bl
	pop	cx
	add	cx,ax
	push	cx
	mov	ah,0
	mov	al,x_out[4]
	mov	bx,1000
	mul	bx
	pop	cx
	add	cx,ax
	mov	nbr1,cx
	mov	cx,0
	mov	cl,x_out[3]
	push	cx
	mov	al,x_out[2]
	mov	bl,10
	mul	bl
	pop	cx
	add	cx,ax
	push	cx
	mov	al,x_out[1]
	mov	bl,100
	mul	bl
	pop	cx
	add	cx,ax
	push	cx
	mov	ah,0
	mov	al,x_out[0]
	mov	bx,1000
	mul	bx
	pop	cx
	add	ax,cx
	mov	dx,0
	div	nbr1
	mov	nbr3[0],ax
	mov	nbr3[2],dx
	;******************************
	;conversion du quotient en hexa
	;******************************	
	mov	dx,0				
	mov	ax,nbr3[0]
	mov	bx,1000
	div	bx
	mov	m[0],al
	mov	ax,dx
	mov	bl,100
	div	bl
	mov	m[1],al
	mov	al,ah
	mov	ah,0
	mov	bl,10
	div	bl
	mov	m[2],al
	mov	m[3],ah
	;*******************
	;conversion du reste
	;*******************
	mov	dx,0					
	mov	ax,nbr3[2]
	mov	bx,1000
	div	bx
	mov	k[0],al
	mov	ax,dx
	mov	bl,100
	div	bl
	mov	k[1],al
	mov	al,ah
	mov	ah,0
	mov	bl,10
	div	bl
	mov	k[2],al
	mov	k[3],ah
	mov	dx,offset result
	mov	ah,09
	int	21h
	mov	dx,offset quot
	mov	ah,9
	int	21h
	mov	si,0
	mov	cx,0
	mov	c1,0
	;******************
	;affichage du reste
	;******************

affich0:mov	dl,m[si]
	add	dl,48
	
	cmp	dl,48	
	jne	aff
	jmp	affic
	mov	dl,10		;retour a la ligne
	mov	ah,6
	int	21h
	mov	dl,13			; debut de la ligne
	mov	ah,6
	int	21h
	
aff:	mov	ah,6
	int	21h
	mov	ct,5
	jmp	j0
affic:	cmp	ct,5
	je	aff
j0:	inc	si
	inc	cx
	cmp	cx,4
	pushf
	jne	jo10
	cmp	ct,0
	jne	jo10
	mov	dl,48
	mov	ah,6
	int	21h
	jmp	t
jo10:	popf
	js	affich0
t:	mov	dl,10		
	mov	ah,6
	int	21h
	mov	dl,13			
	mov	ah,6
	int	21h
	mov	dx,offset reste
	mov	ah,09
	int	21h
	
	mov	si,0		;affichage du reste
	mov	cx,0
	mov	ct,0
affich1:mov	dl,k[si]
	add	dl,48
	
	cmp	dl,48		
	jne	af00
	jmp	af100
	
af00:	mov	ah,6
	int	21h
	mov	ct,5
	jmp	j00
af100:	cmp	ct,5
	je	af00
j00:	inc	si
	inc	cx
	cmp	cx,4
	pushf
	jne	jo100
	cmp	ct,0
	jne	jo100
	mov	dl,48
	mov	ah,6
	int	21h
jo100:	popf
	js	affich1
	jmp	fin
	division	endp	





	;**********************
	;procedure soustraction
	;**********************
soustraction	proc far			
	
	mov	al,x_out[0]
	cmp	al,x_out[4]
	ja	positif
	jb	negatif
	mov	al,x_out[1]
	cmp	al,x_out[5]
	ja	positif
	jb	negatif
	mov	al,x_out[2]
	cmp	al,x_out[6]
	ja	positif
	jb	negatif
	mov	al,x_out[3]
	cmp	al,x_out[7]
	jae	positif
negatif:
	mov	x,10
	mov	si,0
	mov	di,4
	mov	cx,4
boucle:
	mov	bl,x_out[si]
	mov	al,x_out[di]
	mov	m[si],al
	mov	m[di],bl
	inc	si
	inc	di
loop	boucle
	positif:
	mov	al,x_out[7]
	sub	x_out[3],al
	pushf
	jnc	change0
	not	x_out[3]
	add	x_out[3],1
	mov	al,10
	sub	al,x_out[3]
	mov	x_out[3],al
change0:
	mov	al,x_out[6]
	popf
	sbb	x_out[2],al
	pushf
	jnc	change1
	not	x_out[2]
	add	x_out[2],1
	mov	al,10
	sub	al,m[2]
	mov	x_out[2],al
change1:
	mov	al,x_out[5]
	popf
	sbb	x_out[1],al
	pushf
	jnc	change2
	not	x_out[1]
	add	x_out[1],1
	mov	al,10
	sub	al,x_out[1]
	mov	x_out[1],al
change2:
	mov	al,x_out[4]
	popf
	sbb	x_out[0],al
	pushf
	jnc	change3
	not	x_out[0]
	add	x_out[0],1
	mov	al,10
	sub	al,x_out[0]
	mov	x_out[0],al
change3:
	mov	si,0
	mov	cx,0
	popf
	jnc	change4
change4:
	cmp	x,10
	jne	change5
	mov	dx,	offset result
	mov	ah,09
	int	21h
	mov	dl,45
	mov	ah,6
	int	21h
	call	affichage
	jmp	fin
change5:
	mov	dx,offset	result
	mov	ah,09
	int	21h
	mov	c1,0
	call	affichage
	jmp	fin
	soustraction	endp

	;*************************
	;Procedure pour l'addition
	;*************************
addition	proc	far				
	mov	al,x_out[7]
	add	x_out[3],al
	mov	al,x_out[3]
	mov	ah,0
	mov	cl,10
	div	cl
	mov	x_out[3],ah
	add	x_out[2],al
	
	mov	al,x_out[6]
	add	x_out[2],al
	mov	al,x_out[2]
	mov	ah,0
	mov	cl,10
	div	cl
	mov	x_out[2],ah
	add	x_out[1],al
	
	mov	al,x_out[5]
	add	x_out[1],al
	mov	al,x_out[1]
	mov	ah,0
	mov	cl,10
	div	cl
	mov	x_out[1],ah
	add	x_out[0],al
	
	mov	al,x_out[4]
	add	x_out[0],al
	mov	al,x_out[0]
	mov	ah,0				
	mov	cl,10
	div	cl
	mov	x_out[0],ah
	cmp	al,1
	je	dep
	jne	resl
dep:	mov	dx,offset depas
	mov	ah,09
	int	21h
	mov	si,0
	mov	cx,0
	mov	c1,0
	call	affichage
	jmp	fin
	
resl:
	mov	dx,offset result
	mov	ah,09
	int	21h
	
	mov	si,0
	mov	cx,0
	mov	c1,0
	call	affichage
	jmp	fin
	addition	endp




;******************************
;Procedure de la multiplication
;******************************
multiplication	proc	far	
	mov	si,4
a:
	mov	al,x_out[7]
	mov	bl,x_out[si-1]
	mul	bl
	mov	cl,10
	div	cl
	add	n[si],ah
	add	n[si-1],al
	dec	si
	cmp	si,0
	jne	a
	mov	si,4
b:
	mov	al,x_out[6]
	mov	bl,x_out[si-1]
	mul	bl
	mov	cl,10
	div	cl
	add	m[si],ah
	add	m[si-1],al
	dec	si
	cmp	si,0
	jne	b
	
	mov	si,4
c:
	mov	al,x_out[5]
	mov	bl,x_out[si-1]
	mul	bl
	mov	cl,10
	div	cl
	add	l[si],ah
	add	l[si-1],al
	dec	si
	cmp	si,0
	jne	c
	
	mov	si,4
d:
	mov	al,x_out[4]
	mov	bl,x_out[si-1]
	mul	bl
	mov	cl,10
	div	cl
	add	k[si],ah
	add	k[si-1],al
	dec	si
	cmp	si,0
	jne	d
	
	mov	al,n[4]
	add	tab3[7],al
	
	mov	al,0
	add	al,n[3]
	add	al,m[4]
	mov	ah,0
	mov	cl,10
	div	cl
	mov	tab3[6],ah
	
	add	al,n[2]
	add	al,m[3]
	add	al,l[4]
	mov	ah,0
	mov	cl,10
	div	cl
	mov	tab3[5],ah
	
	add	al,n[1]
	add	al,m[2]
	add	al,l[3]
	add	al,k[4]
	mov	ah,0
	mov	cl,10
	div	cl
	mov	tab3[4],ah
	
	add	al,n[0]
	add	al,m[1]
	add	al,l[2]
	add	al,k[3]
	mov	cl,10
	mov	ah,0
	div	cl
	mov	tab3[3],ah
	
	add	al,m[0]
	add	al,l[1]
	add	al,k[2]
	mov	cl,10
	mov	ah,0
	div	cl
	mov	tab3[2],ah
	
	add	al,l[0]
	add	al,k[1]
	mov	cl,10
	mov	ah,0
	div	cl
	mov	tab3[1],ah
	
	add	al,k[0]
	mov	tab3[0],al
	
	mov	dx,offset result
	mov	ah,09
	int	21h
	
	mov	si,0
	mov	cx,0
affichage1:
	mov	dl,tab3[si]
	add	dl,48
	cmp	dl,48		;pour eliminer les zeros
	jne	e
	jmp	f
e:	mov	y,5
	mov	ah,6
	int	21h
	jmp	comp
f:		cmp	y,5
	je	e
	comp:	inc	si
	inc	cx
	cmp	cx,8
	pushf
	jne	g
	cmp	y,0
	jne	g
	mov	dl,48
	mov	ah,6
	int	21h
g:	popf
	js	affichage1
	jmp	fin
	multiplication		endp

;****************************	
;debut de programme principal
;****************************	


start:	mov	ax,@data	
	mov	ds,ax
	mov	cx,5
bouc1:
	mov	dl,13			; debut de la ligne
	loop	bouc1
	mov	dx,offset titre
	mov	ah,9
	int	21h
	
	mov	dx,offset invite
	mov	ah,9
	int	21h
	lea	bx,tab1
	call	lire_4			;saisie de 1er nbre
	cmp	tab1[3],1
	jne	suite1
	cmp	tab1[2],1
	jne	suite2
	cmp	tab1[1],1
	jne	suite3
	mov	al,tab1[0]
	mov	tab1[3],al
	mov	tab1[0],30h
	mov	tab1[1],30h
	mov	tab1[2],30h
	jmp	suite1
suite3:
	mov	al,tab1[1]
	mov	tab1[3],al
	mov	al,tab1[0]
	mov	tab1[2],al
	mov	tab1[0],30h
	mov	tab1[1],30h
	jmp	suite1
suite2:
	mov	al,tab1[2]
	mov	tab1[3],al
	mov	al,tab1[1]
	mov	tab1[2],al
	mov	al,tab1[0]
	mov	tab1[1],al
	mov	tab1[0],48
suite1:
	mov	dx,offset espace
	mov	ah,09
	int	21h
debut1:
	mov	dl,255
	mov	ah,6
	int	21h
	cmp	al,45
	je	soust
	cmp	al,43
	je	addit
	cmp	al,47
	je	divvv
	cmp	al,42
	je	multi
	jmp	debut1
soust:
	mov	dl,45			;affichage de '-'
	mov	ah,6
	int	21h
	mov	x,45
	jmp	application
addit:
	mov	dl,43			;affichage de '+'
	mov	ah,6
	int	21h
	mov	x,43
	jmp	application
divvv:						;affichage de '/'
	mov	dl,47
	mov	ah,6
	int	21h
	mov	x,47
	jmp	application
multi:						;affichage de '*'
	mov	dl,42
	mov	ah,6
	int	21h
	mov	x,42
	jmp	application
	
	mov	dx,offset espace
	mov	ah,09
	int	21h
application:
						
	mov	dx,offset espace	
	mov	ah,09
	int	21h
	lea	bx,tab1
	add	bx,4
	call	lire_4			;  saisie du nombre 2
	cmp	tab1[7],1
	jne	suite4
	cmp	tab1[6],1
	jne	suite5
	cmp	tab1[5],1
	jne	suite6
	mov	al,tab1[4]
	mov	tab1[7],al
	mov	tab1[4],48
	mov	tab1[5],48
	mov	tab1[6],48
	jmp	suite4
suite6:
	mov	al,tab1[5]
	mov	tab1[7],al
	mov	al,tab1[4]
	mov	tab1[6],al
	mov	tab1[4],48
	mov	tab1[5],48
	jmp	suite4
suite5:
	mov	al,tab1[6]
	mov	tab1[7],al
	mov	al,tab1[5]
	mov	tab1[6],al
	mov	al,tab1[4]
	mov	tab1[5],al
	mov	tab1[4],48
suite4:
	mov	dl,10
	mov	ah,6
	int	21h
	mov	dl,13
	mov	ah,6
	int	21h
	mov	si,0		; convertion de code ascii en decimal
	mov	cx,8
bouc2:	sub	tab1[si],48
	mov	al,tab1[si]
	mov	x_out[si],al
	inc	si
	loop	bouc2
	cmp	x,45
	je	sous
	cmp	x,43
	je	addi
	cmp	x,47
	je	divn
	cmp	x,42
	je	multip
	
addi:	call	addition
	
sous:	call	soustraction
	
divn:	call	division
	
multip:	call	multiplication
	

	;**********************
	;Procedure de la saisie
	;**********************

lire_4	proc	
	push	cx
	push	ax
	push	dx
	mov	cx,0
	debut:
	mov	dl,255
	mov	ah,6
	int	21h
	jz	debut
	cmp	al,13
	je	fin1
	cmp	al,30h
	js	debut
	cmp	al,3ah
	jns	debut
	mov	[bx],al
	inc	bx
	inc	cx
	cmp	cx,5
	jns	debut
	mov	dl,al
	mov	ah,6
	int	21h
	jmp	debut
	
fin1:	pop	dx
	pop	ax
	pop	cx
	
	ret
	lire_4	endp

fin:
	mov	dl,10		;retour . la ligne
	mov	ah,6
	int	21h
	mov	dl,10		;retour . la ligne
	mov	ah,6
	int	21h
	mov	dl,13			; debut de la ligne
	mov	ah,6
	int	21h
	mov	dl,10		;retour . la ligne
	mov	ah,6
	int	21h
	mov	dl,13			; debut de la ligne
	mov	ah,6
	int	21h
	mov	dx,offset revoir
	mov	ah,9
	int	21h
	mov	dl,10		;retour . la ligne
	mov	ah,6
	int	21h
	mov	dl,13			; debut de la ligne
	mov	ah,6
	int	21h
	mov	ah,4ch
	int	21h
	

	
	end	start



 Sources de la même categorie

Source avec une capture AIRSTRIKE, JEU DE ‘SHOOT THEM UP’ EN ASSEMBLEUR par loudadyassine
LECTURE ET ECRITURE D'UN CARACTERE ET D'UNE CHAINE DE CARACT... par yasmus
Source avec Zip EN UTILISANT LES INTERRUPTIONS DE DOS , CECI EST UN CODE DE... par iltir_master
DÉCONCATÉNATION DE CHAÎNE SOUS MASM32V8 par Stormy
GENERIC WINDOWS XP URL DOWNLOAD AND EXECUTE SHELLCODE par theXman

Commentaires et avis

Commentaire de eedy31 le 03/09/2002 18:24:12

juste un truc.....pourkoi ya pratiquement personne ki se sert des api?!!?
Du style:pour convertir le code ASCII en decimal il y a l'api WSPRINTF
Et puis windows est plus sympa que DOS nan?
Bonne continuation et a plus!

Amicalement EEDY31

Commentaire de mab_corp le 20/12/2004 12:11:57

elle gère pas les soustraction négative??

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 3,182 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales