Question: Write an assembly language program to color the entire screen in two halves. Upon running the program, the left half of the screen should become green when the spacebar key is pressed. After that, when the spacebar key is released, the right half of the screen should become blue. The program should terminate when the Enter key is pressed.
Solution:
1) Complete assembly language program.
[org 0x100]
jmp start
OLisr: dd 0
kbisr:
push ax
push es
mov ax,0xb800
mov es,ax
in al, 0x60
cmp al, 0x39
jne nxtcmp
mov ah,06h
xor al,al
xor cx, cx
mov dx, 1827h
mov bh, 2eh
int 10h
jmp nomatch
nxtcmp:
cmp al,0xB9
jne nomatch
mov ah, 06h
mov cx, 0027h
mov dx, 184fh
mov bh, 1eh
int 10h
nomatch:
pop es
pop ax
jmp far [cs:OLisr]
start:
xor ax,ax
mov es,ax
mov ax,[es:9*4]
mov [OLisr],ax
mov ax,[es:9*4+2]
mov [OLisr+2],ax
cli
mov word [es:9*4],kbisr
mov [es:9*4+2],cs
sti
L1:
mov ah,0
int 0x16
cmp al,13
jne L1
mov ax, 0x4c00
int 0x21
1) Screenshot of the compilation step.
Screenshot of the final output.
0 Comments