Monday, September 22, 2008

Repeating Characters – Sample Assembly Program

; This program will repeat any character typed on the keyboard

.model small
.code
.stack
org 100h

START:
MOV AH, O6 ; use service 6 command

TOP:
MOV DL, OFFH ; read the character
INT 21H
JZ TYPEOUT ; if there is was no character, type out old one
MOV CL, AL ; store new character
CMP AL, ‘E’ ; was is an ‘E’?
JE FINISH ; if yes jump to the end of the program

TYPEOUT:
MOV DL, CL ; type out store character
INT 21H
JMP TOP ; jump to the beginning

FINISH:
INT 27
END START

No comments: