Instalacion emu8086 y Ejercicios

download Instalacion emu8086 y Ejercicios

of 14

Transcript of Instalacion emu8086 y Ejercicios

  • 8/17/2019 Instalacion emu8086 y Ejercicios

    1/14

    PONTIFICIA UIVERSIDAD CATÓLICA 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/152. DESCRIPCION

    INSTALACIONEMU8086

     

    1)  Descargar de la página Oficial el programa http://emu8086.waxoo.com y ejecutar el

    instalador

  • 8/17/2019 Instalacion emu8086 y Ejercicios

    2/14

     

    2)  Next

    3)  Next

  • 8/17/2019 Instalacion emu8086 y Ejercicios

    3/14

     

    4)  Dar un directorio o dejarlo por defecto

  • 8/17/2019 Instalacion emu8086 y Ejercicios

    4/14

    5)  Click en Install

    6)  Launch the emulator

  • 8/17/2019 Instalacion emu8086 y Ejercicios

    5/14

    7)  Interfaz

  • 8/17/2019 Instalacion emu8086 y Ejercicios

    6/14

    EJERCICIOS

     

    1)  Hola Mundo:

    Código: 

    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 bin color

    ;

    ; 0 0000 black

    ; 1 0001 blue

    ; 2 0010 green

    ; 3 0011 cyan

    ; 4 0100 red

    ; 5 0101 magenta

    ; 6 0110 brown; 7 0111 light gray

    ; 8 1000 dark gray

    ; 9 1001 light blue

    ; a 1010 light green

    ; b 1011 light cyan

    ; c 1100 light red

    ; d 1101 light magenta

    ; e 1110 yellow

  • 8/17/2019 Instalacion emu8086 y Ejercicios

    7/14

    ; 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

  • 8/17/2019 Instalacion emu8086 y Ejercicios

    8/14

     

    ; 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.

    Código: 

    CODE SEGMENT

    ASSUME CS:CODE, DS:CODE, SS:CODE, ES:CODE

    ORG 100h

    codigo:

  • 8/17/2019 Instalacion emu8086 y Ejercicios

    9/14

    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 números del 0 al 9. 

    Código: 

    ;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 $'

  • 8/17/2019 Instalacion emu8086 y Ejercicios

    10/14

     

    .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:

  • 8/17/2019 Instalacion emu8086 y Ejercicios

    11/14

      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.

    Código: name "calc-sum"

    org 100h ; directive make tiny com file.

    ; calculate the sum of elements in vector,

  • 8/17/2019 Instalacion emu8086 y Ejercicios

    12/14

    ; 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'

  • 8/17/2019 Instalacion emu8086 y Ejercicios

    13/14

    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

  • 8/17/2019 Instalacion emu8086 y Ejercicios

    14/14

     

    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