; Kira Swab ; Assembly Assignment #4 ; March 28, 2001 ; This editor program allows the user to control the color of text on the screen .model small .stack 100h .data goinghere db "going here",0 mousestring db "no mouse", 0 menu db "0 Black |1 Blue |2 Green |3 Cyan " db "|4 Red |5 Magenta|6 Brown |7 White |",0 rowpix dw ? colpix dw ? char db 20 dup (?) attribute db ? diffcolor db ? c_row db ? c_col db ? GreenOnWhite = 72h CursorLocation = 0300h MenuLocation = 0000h WhiteOnBlack = 07h BlackOnBlack = 00h BlueOnBlack = 01h GreenOnBlack = 02h CyanOnBlack = 03h RedOnBlack = 04h MagentaOnBlack = 05h BrownOnBlack = 06h slash db ? .code extern Clrscr:proc, Crlf:proc, Gotoxy:proc extern Scroll:proc, Writestring:proc main proc mov ax, @data mov ds, ax SetColor: mov ah, 0 ;set vid mode mov al, 83h ;mode 3 w/o clrscr int 10h MenuSpot: call Clrscr ;clear screen mov cx, 0 ;get left r/c mov dh, 0 ;get right row mov dl, 79 ;get right col mov bh, GreenOnWhite ;sets vid. attr. call Scroll ;scroll whitescreen mov dx, MenuLocation ;sets dx w/ r/c call Gotoxy ;moves cursor to r/c mov dx, offset menu ;offset string call Writestring ;writes menu in g/w jmp Window mov c_row, 3 mov c_col, 0 Window: mov ch, c_row mov cl, c_col mov dx, 184eh ;sets r/c for window mov bh, WhiteOnBlack ;sets attributes mov attribute, bh mov dx, 0300h jmp MouseSetup jmp Cursor MouseSetup: push ax push bx push cx push dx mov ax, 0000h int 33h cmp ax, 0 jne DisplayMouse mov dx, offset mousestring call writestring DisplayMouse: mov ax, 0001h int 33h pop dx pop cx pop bx pop ax jmp Cursor Cursor: call Gotoxy jmp WriteChar WriteChar: mov ah, 8 ;gets char int 21h mov char, al ;saves char jmp CheckChar Attributes: mov ah, 8 int 21h OutputChar: mov char, al mov ah, 9 ;function code mov bl, attribute ;attribute mov bh, 0 ;vid pg. mov cx, 1 ;repetitions int 10h jmp GetCursor CheckChar: cmp char, 7eh ;hex for ~ je EndSpot cmp char, 08h ;hex for bspace je GetCursor cmp char, 5ch ;hex for bslash mov slash, al je BackSlash jmp OutputChar BackSlash: mov ah, 8 int 21h mov diffcolor, al cmp diffcolor, "0" je BlackSlash cmp diffcolor, "1" je BlueSlash cmp diffcolor, "2" je GreenSlash cmp diffcolor, "3" je CyanSlash cmp diffcolor, "4" je RedSlash cmp diffcolor, "5" je MagentaSlash cmp diffcolor, "6" je BrownSlash cmp diffcolor, "7" je WhiteSlash jmp Attributes BlackSlash: mov attribute, BlackOnBlack jmp SetColorChar BlueSlash: mov attribute, BlueOnBlack jmp SetColorChar GreenSlash: mov attribute, GreenOnBlack jmp SetColorChar CyanSlash: mov attribute, CyanOnBlack jmp SetColorChar RedSlash: mov attribute, RedOnBlack jmp SetColorChar MagentaSlash: mov attribute, MagentaOnBlack jmp SetColorChar BrownSlash: mov attribute, BrownOnBlack jmp SetColorChar WhiteSlash: mov attribute, WhiteOnBlack jmp SetColorChar SetColorChar: jmp WriteChar MoveBack: mov ah, 2 mov dh, c_row sub c_col, 1 mov dl, c_col mov bh, 0 int 10h jmp WriteChar GetCursor: mov ah, 3 ;get cursor pos. mov bh, 0 ;vid pg. int 10h ;call BIOS mov c_row, dh ;save cur. row mov c_col, dl ;save cur. col cmp char, 08h je MoveBack ; jmp AdvanceCursor jmp CheckRow CheckRow: cmp c_col, 79 je CarriageReturn jne AdvanceCursor CarriageReturn: cmp c_row, 24 je PageScroll call Crlf jmp WriteChar PageScroll: push ax push bx push cx push dx mov ah, 6 ;scroll wind. up mov ch, 3 mov cl, 0 mov dh, 24 mov dl, 79 mov al, 1 mov bh, attribute int 10h pop dx pop cx pop bx pop ax mov dh, 24 mov dl, 0 jmp Cursor AdvanceCursor: mov ah, 2 ;set cursor pos. mov dh, c_row add c_col, 1 mov dl, c_col mov bh, 0 int 10h jmp Cursor EndSpot: mov ah, 2 mov dh, 23 mov dl, 0 mov bh, 0 int 10h mov ax, 4c00h int 21h main endp end main