Sie sind auf Seite 1von 4

;==========================================================================

; ** lab - 3 ** set colortext mode


;==========================================================================

title colortextmode
.model small
.stack 100h
.data
max equ 12
act equ 10

namepar label byte


maxlen db max
actlen db act
charinput db max dup('$')
colors db 01, 02, 03, 04, 05, 06, 08, 09, 10, 11
row db 00
column db 00
.code

begin proc far


mov ax, @data
mov ds, ax
mov es, ax

call disclear
call setcolormode
mov dx, 0000 ; cursor-iig hamgiin deed, zuun zahiin(ehnii)
call setcursor ; tsegt
bairluulna
call input
call disclear
mov dh, 12 ; cursor-iig
mov dl, 40 ; delgetsiin gold
call setcursor ; bairluulna
call print

;==========================
; ** press keys **
;==========================

start:
mov ah, 00 ; neg temdegtiig garaas unshuulah huselt (bios-iin 16h
tasaldal)
int 16h
cmp ah, 16h ; 16h-n "u" tovchluuriin scan code
je up
cmp ah, 20h ; 20h-n "d" tovchluuriin scan code
je down
cmp ah, 26h ; 26h-n "l" tovchluuriin scan code
je left
cmp ah, 13h ; 13h-n "r" tovchluuriin scan code
je right
cmp ah, 01h ; 01h-n "esc" tovchluuriin scan code
je ending1
jmp start
up:
cmp dh, 00
je start
mov row, dh
mov column, dl
call disclear
mov dh, row
mov dl, column
dec dh
call setcursor
call print
jmp start

down:
cmp dh, 24
je start
mov row, dh
mov column, dl
call disclear
mov dh, row
mov dl, column
inc dh
call setcursor
call print
jmp start

start1:
cmp dl, 00
je start

ending1:
cmp ah, 01h
je ending

right:
cmp dl, 70
je start
mov row, dh
mov column, dl
call disclear
mov dh, row
mov dl, column
inc dl
call setcursor
call print
jmp start

left:
cmp dl, 00
je start1
mov row, dh
mov column, dl
call disclear
mov dh, row
mov dl, column
dec dl
call setcursor
call print
jmp start
;==========================
; ** exit **
;==========================
ending:
mov ah, 4ch
int 21h

begin endp

;=======================================
; ** 80x25 set colortext mode **
;=======================================
setcolormode proc near
mov ah, 00 ; gorim togtoono
mov al, 03 ; 16 ungutei, 80*25 hemjeetei text gorim
int 10h
ret
setcolormode endp

;=======================================
; ** clear screen **
;=======================================
disclear proc near
mov ax, 0600h ; delgets hoosolno
mov bh, 07 ; engiin (har) atribut
mov cx, 0000h ; delgetsiin hamgiin ehnii tseg
mov dx, 184fh ; delgetsiin hamgiin suulchiin tseg
int 10h
ret
disclear endp

;=======================================
; ** set cursor position **
;=======================================
setcursor proc near
mov ah, 02 ; cursor bairluulah huselt
mov bh, 00 ; delgetsiin dugaar
int 10h ; bios-iin 10h tasaldal (interrupt)
ret
setcursor endp

;=======================================
; ** gets string from keyboard **
;=======================================
input proc near
mov ah, 0ah ; orolt huseh
lea dx, namepar
int 21h
ret
input endp

;=====================================================
; ** print by other colors on display center **
;=====================================================
print proc near
lea si, charinput
mov column, dl
repeat:
mov ah, 09 ; delgetsend hevleh huselt
mov al, [si]
cmp al, 0dh ; "enter" tovchluuriin scan code
je endprint
inc si
mov bh, 00 ; 0-dugaar huudasiig songono
mov bl, colors ; ungunii atributiig bl-d olgono
mov cx, 01 ; 1 udaa
int 10h
inc dl ; daraagiin temdegtiig hevlehed beldej baganiin dugaariig
1-eer
call setcursor ;
nemegduulne
inc colors ; daraagiin ungiig songono
jmp repeat
endprint:
mov colors, 01
mov dl, column
call setcursor
ret
print endp

end begin

Das könnte Ihnen auch gefallen