Matrices Emu8086

msg db 13,’ - -',13,10, matriz',13,10, ' - -',10,10,10,'$' supeinf db 13,'----- ----- -----$' lados db 10,13,' | | | |',

Views 86 Downloads 0 File size 371KB

Report DMCA / Copyright

DOWNLOAD FILE

Recommend stories

Citation preview

msg db 13,’ - -',13,10, matriz',13,10, ' - -',10,10,10,'$' supeinf db 13,'----- ----- -----$' lados db 10,13,' | | | |',10,13,' | | | |',10,'$' v1 db ? v2 db ? ite db ? sig db } resultado db ? resultado_div dw rd db ? dist db ? reg db ? col db ? ban_neg db ? resp_des db ? opciones db :',10,10,10,13,'+(suma) - (resta) * (multiplicación) / (división)$ opciones_c_c db ' INGRESAR SIGNO:',10,10,10,13,' + (suma) - (resta) * (multiplicación)$ borr_opciones db ' ',10,10,10,13,'$ .code inicio: mov ah,00h mov al,03h int 10h presentacion titulo, msg, supeinf, lados mov resp_des, ' ' mov ite, 3 mov sig, ' ' ciclo cmp resp_des, 'b' je lnkinicio cmp resp_des, 'B' je lnkinicio jmp fin lnkinicio: jmp inicio fin: mov ah, 4ch int 21h end .model small .stack .data presentacion MACRO a, b, c, d mov ax,@data mov ds, ax mov ah, 09h lea dx, a int 21h lea dx, b int 21h mov cx, 3 impmat: mov ah, 09h lea dx, c int 21h lea dx, d int 21h lea dx, c int 21h LOOP impmat mov ah, 03h mov bh, 00 int 10h mov ah, 02h mov cx, 8 ubpripos: dec dh; fila LOOP ubpripos mov cx, 16

ubsegpos: dec dl; columna LOOP ubsegpos int 10h ENDM impresion_opciones MACRO e, f cmp v2, 0 je imp_msg1 jmp imp_msg2 imp_msg1: mov ah, 02h mov dh, 14h mov dl, 0h int 10h mov ah, 09h lea dx, e int 21h jmp finmac imp_msg2: mov ah, 02h mov dh, 14h mov dl, 0h int 10h mov ah, 09h lea dx, f int 21h jmp finmac finmac: ENDM borrado_opciones MACRO g mov ah, 02h mov dh, 14h mov dl, 0h int 10h mov ah, 09h lea dx, g int 21h ENDM ciclo MACRO proceso: lecturanum 1 rev_des ubiposcur 4 lecturanum 2 rev_des impresion_opciones opciones_c_c, opciones cmp ite, 3 je priimp jmp segimp priimp: ubiposcur2 15,25 operaciones rev_des borrado_opciones borr_opciones ubiposcur2 15,25 aco_pri_col jmp rev segimp: cmp ite, 2 je segimp2 jmp terimp segimp2: ubiposcur2 12,25 operaciones rev_des borrado_opciones borr_opciones ubiposcur2 12,25 aco_pri_col jmp rev terimp: cmp ite, 1

je terimp2 jmp rev terimp2: ubiposcur2 9, 25 operaciones rev_des borrado_opciones borr_opciones ubiposcur2 9,23 jmp rev rev: dec ite cmp ite, 0 je pre_salida jmp proceso pre_salida: mov ah, 2ch int 21h mov al, 3 mov bl, dh add bl, al ret_esp: mov ah, 2ch int 21h cmp dh, bl je cont_pro2 jmp ret_esp cont_pro2: mov al, 'b' mov resp_des, al salida: ENDM lecturanum MACRO posc LOCAL prifase, numero, err1, err2, lnkfnum, gnum, gev1, gev2, chksig, chksig2, mulneg, mulneg2 , fnum prifase: mov ah, 03h int 10h mov col, dl mov ah, 01h int 21h mov sig, al cmp al, '-' je numero cmp al, ' ' je numero cmp al, 'e' je lnkfnum cmp al, 'E' je lnkfnum cmp al, 'b' je lnkfnum cmp al, 'B' je lnkfnum jmp err1 err1: mov ah, 02h int 10h ubiposcur 4 mov ah, 02h mov dl, '|' int 21h mov dl, col mov ah, 02h int 10h mov ah, 02h mov dl, ' ' int 21h mov dl, 08h int 21h jmp prifase lnkfnum:

