Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;S.C.1 2012 - Prof. Diego Corsi
- ;T.P. #7 - Programaci�n NASM #1
- ;
- ;1� en consola de NASM:
- ; nasm -f win32 c:\TP7-1.asm --PREFIX _
- ;
- ;2� en consola de Visual Studio:
- ; link /out:c:\TP7-1.exe c:\TP7-1.obj libcmt.lib
- ; c:\TP7-1
- ;
- ;#1. Dado un entero N, tal que 0 < N < 11,
- ; la computadora muestra la tabla de multiplicar de N.
- global main
- global _start
- extern printf
- extern scanf
- extern exit
- extern gets
- section .bss
- numero:
- resd 1
- numero2:
- resd 1
- cadena:
- resb 0x0100
- caracter:
- resb 1
- resb 3
- section .data
- encabezado:
- db "S.C.1 2012 - Prof. Diego Corsi", 0
- trabajo:
- db "T.P. #7 - Programacion NASM #1", 0
- enunciado:
- db "#1. Ingrese un entero N, tal que 0 < N < 11, la computadora muestra la tabla de multiplicar de N : ", 0
- multiplicacion:
- db " x ", 0
- igual:
- db " = ", 0
- fmtInt:
- db "%d", 0
- fmtString:
- db "%s", 0
- fmtChar:
- db "%c", 0
- fmtLF:
- db 0xA, 0
- section .text
- leerCadena:
- push cadena
- call gets
- add esp, 4
- ret
- leerNumero:
- push numero
- push fmtInt
- call scanf
- add esp, 8
- ret
- mostrarCadena:
- push cadena
- push fmtString
- call printf
- add esp, 8
- ret
- mostrarNumero:
- push dword [numero]
- push fmtInt
- call printf
- add esp, 8
- ret
- mostrarNumero2:
- push dword [numero2]
- push fmtInt
- call printf
- add esp, 8
- ret
- mostrarCaracter:
- push dword [caracter]
- push fmtChar
- call printf
- add esp, 8
- ret
- mostrarSaltoDeLinea:
- push fmtLF
- call printf
- add esp, 4
- ret
- salirDelPrograma:
- push 0
- call exit
- _start:
- main:
- call mostrarSaltoDeLinea
- push encabezado
- call printf
- add esp, 4
- call mostrarSaltoDeLinea
- push trabajo
- call printf
- add esp, 4
- call mostrarSaltoDeLinea
- call mostrarSaltoDeLinea
- push enunciado
- call printf
- add esp, 4
- call leerNumero
- mov ax, [numero]
- cmp ax, -1
- jle salirDelPrograma
- mov bx, 1
- call mostrarSaltoDeLinea
- ciclo:
- div bx
- mov [numero2], ah
- mov ax, [numero2]
- cmp ax, 0
- je mostrarDivisor
- jmp seguirCiclo
- seguirCiclo
- inc bx
- mov ax, [numero]
- cmp bx, ax
- je salirDelPrograma
- jmp ciclo
- mostrarDivisor:
- call mostrarNumero2
- call mostrarSaltoDeLinea
- jmp seguirCiclo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement