ADMINISTRACION DE BASE DE DATOS

jueves, 7 de marzo de 2019

UNIDAD II: EJERCICIO CON SALTOS CONDICIONALES

PROGRAMA QUE REALIZA UNA COMPARACIÓN DE 3 TIPOS DE CASOS, EN LOS QUE EVALÚA 2 NÚMEROS, YA SEA SI UNO ES MAYOR, MENOR O SI EN DADO CASO RESULTAN SER IGUALES.





INCLUDE "emu8086.inc"
org 100h

.MODEL SMALL
.STACK
.DATA

    NUM1 db 8
    NUM2 db 4
    MSG1 DB "NUMEROS IGUALES $"
    MSG2 DB "NUMERO 1 ES MAYOR $"
    MSG3 DB "NUMERO 2 ES MAYOR $"
    
.CODE
    Main:    
    MOV AX, @DATA
    
    MOV DS, AX
    
    MOV AL, NUM1
    
    CMP AL, NUM2
    
    JC MAYOR2
    JZ IGUAL
    JNZ MAYOR1

.EXIT


igual:
    printn "Son iguales"  
    JMP FIN  
    .exit
    
Mayor1:

    printn "Es mayor el numero 1"
    JMP FIN
    .exit
    
Mayor2:
    
    printn "Es mayor el numero 2"
    JMP FIN
    .exit
    
FIN:
    
    printn "fin"
    .exit

UNIDAD II BRINCOS INCONDICIONALES

EJEMPLO DE UN PROGRAMA CON BRINCO INCONDICIONAL



org    100h

mov    ax, 5          ; set ax to 5. 
mov    bx, 2          ; set bx to 2. 

jmp    calc            ; go to 'calc'. 

back:  jmp stop      ; go to 'stop'. 

calc:
add    ax, bx         ; add bx to ax. 
jmp    back           ; go 'back'. 

stop:

ret                   ; return to operating system.




La instrucción básica que transfiere el control a otro punto del programa es JMPComo puede ver en este ejemplo, JMP puede transferir el control hacia adelante y hacia atrás. Puede saltar a cualquier lugar en el segmento de código actual.




Generalmente, cuando se requiere comparar valores numéricos, se usa la instrucción CMP (hace lo mismo que la instrucción SUB (restar), pero no mantiene el resultado, solo afecta a los indicadores). 

EJEMPLO DE INSTRUCCIÓN CMP Y SALTO CONDICIONAL


include "emu8086.inc"

org    100h

mov    al, 25     ; set al to 25. 
mov    bl, 10     ; set bl to 10. 

cmp    al, bl     ; compare al - bl. 

je     equal      ; jump if al = bl (zf = 1). 

putc   'n'        ; if it gets here, then al <> bl, 
jmp    stop       ; so print 'n', and jump to stop. 

equal:            ; if gets here, 
putc   'y'        ; then al = bl, so print 'y'. 

stop:

ret               ; gets here no matter what.

martes, 5 de marzo de 2019

INCLUYENDO LA LIBRERIA emu8086.inc

A continuación se mostraran ejemplos fáciles de analizar y comprender de como se puede hacer uso de la librería emu8086.Inc y sus diferentes macros:

1.  Mensaje "Hola mundo"




Haciendo uso del macro print, el cual nos permite mostrar un mensaje en pantalla de una manera distinta a como en un inicio del curso aprendimos. 


org 100h

name 'hola mundo'
include 'emu8086.inc'

org 100h

   
.code  
print " "
print "hola mundo"



2.  Usando el macro goto x, y



Aquí podemos encontrar que en sí, el código ha sido el mismo, con la diferencia de que le hemos agregado la instrucción "goto x, y", que como ya se ha mencionado es un macro perteneciente a la librería emu8086.inc, que nos permite colocar una posición al mensaje. En este caso la x marca las filas y la y las columnas.




org 100h

name 'hola mundo'
include 'emu8086.inc'

org 100h

   
.code  
gotoxy 5,5
print "hola mundo" 


ret