mov resp_des, al jmp fnum numero: mov ah, 03h int 10h mov col, dl mov ah, 01h int 21h cmp al, '0' je gnum cmp al, '1' je gnum cmp al, '2' je gnum cmp al, '3' je gnum cmp al, '4' je gnum cmp al, '5' je gnum cmp al, '6' je gnum cmp al, '7' je gnum cmp al, '8' je gnum cmp al, '9' je gnum cmp al, 'e' je lnkfnum cmp al, 'E' je lnkfnum cmp al, 'b' je lnkfnum cmp al, 'B' je lnkfnum jmp err2 err2: mov ah, 02h int 10h ubiposcur 3 mov ah, 02h mov dl, '|' int 21h mov dl, col mov ah, 02h int 10h mov ah, 02h mov dl, ' ' int 21h mov dl, 08h int 21h jmp numero gnum: sub al, 30h mov bl, posc cmp bl, 1 je gev1 jmp gev2 gev1: mov v1, al jmp chksig gev2: mov v2, al jmp chksig2 chksig: cmp sig, '-' je mulneg jmp fnum chksig2: cmp sig, '-'

je mulneg2 jmp fnum mulneg: mov al, -1 and ah,00h imul v1 mov v1, al jmp fnum mulneg2: mov al, -1 and ah,00h imul v2 mov v2, al jmp fnum fnum: ENDM rev_des MACRO LOCAL lnksal, fin_rev_des cmp resp_des, 'e' je lnksal cmp resp_des, 'E' je lnksal cmp resp_des, 'b' je lnksal cmp resp_des, 'B' je lnksal jmp fin_rev_des lnksal: jmp salida fin_rev_des: ENDM ubiposcur MACRO colm mov ah, 03h int 10h sigreg = colm mov ah, 02h REPT sigreg inc dl ENDM int 10h ENDM ubiposcur2 MACRO fila, columna mov ah, 03h int 10h mov ah, 02h acf = fila REPT acf dec dh ENDM ach = columna REPT ach dec dl ENDM int 10h ENDM aco_pri_col MACRO mov ah, 03h int 10h mov ah, 02h acf1 = 3 REPT acf1 inc dh ENDM ach1 = 13 REPT ach1 dec dl ENDM int 10h ENDM operaciones MACRO LOCAL lec_sig_ope, ope_s_d, funsuma, funresta, funmultiplicacion, fundivision, error, lnk_fin

_ope, suma, resta, multiplicacion,mult_c_s, mult_normal, cont_pro, filtro, division, mulneg1, mulneg2, d ivi, filtro2, cam_neg, cam_sig, cambio , err3, fin_ope lec_sig_ope: mov ah, 03h int 10h mov col, dl mov ah, 01h int 21h cmp v2, 0 je ope_s_d cmp al, '+' je funsuma cmp al, '-' je funresta cmp al, '*' je funmultiplicacion cmp al, '/' je fundivision cmp al,'e' je lnk_fin_ope cmp al,'E' je lnk_fin_ope cmp al,'b' je lnk_fin_ope cmp al,'B' je lnk_fin_ope cmp al, 0Dh je error jmp err3 lnk_fin_ope: mov resp_des, al jmp fin_ope ope_s_d: cmp al, '+' je funsuma cmp al, '-' je funresta cmp al, '*' je funmultiplicacion cmp al,'e' je lnk_fin_ope cmp al,'E' je lnk_fin_ope cmp al,'b' je lnk_fin_ope cmp al,'B' je lnk_fin_ope cmp al, 0Dh je error jmp err3 funsuma: jmp suma funresta: jmp resta funmultiplicacion: jmp multiplicacion fundivision: jmp division error: jmp err3 suma: mov ah, 02h int 10h mov ah, 02h mov dl, ' ' int 21h mov dl, 08h int 21h mov ah, 03h int 10h

mov reg, dh mov col, dl mov bl,v1 mov al,v2 add bl,al mov resultado, bl imp_resultado jmp fin_ope resta: mov int mov mov int mov int

ah, 10h ah, dl, 21h dl, 21h

02h 02h ' ' 08h

