Haciendo publico el codigo de un chat en assembler que desarrollé en el primer semestre del 2005 para el ramo de microsistemas. Si le sirve a alguien.. bien y si no... aqui igual quedará.
;=================================================================================================
;Microsistemas 1er Semestre 2005.
;Profesor : OTTO PETERSSEN ENTRALGO
;Alumno : Dario Antonio Diaz Videla
;Fecha : 08-Julio-2005
;==============================================================
STACK SEGMENT STACK
DW 100H DUP(?)
STACK ENDS
DATA SEGMENT
IP_RESP DW ?
CS_RESP DW ?
xr db 0
yr db 2
xt db 0
yt db 14
mensaje1 db 'Remoto :$'
mensaje2 db 'Local :$'
mensaje3 db ' Microsistemas 1er Semestre 2005 // DDV / JBV$'
DATA ENDS
CODE SEGMENT
gotoxy macro x,y
xor bh, bh
mov dl, x
mov dh, y
mov ah, 02h
int 10h
endm
Print macro mensaje
mov ah, 09h
mov dx, offset mensaje
int 21h
endm
Linea macro x,y
gotoxy x,y
mov al, '-'
mov ah, 0ah
mov cx, 78
int 10H
endm
CLS macro
mov ax,0600h
mov bh,17h
mov cx,0000h
mov dx,184fh
mov bl, 0
int 10h
endm
MIPROG PROC FAR
ASSUME CS:CODE, DS:DATA
inicio:
mov ax, DATA
mov ds, ax
;-----------------------------------------------------------
;Configurar el Puerto de Comunicacion
;-----------------------------------------------------------
;-----------------------------------------------------------
; Registro de linea de Control
mov dx, 3fbh
mov al, 10000000b
out dx, al
;-----------------------------------------------------------
; Divisor de la velocidad en baudios (Alto)
mov dx, 3f9h
mov al, 00b
out dx, al
;-----------------------------------------------------------
; Divisor de la velocidad en baudios (Bajo)
mov dx, 3f8h
mov al, 60h
out dx, al
;-----------------------------------------------------------
; Longitud de los caracteres(bit 0 y 1 estaran en 1 para que
; sea 8 bit)
mov al, 00000011b
mov dx, 3fbh
out dx, al
;-----------------------------------------------------------
CLI
;-----------------------------------------------------------
; Respaldo de tabla de interrupciones de comunciacion com1
MOV DI,0
MOV ES, DI
MOV DI, 4*12 ; 12 COM1
MOV AX, ES:[DI]
MOV IP_RESP, AX
MOV AX, ES:[DI+2]
MOV CS_RESP, AX
;-----------------------------------------------------------
; Configurar de tabla de interrupciones de comunciacion com1
MOV DI, 0
MOV ES, DI
MOV DI, 4*12 ; 12 COM1
MOV word ptr ES:[DI], offset recibe
MOV word ptr ES:[DI+2], seg recibe
;-------------------------------------------------------------
; Interrupt Enable Register
; Habilitar la interrupcion
;-------------------------------------------------------
mov dx, 3f9h
mov al, 1
out dx, al
;-------------------------------------------------------------
; Habilitar la interrupcion bit 3, Request to Send bit 1, Data
; Terminal Ready bit 0
;-------------------------------------------------------------
mov dx, 3fch
mov al, 00001011b
out dx, al
;-------------------------------------------------------------
;
in al, 21h
and al, 11100111b
out 21h, al
STI
;-----------------------
; borra la pantalla
CLS
;---------------------------------------
; Despliega titulos y lineas de division
gotoxy 0,1
Print mensaje1
gotoxy 0,13
Print mensaje2
gotoxy 0,0
Print mensaje3
Linea 0,12
espera:
mov ah,0
int 16H
cmp ah,1 ; Sale con Escape ScanCode 1 en ah
je fin
mov dx, 3f8h
out dx, al; escribe en puerto serie
jmp escribe
fin:
MOV DI, 0
MOV ES, DI
MOV DI, 4*12 ; com1
MOV AX, IP_RESP
MOV ES:[DI], AX
MOV AX, CS_RESP
MOV ES:[DI+2], AX
;-----------------------------
; borra la pantalla
CLS
;-----------------------------
; Posicionar el cursor en 0, 0
gotoxy 0,0
MOV AX, 4C00H
INT 21H
escribe:
;--------------------------------
; Posiciona cursor en la pantalla
gotoxy xt, yt
;--------------------------------
; Escribe caracter en Pantalla
mov ah, 0ah
mov cx, 1
int 10H
inc xt
;-----------------------------------------------
; chequeamos coordenadas
cmp xt,78
jne salto1 ; chequea que la columna distinta a 78
mov xt,0
inc yt
cmp yt,24 ; chequea que la fila distinta a 22
jne salto1
mov yt,14
borrarsectorB:
;----------------------------------
; borrar sector de pantalla.
;--------------------------------
; Posiciona cursor en la pantalla
gotoxy 0,yt
;----------------------------------------
; Borra escribiendo un espacio en la fila
mov al, ' '
mov ah, 0ah
mov cx, 78
int 10H
inc yt ; incrementa fila a borrar
cmp yt,24
jne borrarsectorB
mov yt,14
salto1:
jmp espera
recibe:
push ds
push ax
push cx
mov ax, DATA
mov ds, ax
mov dx, 3f8h
in al, dx ; lee puerto serie
;--------------------------------
; Posiciona cursor en la pantalla
gotoxy xr,yr
;--------------------------------
; Escribe caracter en Pantalla
mov ah, 0ah
mov cx, 1
int 10H
;-----------------------------------------------
; cheaqueamos coordenadas
inc xr
cmp xr,78
jne salir ; chequea que la columna distinta a 78
mov xr,0
inc yr
cmp yr,12 ; chequea que la fila distinta a 10
jne salir
mov yr,2
borrarsectorA:
;----------------------------------
; borrar sector de pantalla.
;--------------------------------
; Posiciona cursor en la pantalla
gotoxy 0,yr
;----------------------------------------
; Borra escribiendo un espacio en la fila
mov al, ' '
mov ah, 0ah
mov cx, 78
int 10H
inc yr ; incrementa fila a borrar
cmp yr,12
jne borrarsectorA
mov yr,2
salir:
MOV AL, 20H
OUT 20H, AL
pop cx
pop ax
pop ds
IRET
MIPROG ENDP
CODE ENDS
END MIPROG
Utiliza conexión por el puerto serie com1 a 1200 bps 8 bit.