; You may customize this and other start-up templates;
; The location of this template is c:\emu8086\inc\0_com_template.txt
;Eduardo Pablo Aquino Sanchez
org 100h
multi macro chra,chrb,chrx,chr3,chr2,chr1
mov al,chra ;al = chr4
mov bl,chrb ;bl = chr2
mul bl ;AL = chr3*chr2 (BL*AL)
mov Ah,0h ;
AAM ;ASCII Adjusment
mov ac,AH ;ac = AH (Acarreo)
mov r2,AL ;r2 = AL (Unidad del resultado)
mov al,chra ;AL = chr4
mov bl,chrx ;BL = chr1
mul bl ;AL = chr1*chr3 (BL*AL)
mov r1,al ;r1 = AL (Decena del resultado)
mov bl,ac ;BL = Acarreo anterior
add r1,bl ;r1 = r1+ac (r1 + Acarreo)
mov ah,00h ;
mov al,r1 ;AL = r1 (Asignaci?n para el ajust)
AAM ;ASCII Adjustment
mov r1,al ;r1 = AL
mov ac,ah ;ac = AH (Acarreo para la Centena del resultado)
mov al,chr3 ;al = chr3
mov bl,chr2 ;bl = chr2
mul bl ;AL = chr3*chr2 (BL*AL)
AAM ;ASCII Adjusment
mov ac2,AH ;ac2 = AH (Acarreo)
mov r4,AL ;r4 = AL (Unidad del resultado)
mov al,chr3 ;AL = chr3
mov bl,chr1 ;BL = chr1
mul bl ;AL = chr1*chr3 (BL*AL)
mov r3,al ;r3 = AL (Decena del resultado)
mov bl,ac2 ;BL = Acarreo anterior
add r3,bl ;r3 = r1+ac (r1 + Acarreo)
mov ah,00h ;
mov al,r3 ;AL = r3(Asignaci?n para el ajust)
AAM ;ASCII Adjustment
mov r3,al ;r3 = AL
mov ac2,ah ;ac2 = AH (Acarreo para la Centena del resultado)
endm
suma macro r1_,r4_,ac_,r3_,ac2_
mov al,r1_;=9 ;99
mov bl,r4_;=1 ;x99
add al,bl ;----------------
aAm ;891
mov r1,al;=00 ;891
mov r4,ah;=01 ;------------------------
; 8901
mov al,ac_;=8
mov bl,r3_;=9
add al,bl
add al,r4
aAm
mov ac,al;=8
mov r3,ah;=1
mov al,ac2_;=8
mov bl,r3;=1
add al,bl
aAm
mov ac2,al;=09
mov r3,ah;=0
endm
imprime macro ac2_,ac_,r1_,r2_
mov ah,02h
mov dl,ac2_
add dl,30h
int 21h ;Mostramos ac (millar)
mov ah,02H
mov dl,ac_
add dl,30h
int 21h ;Mostramos r1 (centena)
mov ah,02H
mov dl,r1_
add dl,30h
int 21h ;Mostramos r2 (decena)
mov ah,02H
mov dl,r2_
add dl,30h
int 21h ;Mostramos r2 (Unidad)
endm
.model small ;Modelo de memoria m?s utilizado
.stack
.data ;definición de datos(variables), donde se almacenara información
chr1 db ?
chr2 db ?
chr3 db ?
chr4 db ?
r1 db ?
r2 db ?
r3 db ?
r4 db ?
ac db 0
ac2 db 0
aca db 0
aca2 db 0
.code
.startup
mov ax,@data ;almacenamos lo que esta en el segento data
mov ds,ax ;movemos ax a ds
mov ah,00h ;Function(Set video mode)
mov al,03 ;Mode 80x25 8x8 16
int 10h ;Interruption Video
mov ah,01h ;Function(character read)
int 21h ;Interruption DOS functions
sub al,30h ;ajustamos valores
mov chr1,al ;[chr1].chr2 * chr3 = ac.r1.r2
mov ah,01h ;Function(character read)
int 21h ;Interruption DOS functions
sub al,30h ;Ajustamos valores
mov chr2,al ;chr1.[chr2] * chr3 = ac.r1.r2
mov ah,02h ;Function(character to send to standard output)
mov dl,'*' ;Character to show
int 21h
mov ah,01h ;Function(Read character)
int 21h ;Interruption DOS Functions
sub al,30h ;Transform(0dec = 30hex)
mov chr3,al ;chr1.chr2 * [chr3] = ac.r1.r2
mov ah,01h ;Function(Read character)
int 21h ;Interruption DOS Functions
sub al,30h ;Transform(0dec = 30hex)
mov chr4,al ;chr1.chr2 * [chr3] = ac.r1.r2
mov ah,02h ;Character to send to standar output
mov dl,'=' ;
int 21h ;Interruption DOS functions
;Realizamos operaci?n
;parte 1 multiplicar
multi chr4,chr2,chr1,chr3,chr2,chr1
;parte 3 Suma de los resultados
suma r1,r4,ac,r3,ac2
;Mostramos resultado
imprime ac2,ac,r1,r2
.exit
end