Sei sulla pagina 1di 14

PONTIFICIA UIVERSIDAD CATLICA DEL ECUADOR

SEDE IBARRA

1. DATOS INFORMATIVOS
1.1 Nombre: Luis Viteri
1.2 Carrera: Sistemas
1.3 Nivel: 5to
1.4 Tema: Compiladores
1.5 Fecha: 27/04/15
2. DESCRIPCION

INSTALACION EMU8086
1) Descargar de la pgina Oficial el programa http://emu8086.waxoo.com y ejecutar el
instalador

2) Next

3) Next

4) Dar un directorio o dejarlo por defecto

5) Click en Install

6) Launch the emulator

7) Interfaz

EJERCICIOS
1) Hola Mundo:

Cdigo:
name "hi-world"
; this example prints out "hello world!"
; by writing directly to video memory.
; in vga memory: first byte is ascii character, byte that follows is character attribute.
; if you change the second byte, you can change the color of
; the character even after it is printed.
; character attribute is 8 bit value,
; high 4 bits set background color and low 4 bits set foreground color.
; hex
;
;0
;1
;2
;3
;4
;5
;6
;7
;8
;9
;a
;b
;c
;d
;e

bin
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110

color
black
blue
green
cyan
red
magenta
brown
light gray
dark gray
light blue
light green
light cyan
light red
light magenta
yellow

;f

1111

white

org 100h
; set video mode
mov ax, 3 ; text mode 80x25, 16 colors, 8 pages (ah=0, al=3)
int 10h
; do it!
; cancel blinking and enable all 16 colors:
mov ax, 1003h
mov bx, 0
int 10h

; set segment register:


mov ax, 0b800h
mov ds, ax
; print "hello world"
; first byte is ascii code, second byte is color code.
mov [02h], 'H'
mov [04h], 'o'
mov [06h], 'l'
mov [08h], 'a'
mov [0ah], ' '
mov [0ch], 'M'
mov [0eh], 'u'
mov [10h], 'n'
mov [12h], 'd'
mov [14h], 'o'
mov [16h], '!'
mov [18h], '!'
; color all characters:
mov cx, 12 ; number of characters.
mov di, 03h ; start from byte after 'h'
c: mov [di], 10101000b ; light red(1100) on yellow(1110)
add di, 2 ; skip over next ascii code in vga memory.
loop c

; wait for any key press:


mov ah, 0
int 16h
ret

2) Programa 1: Compilar un programa en EMU8086 que indique lo siguiente:


Nombre completo del estudiante, Universidad, Fecha y materia.

Cdigo:
CODE SEGMENT
ASSUME CS:CODE, DS:CODE, SS:CODE, ES:CODE
ORG 100h
codigo:

mov ah, 0Fh


mov ah, 0
int 10h
lea dx, mensaje
mov ah, 9h
int 21h
int 20h
mensaje db "Luis Francisco Viteri Vinueza PUCE-SI 03/05/16 COMPILADORES $",0
CODE ENDS
end codigo

3) Programa 2: Compilar un programa que permita comparar 2 nmeros del 0 al 9.

Cdigo:
;URL
.model small
.stack
.data
var1 db ?
var2 db ?
msg1 db ' El primero es mayor $'
msg2 db ' El segundo es mayor$'
msg3 db ' Son iguales$'
msg4 db ' Primero numero $'
msg5 db ' Segundo numero $'

.code
.startup
mov ah,00h
mov al,03h
int 10h
mov ah,02h
mov dx,0510h
mov bh,0
int 10h

mov ah,09h
lea dx,msg4
int 21h
mov ah,07h
int 21h
mov ah, 02h
mov dl,al
int 21h
mov var1,al
mov ah,09h
lea dx,msg5
int 21h
mov ah,07h
int 21h
mov ah,02h
mov dl,al
int 21h
mov var2,al

cmp var1,al
ja mayor
jb menor
je igual
mayor:
mov ah,09h
lea dx,msg1
int 21h
jmp salir
menor:

mov ah,09h
lea dx,msg2
int 21h
jmp salir
igual:
mov ah,09h
lea dx,msg3
int 21h
jmp salir

salir:
.exit
end

4) Programa 3: Compilar un programa que permita sumar 10 valores asignados a un

vector.

Cdigo:
name "calc-sum"

org 100h ; directive make tiny com file.

; calculate the sum of elements in vector,

; store result in m and print it in binary code.

; number of elements:
mov cx, 10

; al will store the sum:


mov al, 0

; bx is an index:
mov bx, 0

; sum elements:
next: add al, vector[bx]

; next byte:
inc bx

; loop until cx=0:


loop next

; store result in m:
mov m, al

; print result in binary:


mov bl, m
mov cx, 8
print: mov ah, 2 ; print function.
mov dl, '0'
test bl, 10000000b ; test first bit.
jz zero
mov dl, '1'

zero: int 21h


shl bl, 1
loop print
; print binary suffix:
mov dl, 'b'
int 21h

mov dl, 0ah ; new line.


int 21h
mov dl, 0dh ; carrige return.
int 21h

; print result in decimal:


mov al, m
call print_al

; wait for any key press:


mov ah, 0
int 16h

ret

; variables:
vector db 5, 4, 5, 2, 1, 6, 8, 1, 2, 6
m db 0

print_al proc
cmp al, 0
jne print_al_r
push ax
mov al, '0'
mov ah, 0eh
int 10h
pop ax
ret
print_al_r:
pusha
mov ah, 0
cmp ax, 0
je pn_done
mov dl, 10
div dl
call print_al_r
mov al, ah
add al, 30h
mov ah, 0eh
int 10h
jmp pn_done
pn_done:
popa
ret
endp

Potrebbero piacerti anche