Profesor: Carlos Bethencourt
Practica # 4
Practica
Desarrolle un programa que permita simular un CHAT entre dos computadores.
El nombre (10 caracteres) de los participantes debe aparecer en colores diferentes, seguido del mensaje a enviar (Hasta 50 caracteres).
Ejemplo:
Carlos: Hola como estas?
Mariana: Yo estoy bien, y tu?
Carlos: Bien, cuando nos vemos?
1: .model small 2: .stack 64h 3: .data 4: caracter db ? 5: atributo db ?6: mensaje3 db " Introduce el nick max 10 caracteres$"
7: contador db ? 8: nickname db 11 dup (?) 9: mensaje db 51 dup (?) 10: mensaje2 db 69 dup (20h),24h 11: mensaje10 db 80 dup (20h) 12: 13: marco db 0,0,0,201,70 dup (205),187,10,13 14: db 0,0,0,186,70 dup (20h),186,10,13 15: db 0,0,0,186,70 dup (20h),186,10,13 16: db 0,0,0,186,70 dup (20h),186,10,13 17: db 0,0,0,186,70 dup (20h),186,10,13 18: db 0,0,0,186,70 dup (20h),186,10,13 19: db 0,0,0,186,70 dup (20h),186,10,13 20: db 0,0,0,186,70 dup (20h),186,10,13 21: db 0,0,0,186,70 dup (20h),186,10,13 22: db 0,0,0,186,70 dup (20h),186,10,13 23: db 0,0,0,186,70 dup (20h),186,10,13 24: db 0,0,0,186,70 dup (20h),186,10,13 25: db 0,0,0,186,70 dup (20h),186,10,13 26: db 0,0,0,186,70 dup (20h),186,10,13 27: db 0,0,0,186,70 dup (20h),186,10,13 28: db 0,0,0,186,70 dup (20h),186,10,13 29: db 0,0,0,186,70 dup (20h),186,10,13 30: db 0,0,0,200,70 dup (205),188,24h 31: 32: marco2 db 0,0,0,201,10 dup (205), " ESCRIBE EL MENSAJE ",40 dup (205),187,10,13
33: db 0,0,0,186,70 dup (20h),186,10,13 34: db 0,0,0,200,70 dup (205),188,24h 35: 36: marco3 db 0,0,0,201,10 dup (205), " ESCRIBE EL NICK, MAX 10 CARACTERES ",24 dup (205),187,10,13
37: db 0,0,0,186,70 dup (20h),186,10,13 38: db 0,0,0,200,70 dup (205),188,24h 39: 40: 41: 42: .code 43: 44: mov ax,@data 45: mov es,ax 46: mov ds,ax 47: 48: call cls
49: 50: mov dh,15 51: mov dl,052: call cursor
53: 54: lea dx,marco3 55: mov ah,9 56: int 21h 57: 58: mov dh,16 59: mov dl,1060: call cursor
61: 62: lea si,nickname 63: mov cx,10 64: pidonick: mov ah,0 65: int 16h 66: cmp al,13 67: je salnick 68: mov [si],al 69: inc si70: mov byte ptr [si],">"
71: mov dl,al 72: mov ah,2 73: int 21h74: loop pidonick
75: salnick: call cls
76: mov dh,4 77: mov dl,078: call cursor
79: lea dx,marco 80: mov ah,9 81: int 21h 82: 83: mov dh,22 84: mov dl,085: call cursor
86: mov ah,9 87: lea dx,marco2 88: int 21h 89: 90: 91: 92: inicio: mov contador,0 93: lea si,mensaje 94: mov cx,5095: call limpiar
96: lea si,mensaje 97: mov dh,23 98: mov dl,599: call cursor
100: mov ah,9 101: lea dx,mensaje2 102: int 21h 103: mov dh,23 104: mov dl,5105: call cursor
106: 107: tecla: 108: mov ah,0bh 109: int 21h 110: cmp al,0 111: je nada 112: mov ah,1 113: int 21h 114: 115: cmp al,1bh 116: je salir 117: cmp al,13 118: je enviar 119: mov [si],al 120: inc si 121: inc contador122: nada: call recibe
123: jmp tecla124: salir: call modot
125: .exit
126: 127: enviar:128: call leerpantalla
129: mov dh,20 130: mov dl,5131: call cursor
132: mov ah,9 133: lea dx,mensaje2 134: int 21h 135: 136: mov dh,20 137: mov dl,5 138: mov al,00000001b 139: mov ah,13h 140: mov bh,0 141: mov bl,72h 142: mov ch,0 143: mov cl,contador 144: add cl,11 145: lea bp,nickname 146: int 10h147: call transmite
148: jmp inicio 149: 150: modot: mov ah,0 151: mov al,3 152: int 10h 153: ret 154: 155: cls: mov ah,6 156: mov al,0 157: mov bh,70h 158: mov cx,0 159: mov dh,24 160: mov dl,79 161: int 10h 162: ret 163: 164: leerpantalla:165: call leeposicion
166: push dx 167: 168: mov dh,6 169: leopant2: mov dl,5170: leopant: call cursor
171: call leecursor
172: mov atributo,ah 173: mov caracter,al 174: dec dh175: call cursor
176: call escribe
177: inc dh 178: inc dl 179: cmp dl,66 180: jne leopant 181: inc dh 182: cmp dh,21 183: jne leopant2 184: 185: pop dx186: call cursor
187: ret 188: 189: escribe: mov al,caracter 190: mov ah,9 191: mov bh,0 192: mov bl,atributo 193: mov cx,1 194: int 10h 195: ret 196: 197: leeposicion: 198: mov ah,3 199: mov bh,0 200: int 10h 201: ret 202: 203: leecursor: 204: mov ah,8 205: mov bh,0 206: int 10h 207: ret 208: 209: cursor: mov ah,2 210: mov bh,0 211: int 10h 212: ret 213: 214: limpiar: mov byte ptr [si],0
215: inc si216: loop limpiar
217: ret 218: 219: transmite: nop 220: mov ch,0 221: mov cl,contador 222: add cx,12 223: lea si,contador224: lazo01: call estado
225: test ah,40h 226: jz lazo01227: call escricom
228: inc si229: loop lazo01
230: ret 231: 232: lazo10: pop si 233: ret 234: 235: recibe: nop 236: push si 237: lea si,mensaje10238: call estado
239: test ah,1 240: jz lazo10241: call LEERCOM
242: MOV [SI],AL 243: INC SI 244: 245: xor cx,cx
246: mov cl,[si-1]247: lazo11: call estado
248: test ah,1 249: jz lazo11250: call LEERCOM
251: MOV [SI],AL 252: INC SI253: loop lazo11
254: 255: call leeposicion
256: push dx 257: 258: call leerpantalla
259: mov dh,20 260: mov dl,5261: call cursor
262: mov ah,9 263: lea dx,mensaje2 264: int 21h 265: push si 266: lea si,mensaje10 267: mov cl,[si] 268: inc si 269: push si 270: pop bp 271: 272: mov dh,20 273: mov dl,5 274: mov al,00000001b 275: mov ah,13h 276: mov bh,0 277: mov bl,76h 278: mov ch,0 279: int 10h 280: pop si 281: 282: pop dx283: call cursor
284: pop si 285: ret 286: 287: preparar: mov ah,0 288: mov al,11100011b 289: mov dx,0 290: int 14h 291: ret 292: estado: mov ah,3 293: mov dx,0 294: int 14h 295: ret 296: leercom: mov ah,2 297: mov dx,0 ; cambiar a 0 298: int 14h 299: ret 300: escricom: mov ah,1 301: mov al,[si] 302: mov dx,0 303: int 14h 304: ret 305: 306: end
No hay comentarios:
Publicar un comentario