;---------------------------------------------------------------------------
; Demo of character I/O in assembly from class examples
;
; 2001-02-14 -bob,mon.
;---------------------------------------------------------------------------
.model small
.stack 100h
.data
msg1 db "Enter a character: $"
ch1 db ?
msg2 db "You entered '$"
msg3 db "'.$"
.code
extern DOSstr:near
extern getChr:near, putChr:near
extern doCRLF:near
main proc
mov dx, @data
mov ds, dx
mov ax, offset msg1
call DOSstr
call getChr
mov ch1, al
call doCRLF
mov ax, offset msg2
call DOSstr
mov al, ch1
call putChr
mov ax, offset msg3
call DOSstr
call doCRLF
mov al, 0
mov ah, 4Ch
int 21h
main endp
;---------------------------------------------------------------------------
end main ; program will start w/ "main" proc.
;---------------------------------------------------------------------------
|
;---------------------------------------------------------------------------
; some I/O procedures, in assembly.
; version 1:
; unprotected registers
; args passed in AX, BX, ... as needed
;
; 2001-02-14 -bob,mon.
;---------------------------------------------------------------------------
public DOSstr, getChr, doCRLF, DOSstr, putChr
.model small
.code
doCRLF proc
mov dl, 0Dh
mov ah, 02h
int 21h
mov dl, 0Ah
int 21h
ret
doCRLF endp
;---------------------------------------------------------------------------
DOSstr proc
mov dx, ax
mov ah, 09h
int 21h
ret
DOSstr endp
;---------------------------------------------------------------------------
; Get DOS-processed keyboard character, w/ echo
;
getChr proc
mov ah, 01h
int 21h
ret
getChr endp
;---------------------------------------------------------------------------
putChr proc
mov dl, al
mov ah, 02h
int 21h
ret
putChr endp
;---------------------------------------------------------------------------
end ; no proc name here: none of these proc's start a program
;---------------------------------------------------------------------------
|