Programa 1: Demostración de códigos.
Código:
include "emu8086.inc" org 100h .data mensaje1 db 13,10,"print_string imprime un mensaje guardado en el registro SI",0 .code print "Print muestra un mensaje en pantalla" lea si,mensaje1 call print_string gotoxy 6,6 ;esto mueve el cursor a la posicion deseada print "GOTOXY mueve el cursor a la posicion deseada" gotoxy 6,7 print "scan_num solicita un valor por teclado, este se guarda en cl: " call scan_num xor ax,ax mov al,cl gotoxy 6,8 print "print_num imprime en pantalla el valor numerico de al: " call print_num gotoxy 6,9 print "Putc imprime un solo caracter: " putc "a" define_print_num define_scan_num define_print_num_uns define_print_string end
Programa 2: Hello World
Código:
include emu8086.inc ORG 100h PRINT 'Hello World!' GOTOXY 10, 5 PUTC 65 ; 65 - is an ASCII code for 'A' PUTC 'B' RET ; return to operating system. END ; directive to stop the compiler.
Resultado:
Programa 3: Demostracion del uso print_string y get_string
Código:
; demonstrate get_string and print_string
;----------------------------------------
include 'emu8086.inc'
ORG    100h
LEA    SI, msg1       ; set up pointer (SI) to msg
                      ; to ask for the number
CALL   print_string   ; print message that SI points to
LEA    DI, buffer     ; set up pointer (DI) to input buffer
MOV    DX, bufSize    ; set size of buffer
CALL   get_string     ; get name & put in buffer
LEA    SI, newln      ; point at CR/LF / Hello message 
CALL   print_string   ; print message that SI points to
RET                   ; return to operating system.
; data
msg1   DB "Enter your name: ", 0  
newln  DB 13, 10
       DB "Hello, "
buffer DB 20 DUP (0)  ; input buffer for get_string   
bufSize = $-buffer    ; calculates size of buffer
DEFINE_GET_STRING
DEFINE_PRINT_STRING
END                   ; directive to stop the compiler.
Resultado:
Programa 4: Uso scan_num, print_num, pthis
Código:
; demonstrate scan_num, print_num, pthis ;---------------------------------------- include 'emu8086.inc' ORG 100h LEA SI, msg1 ; ask for the number CALL print_string ; CALL scan_num ; get number in CX. MOV AX, CX ; copy the number to AX. ; print the following string: CALL pthis DB 13, 10, 'You have entered: ', 0 CALL print_num ; print number in AX. RET ; return to operating system. ; data msg1 DB 'Enter the number: ', 0 ; macros to define procs DEFINE_SCAN_NUM DEFINE_PRINT_STRING DEFINE_PRINT_NUM DEFINE_PRINT_NUM_UNS ; required for print_num. DEFINE_PTHIS END ; directive to stop the compiler.Resultado:
Programa 5: hola mundo uso de gotoxy
Código:
name 'hola mundo' include 'emu8086.inc' org 100h .code gotoxy 5,5 printn "hola mundo" gotoxy 5,6 printn "hola mundo 2" gotoxy 5,7 print "dame un numero:" call scan_num define_scan_num putc "A" ret
Resultado:
Programa 6: hola mundo gotoxy- imprime número
Código:
include 'emu8086.inc' org 100h .code Cursoroff ;apaga el cursor call scan_num ;pide un numero define_scan_num ;define la funcion gotoxy 2,5 putc 'A' ;imprime un solo caracter gotoxy 5,7 ;define en donde se ira a la pantalla print 'dame un numero: ' call scan_num mov ax,cx gotoxy 5,8 call print_num define_print_num define_print_num_uns end ret
Resultado:
Referencia:
http://jbwyatt.com/253/emu/asm_tutorial_05.html
No hay comentarios:
Publicar un comentario