Division en ensamblador
Publicado por Yael A Perez H (1 intervención) el 19/09/2019 04:50:52
Buenas noches, necesito su ayuda con un código, se deben ingresar 5 números por medio de un loop, sumarlos y luego dividir el resultado entre 5
Mi código fuente es el siguiente
Mi código fuente es el siguiente
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
.model small
.stack
.data
n1 db 0
n2 db 0
numdiv db 5
division db 0
welc db 10,13,7, 'Suma 5 numeros, divide entre 5 ','$'
msg0 db 10,13,7, 'Ingresa el numero: ','$'
msg2 db 10,13,7, 'Resultado: ','$'
msg3 db 10,13,7, 'Ingresa el numero 5: ','$'
.code
.startup
mov cx,5 ;Contador
mov si,0
mov ah,09h
lea dx,welc
int 21h
leer0:
mov ah,09h
lea dx,msg0
int 21h
mov ah,01h
int 21h
sub al,30h
mov n1,al
add n2,al
add al,n2
loop leer0
;Dividir
div numdiv
mov division,al
;Imprimir resultado decimal
mov ah, 09h
lea dx, msg2
int 21h
mov al,division
AAM
mov bx,ax
mov ah,02h
mov dl,bh
add dl,30h
int 21h
mov ah,02h
mov dl,bl
add dl,30h
int 21h
mov ah,4ch
int 21h
mov ah,4ch
int 21h
end
Valora esta pregunta


0