;programa que altera a cor de um rectangulo
org 100h
escrita equ 40h
ecra equ 1
section .text
mov ah,00h
mov al,13h ;modo video 320*200 256 cores
int 10h
mov byte [cor],100
mov byte [R],100
mov byte [G],100
mov byte [B],100
mov cx,16
linhas: mov word [nlinhas],cx
mov cx, 100
colunas:mov word [ncolunas], cx
mov ah, 0ch
mov al, byte [cor]
mov bh, 0
mov cx, word [ncolunas]
mov dx, word [nlinhas]
int 10h
mov cx, word [ncolunas]
loop colunas ;ciclo para desenhar os pixels colunas
mov cx, word [nlinhas]
loop linhas ;ciclo para desenhar os pixels linhas
teclapremida:
;ler uma tecla
mov ah, 07h
int 21h
mov byte [tecla],al
;verifica se ‚ a tecla w
tecla_w:cmp byte [tecla], 119
jnz tecla_s
inc byte [R]
call novacor
;verifica se ‚ a tecla s
tecla_s:cmp byte [tecla], 115
jnz tecla_e
dec byte [R]
call novacor
;verifica se ‚ a tecla e
tecla_e:cmp byte [tecla], 101
jnz tecla_d
inc byte [G]
call novacor
tecla_d:cmp byte [tecla], 100
jnz tecla_r
dec byte [G]
call novacor
tecla_r:cmp byte [tecla], 114
jnz tecla_f
inc byte [B]
call novacor
tecla_f:cmp byte [tecla], 102
jnz tecla_q
dec byte [B]
call novacor
tecla_q:cmp byte [tecla], 113
jnz teclapremida
jmp saidavideo
;definir a nova cor
novacor:mov ah, 10h
mov al, 10h
mov bl, byte [cor]
mov bh, 0
mov dh, byte [R]
mov ch, byte [G]
mov cl, byte [B]
int 10h
ret
saidavideo:
mov ah,00h
mov al,03h
int 10h
mov ah,4ch ;saida para o dos
int 21h
section .data
pixel db "."
novalinha db 13,10
section .bss
ncolunas resw 1
nlinhas resw 1
cor resb 1
R resb 1
G resb 1
B resb 1
tecla resb 1