20BCE2351 Micro Assignment-01
20BCE2351 Micro Assignment-01
ASSIGNMENT-01
Example:
String Cryptography writes to standard output after reading from
standard input and encrypting each byte.
TITLE Encryption Program
; This program uses MS-DOS function calls to
; read and encrypt a file. Run it from the
; command prompt, using redirection:
; Encrypt < infile.txt > outfile.txt
; Function 6 is also used for output, to avoid
; filtering ASCII control
characters. INCLUDE Irvine16.inc
XORVAL = 239; any value between 0-255
. code
main PROC
mov ax,@data
mov ds,ax
L1:
mov ah,6 ; direct console input
mov dl,0FFh ; don't wait for
character int 21h ; AL = character
jz L2 ; quit if ZF = 1
(EOF) xor al,XORVAL
mov ah,6 ; write to
output mov dl,al
int 21h
jmp L1 ; repeat the loop
L2: exit
main ENDP
END main
Function 06
clear the screen
AH = 06 ; function number
AL = 00 ; page number
BH = 07 ; normal attribute
CH = 00 ; row value of start points
CL = 00 ; column value of start
point DH = 24 ; row value of
ending point
DL = 79 ; column value of ending point
Function 02 – setting the cursor to a specific location
AH = 06 ; function number
DH = row ; cursor
DL = column ; position
Function 03 – get the current cursor position
AH = 03 ; function number
BH= 00 ; currently viewed page
The position is returned in DH = row and DL =
column Function 0E – output a character to the
screen
AH = 0E ; function number
AL = Character to be displayed
BH = 00 ; currently viewed
page
BL = 00 ; default foreground colour