mov ah, 03h int 10h mov reg, dh mov col, dl

mov bl,v1 mov al,v2

sub bl,al mov resultado, bl imp_resultado jmp fin_ope

multiplicacion: mov ah, 02h int 10h mov ah, 02h mov dl, ' ' int 21h mov dl, 08h int 21h mov ah, 03h int 10h mov reg, dh mov col, dl

mov bl,v1 mov al,v2

and ah,00h cmp v1, 0 jl mult_c_s jmp filtro

mult_c_s: imul bl jmp cont_pro

filtro: cmp v2, 0 jl mult_c_s jmp mult_normal

mult_normal: mul bl jmp cont_pro

cont_pro:

mov resultado, al imp_resultado jmp fin_ope

division:

mov ah, 02h int 10h mov ah, 02h mov dl, ' ' int 21h mov dl, 08h int 21h mov ah, 03h int 10h mov reg, dh mov col, dl

cmp v1, 0 jl mulneg1 mov ban_neg, 0 jmp filtro2

mulneg1: mov ban_neg, 1 mov al, -1 and ah, 00h mov bl, v1 imul bl mov v1, al

jmp filtro2

filtro2: cmp v2, 0 jl mulneg2 cmp ban_neg, 1 je cam_neg mov ban_neg, 0 cam_neg: jmp divi

mulneg2: cmp ban_neg, 1 je cam_sig mov ban_neg, 1 jmp cambio

cam_sig: mov ban_neg, 0 jmp cambio

cambio: mov al, -1 and ah, 00h mov bl, v2 imul bl mov v2, al

jmp divi

divi: mov bl, v1 mov al, v2

and ah, 00h and bh, 00h

xchg ax, bx cwd div bx mov resultado_div, ax

imp_divi

jmp fin_ope

err3: mov ah, 02h int 10h ubiposcur 4 mov ah, 02h mov dl, '|' int 21h mov dl, col

mov ah, 02h int 10h mov ah, 02h mov dl, ' ' int 21h mov dl, 08h int 21h jmp lec_sig_ope

fin_ope: ENDM

; MACRO QUE IMPRIME EL RESULTADO DE LA SUMA, RESTA O MULTIPLICACIÓN

imp_resultado MACRO LOCAL m9, m0, normal, separ, division, n_imp_res, fimp_resultado cmp resultado,9 jg m9 cmp resultado,0 jl m0 jmp normal

m9: mov bl,resultado mov al,10 and ah,00h and bh,00h xchg ax,bx cwd div bx mov bx,ax mov rd,dl

mov ah, 02h mov dl, ' ' int 21h mov ah,02h mov add int mov add int

dx,bx dl,30h 21h dl,rd dl,30h 21h

jmp fimp_resultado

m0: mov al, -1 and ah,00h imul resultado

mov resultado, al cmp resultado,10 jl separ mov mov mov jmp

bl,resultado al,10 dist, 2 division

separ: mov bl,resultado mov al,1 mov dist, 1

division: and ah,00h and bh,00h xchg ax,bx cwd div bx mov bx,ax mov rd,dl mov dh, reg mov dl, col

mov ah, 02h int 10h mov ah, 02h mov int mov add

dl, '-' 21h dx,bx dl,30h

int 21h cmp dist,1 je n_imp_res mov dl,rd add dl,30h int 21h

n_imp_res:

mov al, -1 and ah,00h imul resultado

mov resultado, al

jmp fimp_resultado

normal:

mov ah, 02h mov dl, ' ' int 21h

mov ah,02h mov dl,resultado add dl, 30h int 21h jmp fimp_resultado

fimp_resultado:

ENDM

; MACRO QUE IMPRIME EL RESULTADO DE LA DIVISIÓN imp_divi MACRO LOCAL imp_resneg, fin_imp_divi

cmp ban_neg, 1 je imp_resneg

mov ah, 02h mov int mov add int

dl, ' ' 21h dx, resultado_div dl, 30h 21h

jmp fin_imp_divi

imp_resneg:

mov ah, 02h mov int mov int mov add int

dl, 21h dl, 21h dx, dl, 21h

' ' '-' resultado_div 30h

mov ax, -1 and ah, 00h imul bx mov resultado_div, ax

jmp fin_imp_divi

fin_imp_divi:

mov ban_neg, 3

ENDM