Problem Statement: Write a TSR program in 8086 ALP to implement Screen Saver. Screen Saver should get activated if the
keyboard is idle for 7 seconds. Access the video RAM directly in your routine.
CODE
SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE
ORG 100H
START :
JMP BEGIN
TIMER_IP DW ?
TIMER_CS DW ?
KB_IP DW ?
KB_CS DW ?
FLAG DB 0
CNT DB 127
BUFFER DW 2000 DUP(0)
TIMER:
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
PUSH DS
PUSH ES
MOV AX,CS
MOV DS,AX
MOV ES,AX
CMP FLAG,00H
JNE TIMER_END
DEC CNT
JNE TIMER_END
CLD
MOV AX,0B800H ;cursor to the start of
the screen(initialising data seg)
MOV DS,AX
MOV SI,0000H
MOV DI,OFFSET BUFFER
MOV CX,2000
;size(80*25=2000
characters, 2 bytes per char:ascii code & attribute)
REP MOVSW ;saving the screen contents to the buffer
MOV AX,0B800H ;initialising extra
segment to the starting of screen mem
MOV ES,AX
MOV DI,0000H
MOV AL,00
MOV AH,00 ;attribute
MOV CX,2000
REP STOSW ;filling the entire screen
MOV CS:FLAG,01H
TIMER_END:
POP ES
POP DS
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
JMP
DWORD PTR CS:TIMER_IP ;jump to timer
ISR
KB:
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
PUSH DS
PUSH ES
MOV AX,CS
MOV DS,AX
MOV ES,AX
MOV CNT,127 ;setting count for waiting period to activate screen
CMP FLAG,01
JNE KB_END
CLD
MOV AX,0B800H
MOV ES,AX
MOV SI,OFFSET BUFFER
MOV DI,0000H
MOV CX,2000
REP MOVSW
MOV FLAG,00H
KB_END :
POP ES
POP DS
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
JMP
DWORD PTR CS:KB_IP
BEGIN:
MOV AX,CS
MOV DS,AX
MOV ES,AX
MOV AH,35H
MOV AL,08H
INT 21H
MOV TIMER_IP,BX
MOV TIMER_CS,ES
MOV AH,35H
MOV AL,09H
INT 21H
MOV KB_IP,BX
MOV KB_CS,ES
MOV AH,25H
MOV AL,08H
MOV DX,OFFSET TIMER
INT 21H
MOV AH,25H
MOV AL,09H
MOV DX,OFFSET KB
INT 21H
MOV AH,31H ; requests stay
resident
MOV DX,OFFSET BEGIN ;specify size
INT 21H
CODE
ENDS
END
START
Output