DOSSEG ; A Assembler program that demonstrates graphics modes ; It demonstrates the 10h interrupt and uses the text modes ; It also writes things with attributes ; Author: Curt Hill ; Purpose: ;Data section .model large .stack 100h .486 .code ; Here is the code start: mov ax,@data ; Address the data mov ds,ax mov es,ax xor ax,ax ; cycle through the modes xor cx,cx modeloop: ; set the mode mov ax,cx call chmode ; Correct the string or al,'0' ; make a digit mov modev,al lea dx,mode call writewattr ; allow reaction time call pause mov attrib,82h inc cx cmp cx,4 jl modeloop ; once more for mode 7 which is monochrome ; set the mode mov ax,7 call chmode mov attrib,48h mov modev,'7' lea dx,mode call writewattr call incr_cur_size ; allow reaction time call pause mov ax,3 ; most colorful call chmode call incr_cur_size ; draw the string with alternating attributes lea bp,dmsg2 ; not anywhere near stack mov ah,13h ; main function mov al,02h ; advance cursor only characters xor bh,bh xor bl,0fh mov cx,4 ; four character attribute pairs mov dx,0502h ; fifth row int 10h call pause call incr_cur_size ; draw a string with one attribute lea bp,dmsg mov cx,dlen mov al,00h ; advance cursor characters and attr mov bl,0a0h mov dx,0902h ; ninth row int 10h call pause mov ax,4c00h ; Leave the program int 21h ; Any subroutines would go here, keep label names local LOCALS ; mode is in al chmode proc near push ax mov ah,0 int 10h pop ax ret chmode endp incr_cur_size proc near push ax push bx push cx push dx ; first get its size mov ah,3 int 10h ; now increase sub ch,2 mov ah,1 int 10h pop dx pop cx pop bx pop ax ret incr_cur_size endp ; write characters no attribute using ah=0ah ; DX is the string, which ends with a null character writenoattr proc near push ax push cx push di mov cx,1 mov ah,0ah mov di,dx ; move from di, on pentium move directly @@wcloop: mov al,[di] inc di cmp al,0 je @@wcdone int 10h call incr_cursor jmp @@wcloop @@wcdone: pop di pop cx pop ax ret writenoattr endp ; write characters with attributes using ah=09h ; DX is the string, which ends with a null character writewattr proc near push ax push bx push cx push di mov cx,1 mov ah,09h mov di,dx ; move from di, on pentium move directly mov bl,attrib @@wcloop: mov al,[di] inc di cmp al,0 je @@wcdone int 10h call incr_cursor jmp @@wcloop @@wcdone: pop di pop cx pop bx pop ax ret writewattr endp ; write characters using ah=0eh ; DX is the string, which ends with a null character writechars2 proc near push ax push bx push di mov ah,0eh mov di,dx ; move from di, on pentium move directly xor bh,bh ; page zero mov bl,attrib wcloop2: mov al,[di] inc di cmp al,0 je wcdone2 int 10h jmp wcloop2 wcdone2: pop di pop bx pop ax ret writechars2 endp ; no parameters, nothing is changed but video incr_cursor proc near push ax push bx push cx push dx ; first get cursor mov ah,3 int 10h ; now set up by one mov ah,2 xor bx,bx inc dl int 10h pop dx pop cx pop bx pop ax ret incr_cursor endp pause proc near push ax push dx lea dx,readym mov ah,9 int 21h mov ah,0ah lea dx,block int 21h pop dx pop ax ret pause endp .data ; Data goes here readym db 13,10,"Enter when ready for next",13,10,'$' attrib db 71h block db 20 new db ? strn db 20 dup (' ') mode db "This is mode number " modev db "0",0 dmsg db "Drawn with one function call" dlen dw $-dmsg dmsg2 db "D",2fh,"r",0fh,"a",0f0h,'w',0c3h end