memory blocks memory manager xma memorijsku oblast (xma...

72

Upload: others

Post on 18-Sep-2019

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi
Page 2: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-1

B. DODATAK: OSNOVA DOS -a

ö õ

Sekcija B.1 -- UVOD U DOS

Jedan od programa koje ra~unar izvr{ava je master, ili glavni program. ovaj program nam obezbe|uje uslove da se i drugi programi mogu bez velikih problema izvr{avati. Uobi~ajeno, master program nazivamo operativni sistem. Kada se govori o peresonalnim ra~unarima, poznatiji operativni sistemi su MS-DOS (ili PC-DOS), ), OS-2, Windows, Linux i dr. Operativni sistem uobi~ajeno se mo`e: (a) nalaziti na jednom od flopi disk jedinica, (b) nalaziti na hard (krutom) disku - ova verzija je rezidentna, (c) memorisati u ROM prostor ra~unara - rezidentna verzija, (d) napuniti preko lokalne ra~unarske mre`e (LAN). Svaki put kada se ra~unar uklju~i na napajanje, ili se resetuje, operativni sistem se ~ita sa diska (flopi ili krutog), ROM-a, ili LAN-a i sme{ta u memoriju. Ova operacija se naziva boot-ovanje sistema. U daljem tekstu ograni~i}emo se na obja{njenja koja se odnose na operativni sistem DOS. (Napomenimo da je DOS od poznatijih, {iroko apliciranih, operativnih sistema jedan od najjednostavnijih pa je sa ta~ke gledi{ta edukacije, {to se po~etnika ti~e, najopravdanije prvo njega izu~avati). Nakon punjenja u memoriju, DOS koristi usluge fajla CONFIG.SYS. Ovaj fajl specificira razli~ite pokreta~ke programe (drajvere), koji se pune u memoriju i na taj na~in u~estvuju u konfigurisanju ma{ine. Ilustracije radi na Slici B.1 prikazana je lista CONFIG.SYS fajla kod DOS-ove verzije 5.0 Prva ~etiri iskaza u CONFIG.SYS fajla sa Slike B.1 postavljaju broj fajlova, bafera, magacina i fajl upravlja~kih blokova potrebnih za izvr{enje razli~itih programa. Vrednosti na koje se oni postavljaju treba da su u skladu sa potrebama programa i mogu se menjati u zavisnosti od potreba. Komanda SHELL specificira koji interpreter komandi (komandni procesor) koristi DOS. U konkretnom slu~aju kao interpreter komandi se koristi program COMMAND.COM. Prekida~ (switch) E:256 odredjuje da obim (bloka) okru`enja bude 256 bajtova, a prekida~/P ukazuje da se COMMAND.COM permanentno nalazi u memoriji. Za slu~aj da COMMAND.COM nije permanentan u memoriji, uvek kada se DOS vrati na komandni prompt, on se mora sa diska puniti u memoriju. Ovakav re`im rada i pored toga {to oslobadja odredjeni iznos memorije ima slede}e ozbiljne nedostatke: (a) dovodi do stalnog obra}anja disku - disk je mehani~ka jedinica koja se ~esto kvari; i (b) produ`ava vreme potrebno za povratak na DOS prompt -usporava rad sistema. U primeru sa Slike B.1 prvi DEVICE (drajver) koji se puni u memoriju je HIMEM.SYS (high MEMory driver). Pokreta~ki program (driver) je program koji upravlja radom nekog uredjaja ili

Page 3: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-2

program koji mora biti prisutan u memoriji ra~unara. Program HIMEM.SYS obezbedjuje da se memorija ra~unara obima 1 MB pro{iri za iznos 66520 bajtova, tj. na 1 MB + 65519 B. Iznos od 65520 bajtova koji se nalazi u opsegu od adrese 10 0000 h do 10 FFFF naziva se expanded memory ili alternativno HMA (High Memory Area). HMA ~uva najve}i deo programa DOS-ovih verzija 5.0 ili 6.2.

REM DOS VERSION 5.0 CONFIG.SYS FILE REM FILES=30 BUFFERS=30 STACKS=64,128 FCBS=48 SHELL=C:\DOS\COMMAND.COM C:\DOS\ /E:256 /P

DEVICE=C:\DOS\HIMEM.SYS

DOS=HIGH, UMB

DEVICE=C:\DOS\EMM386.EXE I=C800-EFFF NOEMS

DEVICEHIGH SIZE=1EB0 C:\LASERLIB\SONY_CDU.SYS

DEVICEHIGH SIZE=0190 C:\DOS\SETVER.EXE

DEVICEHIGH SIZE=3150 C:\MOUSE1\MOUSE.SYS

LASTDRIVE=F

Slika B.1 CONFIG.SYS fajl kod DOS verzije 5.0

Naredna komanda DOS = HIGH, UMB, ukazuje ra~unaru da napuni DOS u vi{i deo memorije (HIGH) i obezbedi kori{}enje blokova koji su locirani u vi{em delu memorije (UMB - Upper Memory Blocks). Kori{}enje blokova koji su locirani u vi{em delu memorije dostupno je samo kod procesora 80386/80486/Pentium/Pentium-Pro uz pomo} programa EMM386.EXE (Extended Memory Manager). EMM386.EXE je pokreta~ki program koji emulira HMA memorijsku oblast u XMA memorijsku oblast (XMA-eXtended Memory Area), a takodje, obezbedjuje uslove za rad sa extended memorijskim sistemom. Prekida~ I=C800-EFFF ukazuje programu EMM386.EXE da koristi memoriju po~ev od lokacije C8000h-EFFFFh kao vi{i deo memorije ili kao blokove locirane u vi{em delu memorije (UMB). Punjenjem pokreta~kih programa u vi{em delu memorije oslobadja se vi{e prostora u TPA obla{}u za potrebe aplikacionih programa. Ali pre kori{}enja prekikda~a I=C800-EFFF moramo biti sigurni da u ovoj memorijskoj oblasti ra~unar nema instaliranu neku ROM/RAM oblast koju ve} koristi. NOEMS ukazuje programu EMM386.EXE da ne uklju~i HMA oblast. Danas najve{i broj ra~unara ne koristi HMA oblast. Komanda DEVICEHIGH puni pokreta~ke programe i programe u blokove locirane u vi{em delu memorije koji su dodeljeni od strane EMM386.EXE. U konkretnom slu~aju sa Slike B.1, po~ev od lokacije C8000h instalirana su tri pokreta~ka programa (drajvera). Prvi se odnosi na pokretanje SONY CDROM drajva, drugi puni program nazvan SETVER, a tre}i puni pokreta~ki program MOUSE. Zadnji iskaz u CONFIG.SYS fajlu sa Slike B.1 je iskaz LASTDRIVE. Ovaj iskaz ukazuje DOS-u koji je zadnji disk uredjaj povezan na ra~unarski sistem. U konkretnom slu~aju (Slika B.1) to je disk F. Mogu}e je, takodje, koriste}i COFIGF.SYS fajl, napuniti i druge pokreta~ke programe u

Page 4: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-3

memoriju. Tipi~ni takvi drajveri su PRINT.SYS, ANSI.SYS. Uobi~ajeno je da pokreta~ki programi imaju pridru`enu DOS ekstenziju SYS. Uvek kada DOS startuje sa radom, interpreter komandi, COMMAND.COM, proverava da li postoji inicijalna instrukcija za njega. Naime, proverava da li postoji instaliran specijalni batch fajl koji se naziva AUTOEXEC.BAT. Ako DOS ne pronadje fajl sa tim imenom, on poziva svoje dve, po definiciji ugradjene, komande DATE i TIME. Kada se fajl AUTOEXEC.BAT pronadje tada se u okviru start-up procedure, izvr{avaju samo one komande koje su sastavni deo batch fajla. To zna~i da DOS po automatizmu, u okviru start-up rutine, ne izvr{ava DATE i TIME programe. Za slu~aj da `elimo postaviti datum i vreme, tada programi DATE i TIME moraju biti uklju~eni u AUTOEXEC.BAT fajl. Na Slici B.2 prikazan je jedan tipi~an AUTOEXEC.BAT fajl koji va`i za verzije DOS-a 5.0 ili 6.0. Naravno da su varijacije AUTOEXEC.BAT fajla mogu}e. Ono {to je klju~no da se zna je slede}e: AUTOEXEC.BAT fajl sadr`i komande koje se izvr{avaju nakon uklju~enja sistema na napajanje. Obi~no su to one komande koje nakon uklju~enja treba uvek ukucavati preko tastature sa ciljem da se sistem pokrene. Izvr{enjem AUTOEXEC.BAT {tedi se kako vreme, tako i napor projektanta da se obavi ta aktivnost.

PATH C:\DOS; C:\MASM\BIN; C:\MASM\BINB\; C:\UTILITY PATH C:\WS; C:\LASERLIB SET BLASTER=A220 I7 D1 T3 SET INCLUDE=C:\MASM\INCLUDE\

SET HELPFILES=C:\MASM\HELP\*.HLP SET INIT C:\MASM\INIT\ SET ASMEX=C:\MASM\SAMPLES\ SET TMP=C:\MASM\TMP SET SOUND=C:\SB LOADHIGH C:\LASERLIB\MSCDEX.EXE /D:SONY_001 /L:F /M:10 LOADHIGH C:\LASERLIB\LLTSR.EXE ALT-Q LOADHIGH C:\DOS\FASTOPEN C:=256 LOADHIGH C:\DOS\DOSKEY /BUFSIZE=1024 LOADHIGH C:\LASERLIB\PRINTF.COM DOSKEY GO=DOSSHELL DOSSHELL

Slika B.2 Struktura jednog tipi~nog AUTOEXEC.BAT fajla

Uvek kada se u komandnoj liniji otkuca ime programa tada iskaz PATH specificira putokaze (puteve pretra`ivanja). Na primer, ako se u komandnoj liniji otkuca MILE1 ma{ina prvo pretra`uje C:\DOS, nakon toga root direktorijum C:\, zatim C:\MASM\BIN, i tako dalje sve dok se ne pronadje program pod imenom MILE1. Ako se program pod tim imenom ne pronadje, tada interpreter komandi COMMAND.COM obave{tava korisnika da taj program nije pronadjen. Prvom konadom SET postavlja se okru`enje za karticu sound blaster. Druga postavlja INCLUDE za put C:\MASM\INCLUDE. Uka`imo da su kodovi SET iskaza sme{teni (memorisani) u DOS-om prostoru okru`enja. Ovaj prostor se rezervi{e u CONFIG.SYS fajlu uz pomo} iskaza SHELL.

Page 5: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-4

Kada obim okru`enja postane suvi{e veliki tada je potrebno promeniti iskaz SHELL kako bi se okru`enju dodelilo bi{e prostora. LOADHIGH ili LH sme{ta programe u blokovima lociranim u vi{em delu memorije definisanih od strane EMM386.EXE programa. (Va`i za ra~unare kod kojih je instalirana CPU 386, 486, Pentium ili Pentium Pro). Zadnja komanda u fajlu EUTOEXEC.BAT, sa Slike B.2, je DOSSHELL Program DOSSHELL je u su{tini program tipa meni koji postoji kod MSDOS verzija 5.0 ili 6.x. ^esto se zadnje dve komande sa Slike B.2 zamenjuju slede}im

DOSKEY GO = C:\ WINDOWS\WIN /3 GO Program DOSKEY defini{e makro naredbu za re~ GO. U konkretnom slu~aju re~ GO se dodeljuje nizu znakova C:\WINDOWS\WIN /3. To zna~i da }e program COMMAND.COM uvek interpretirati re~ GO na taj na~in {to }e izvr{iti taj program uvek kada se preko tastature nakon pojave DOS prompt-a otkuca re~ GO. Zadnja komanda nakon toga izvr{ava Windows. Drugim re~ima nakon izvr{enja fajlova CONFIG.SYS i AUTOEXEC.BAT, ime programa koje je u AUTOEXEC.BAT kao zadnje prikazuje po~inje da se izvr{ava. U slu~aju sa Slike B.2 to je DOSSHELL program, a sa Slike B.3 izvr{i}e se Windows.

Pogled na DOS

Na Slici B.3 prikazan je pogled na MS DOS sistem. Da bi ovaj model mogli efikasnije da koristimo neophodno je poznavati mnogo vi{e detalja o kori{}enju: (a) BIOS-a i DOS-a kod izvr{enja U/I-a; (b) kako DOS puni i izvr{ava programe u memoriju; i (c) {ta se sme{ta u memoriju PC-a u toku izvr{enja programa. Kada se MS-DOS PC ma{ina uklju~i na napajanje, ona automatski po~inje da izvr{ava kod sa fiksne memorijske lokacije. Prvo se pune registri procesora CS i IP na vrednosti FFFFh i 0000h respektivno {to dovodi da se prvo pristupa fizi~koj adresi FFFF0h. Lokacija FFFF:0000 se nalazi u ROM-u, a program sme{ten u memoriji po~ev od te lokacije ~ini skup rutina koje testiraju integritet razli~itih hardverskih celina sistema. Ova aktivnost je poznata kao power-on-self-test (POST), tj. korak 1 na Slici B.4.

Page 6: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-5

SYSINIT

ROM BIOS

Power On Self Test (POST)

ROM bootstrap

Video memorija i drugi ROM-ovi

Disk bootstrap

COMMAND.COM(rezidentni)

Drajveri uredjajakoji se instaliraju

File Control Blocks (FCB)

Disk baferi

MD-DOS kernel

SYSINIT(relociraju}i)

DOS-BIOS interfejs

BIOS oblastpodataka

Vektori prekida Vektori prekida

BIOS oblastpodataka

DOS-BIOS interfejs

MD-DOS kernel

Disk baferi

FCBs

Drajveri uredjajakoji se instaliraju

COMMAND COM (rezidentni)

Video memorija i drugi ROM-ovi

COMMAND COM (rezidentni)

IO.SYS

boot sector

MSDOS.SYS

ROMBIOS

3

6

Preklapa se satranzijentnim delomCOMMAND.COM

2

6

Vrh memorijeVrh memorije

0

400H

600H

A0000H

0

400H

600H

A0000H

Memorija

boot drajv

1

5

4

Slika B.3 Ukupni pogled na MS-DOS sistem sa aspekta programa i U/I uredjaja

Page 7: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-6

ROM BIOS(osnovni U/Isistem)

video memorija

prostor zakorisni~kiprogram

operativnisistem

(MS DOS)

CPU

serijski port

{tampa~

disk

tastatura

prikaz

periferije0

640k

1024k

Slika B.4 MS DOS-ov boot proces i kona~ni izgled memorije Nakon uspe{nog zavr{etka POST-a po~inje izvr{enje ROM bootstrap rutine. (Bootstrap rutina je mala programska celina kojom se puni program velikog obima u RAM. Ova rutina kopira sektor 1 na pisti 0 (track 0), koga nazivamo boot sektor, sa flopi disk drajva A (ili hard disk drajva C za slu~aj da je drajv A prazan) u RAM prostor i prelazi (jump) na izvr{enje ovog programa (korak 2 na Slici B.4).). Boot sektor ~uva informaciju o MS-DOS-ovom fajl sistemu koji se nalazi na tom drajvu, a takodje sadr`i jo{ jedan bootstrap program. Ovim bootstrap programom pretra`uje se informacija o fajlovima poznatim kao IO.SYS i MSDOS.SYS. Ako se ovi fajlovi ne pronadju na disketi/disku tada se na ekranu displeja ispisuje poruka

Non-System disk or disk error Replace and strike any key when ready

Ako se fajlovi MSDOS.SYS i IO.SYS pronadju, tada se oni pune u memoriju, a nakon punjenja, upravljanje se prenosi modulu IO.SYS (korak 3 na Slici B.4). Kod IO.SYS-a ~ine dve celine: SYSINIT i DOS BIOS (Uo~imo sa Slike B.4 da postoji i deo BIOS-a koji je sme{ten u ROM prostoru). DOS BIOS ~ine pokreta~ki programi uredjaja (device drivers), tj. programi koji obezbedjuju standardni mehanizam za komuniciranje sa hardverskim uredjajima kao {to su tastatura, ekran (CON), serijski portovi (COM1 i COM2) i disk drajvovi. Kod SYSINIT modula, kao {to i samo ime ukazuje, obavlja inicijalizaciju MS-DOS kernela (jezgra). Naime, postavljaju se na po~etne vrednosti kako interne tabele, tako i radne oblasti. Ove tabele i oblasti koristi MS-DOS u toku izvr{enja raznih zadataka. Kao prvo, kopira se (sme{ta) MS-DOS kernel (korak 4 na Slici B.4). Zatim se postavljaju interne tabele, koje se koriste od strane MS-DOS-a i obavlja ostala inicijalizacija sistema. Nakon sprovedene inicijalizacije MS DOS i U/I fajl servisi postaju dostupni modulu SYSINIT. Modul SYSINIT koristi DOS fajl usluge da bi otvorio i procesirao sadr`aj CONFIG.SYS fajla. Kao {to su ve} napomenuli, fajl CONFIG.SYS sadr`i specifikaciju svih instaliranih pokreta~kih programa (to su pokreta~ki programi onih uredjaja koji su instalirani u sistem pri kupovini ili dodatnoj instalaciji). Pomo}u komandi BUFFERS= i FILES=, modul SYSINIT dodeljuje memoriju za potrebe ke{-bafera (koriste se kod prenosa podataka sa/ka disku) i potreba internih fajl upravlja~kih blokova. Nakon toga pune se pokreta~ki programi, specificirani iskazom DEVICE =, zatvara CONFIG.SYS fajl i dozvoljava rad uredjajima tipa konzola (CON:), {tampa~ (PRN:) i pomo}ni (AUX:). U daljem toku, SYSINIT puni i izvr{ava MS-DOS-ov interpreter komandi COMMAND.COM (koraci 5 i 6 na Slici B.4). Treba naglasiti da je pomo}u iskaza SHELL = <name> u CONFIG.SYS fajlu mogu}e specificirati i neki drugi interpreter komandi. Izgled memorijske mape nakon ove

Page 8: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-7

aktivnosti bi}e kao onaj na Slici B.4. Kao {to se vidi sa Slike B.program COMMAND.COM ~ine dve celine, tranzijentni i rezidentni deo. Sastavni deo programa COMMAND.COM je inicijalizaciona sekcija koja izvr{ava komande prisutne u AUTOEXEC.BAT - fajlu. Memorija koja se koristi od strane tranzijentnog dela COMMAND.COM programa oslobadja se kod punjenja i izvr{avanja korisni~kih programa. Rezidentni deo programa COMMAND.COM ponovo puni tranzientni deo nakon zavr{etka korisni~kog programa.

Mapa memorije kod MS-DOS-a

Godine1981, kada se prvi put pojavio, operativni sistem DOS je bio projektovan da se izvr{ava na IBM PC ma{ini zasnovanoj na mikroprocesoru 8088 koji ima 20-bitnu adresnu magistralu, pa je zbog toga memorija bila ograni~ena na prostor obima 1MB. Kao {to se vidi sa Slike B.5 projektanti IBM-a su podelili adresni prostor veli~ine 1MB na nekoliko specifi~nih blokova.

BIOS RAM

ne koristi se

ROM krutog diska

ne koristi se

bafer prikaza

memorijakorisnika

okru`enje

command.com

DOS

1 MB

384 kB specijalna memorija(sistemska oblast)

640 kB korisni~ka memorija(tranzijentna oblast)

Slika B.5 Memorijska mapa mikroprocesora 8086 koji izvr{ava MS-DOS

Ukupni prostor od 1MB, globalno posmatrano, je bio podeljen na dva dela, i to: (a) 640MB RAM-a korisni~ka memorija; i (b) 384kB rezervisana za ROM funkcije- upravlja~ki programi za video sistem, kontroler krutog (~vrstog) diska, i osnovni ulazno/izlazni sistem (BIOS). U trenutku kada se prva PC ma{ina pojavila na tr`i{tu (1981 god) adresni prostor od 640kB RAM-a izgledao je kao suvi{e veliki. Naime svi dotada{nji 8-bitni ra~unari imali su 16-bitnu adresnu magistralu, a shodno tome i memorijski prostor ograni~en na 64kB. Napredak tehnologije je uslovio da se dana{nje PC ma{ine zasnivaju na procesorima tipa 386, 486, Pentium i Pentium Pro, kod kojih je adresna magistrala 32 bitna (a kod nekih i 36-bitna). U poredjenju sa 8088 ovi procesori mogu da adresiraju ve}i memorijski prostor za 65536 puta. No nezavisno od toga, da bi sa~uvali kompatibilnost sa prethodnim verzijama DOS-a, ovi veoma mo}ni procesori su uslovljeni da rade u Realnom na~inu rada (Real Mode), kod kojih je memorija ograni~ena na prostor od 1MB. Naravno da je memorijska mapa dana{njih PC ma{ina (Slika B.6) zasnovana pre svega na procesorima 80386 - Pentium Pro pretrpela izmene u odnosu na prvobitnu sa Slike B.1. Kod personalnih ra~unara tipa IBM PC XT (zasnovani na 8088) oblast XMA ne postoji. Memorija do 1MB se obi~no naziva realna, iz razloga {to su Intelovi mikroprocesori projektovani da rade u ovoj oblasti u realnom na~inu rada. Personalni ra~unari zasnovani na 80286 do Pentium Pro sadr`e sve tri oblasti (TPA, sistemska i XMA). Ove ma{ine se ~esto nazivaju ma{ine klase AT.

Page 9: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-8

XMA

HMA

sistemska oblast(386 kB)

TPA(640 kB)

1MB+66520B

1MB

640 kB

0

1MBrealna

UMA (Upper Memory Area)

konvencionalna

15MB kod 80286 ili 80386SX31MB kod 80386 SL/SLC63MB kod 80386 EX4095MB kod 80386DX, 80486 i Pentium64GB kod Pentium Pro

Slika B.6 Memorijska mapa kod dana{njih PC ma{ina Napomena: HMA - High Memory Area; XMA - Extended Memory Area; ^esto se memorija od 0-640kB naziva konvencionalna a od 640kB - 1MB UMA; termin TPA se odnosi na Transient Program Area

MS-DOS funkcije i BIOS servisi

Jedna od najva`nijih osobina bilo kog operativnog sistema predstavlja softverska podr{ka koju on nudi korisnicima koji razvijaju programe. Na primer, skoro kod svih programa koji se izvr{avaju na PC ma{ini postoji potreba za unos podataka preko tastature. Jedan od na~ina da se prihvataju podaci sa ulaza je da se napi{e program koji }e ~itati podatke sa U/I-og porta na kome je povezana tastatura. S obzirom da su programi ovakvog tipa, i sli~ni njima, potrebni skoro kod svakog ra~unarskog sistema logi~ki se name}e pitanje: za{to ih ne ugraditi u operativni sistem kakav je DOS. U su{tini oni bi trebalo da su deo BIOS-ovih (Basic Input Output System) servisa. Danas veliki broj programa za PC ma{ine je da se izvr{ava pod MS-DOS operativnim sistemom. Sastavni deo ovog operativnog sistema su DOS-ove funkcije i BIOS-ovi pozivi. To su potprogrami, koji se mogu pozivati od strane aplikacionog softvera, a koriste se za pristup hardveru PC ma{ine. Namera je da se u{tedi programerima vreme i da se usmere njihovi napori na kreiranju efikasnijih aplikacionih programa, a ne da se oni zamaraju detaljima koji se odnose na upravljanje ulazom-izlazom. Sa druge strane obezbedjuju}i standardni skup ulazno/izlaznih rutina, ovim potprogramima se obezbedjuje softverska kompatibilnost izmedju ra~unara sa razli~itom hardverskom konfiguracijom. U tekstu koji sledi ukaza}emo na to: 1. Kako je struktuiran MS-DOS i objasniti uloge BOIS-a i MS-DOS kernela. 2. Objasniti razliku izmedju hardverskih i softverskih prekida 3. Ukazati na listu standardnih vektorskih prekida kod ra~unarskog sistema zasnovanog na mikroprocesoru 80x86 koji radi pod MS-DOS-om.

Struktura MS-DOS-a

BIOS (Basic Input/Output System) - kako je to prikazano na Slici B.7, BIOS-ove rutine su najprimitivnije, jer direktno "komuniciraju" sa hardverom sistema.

Page 10: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-9

aplikacioni programi komandni procesorCOMMAND.COM

MS-DOS kernel (MSDOS.SYS)

BIOS (ROM plus IO.SYS)

hardver sistema

Slika B.7 Nivovska organizacija ra~unarskog sistema koji izvr{ava aplikacione programe pod MS-DOS okru`enjem.

Ovo zna~i da je BIOS hardversko specifi~an, tj. da bi se napisala BIOS-ova rutina, mora da se zna ta~na adresa porta kao i konfiguraciju upravlja~kih bitova za svaku ulazno/izlazni uredjaj instaliran u ra~unaru. Obi~no BIOS se isporu~uje zajedno sa ra~unarom i sme{ten je na jednom ili dva ROM ~ipa lociranih na glavnoj plo~i ra~unara. U najve}em broju slu~ajeva kôd smesten u ROM-u je neizmenjiv (mo`e se samo ~itati). Ipak danas sve ve}i broj proizvodja~a ugradjuje fle{ memorije za BIOS. Ovaj tip ROM-a se mo`e selektivno reprogramirati a da se ~ip ne izvadi iz sistemske plo~e. Ova mogu}nost obezbedjuje korisniku da nadgradi BIOS, ali ~esto puta i da napravi neku ozbiljniju gre{ku koja mo`e da naru{i integritet sistema. Kod ra~unara koji imaju instalirano MS-DOS, BIOS se u su{tini sastoji iz dva dela. Prvi rezidentni deo, o kome smo govorili nalazi se u ROM-u, a drugi nerezidentni deo se puni u RAM kada se ra~unar boot-uje. Deo koji se boot-uje je u su{tini fajl IO.SYS. Ovaj fajl predstavlja pro{irenje rezidentnog BIOS-a i dozvoljava (omogu}ava) prenos podataka izmedju vi{ih nivoa DOS-a i hardvera sistema. Pored toga IO.SYS obezbedjuje (pru`a mogu}nost) nadgradnje (dodavanje) novih rutina BIOS-u. MS-DOS kernel - izmedju BIOS-a i aplikacionog softvera vi{eg nivoa (Slika B.7) nalazi se MS-DOS kernel. On se puni u RAM kada se sistem boot-uje pomo}u fajla MSDOS.SYS. Nasuprot BIOS-u, kernel obezbedjuje hardversko-nezavisne funkcije. Na primer, funkcija 39 se koristi za kreiranje subdirektorijuma na disku. Da bi koristio ovu funkciju korisnik koristi registar DX koji pokazuje na ime direktorijuma (sme{teno kao niz znakova u memoriji), puni registar AH sa 39 (broj funkcije), a zatim izvr{ava softverski prekid Int 21h. MS-DOS-ova funkcija 39 vodi brigu o svim detaljima: Poziva razli~ite BIOS-ove rutine koje aktiviraju disk drajv, lociraju dostupnost sektora na disku, i upisuju podatke. To zna~i da je kernel projektovan da pru`i (obezbedi) funkcije vi{eg nivoa u poredjenju sa BIOS-om. Imaju}i u vidu da je MS-DOS kernel hardversko nezavisaan, korisnici mogu bezbedno (bez opasnosti) da kreiraju ove pozive u njihovom softveru a da ne vode brigu o ulazno/izlazno adresnoj kompatibilnosti. U su{tini kernel je taj koji obezbedjuje da se isti program izvr{ava na ra~unarima koji imaju ugradjeno razli~ite disk drajvove, razli~ite video kartice, razli~ite tastature, i td.

Prekidi kod 80x86

Prekidi su dogadjaji koji uzrokuju da procesor suspenduje svoj teku}i zadatak i preda upravljanje novom programu koji se naziva prekidno uslu`na rutina (ISR-interrupt service routine). Kod ra~unara zasnovanih na procesorima 80x86 postoje tri izvora prekida: (1) procesorski prekidi; (2) softverski prekidi; i (3) hardverski prekidi. Svaki prekid mora da preda odgovaraju}i broj ili vektor koji se koristi od strane procesora kao pokaziva~ da iz vektorske tabele prekida (IVT -interrupt vector table) odredi po~etnu adresu prekidno uslu`ne rutine. Kako je to prikazano na Slici B.8 (vektorska tabela prekida), IVT ukupno sadr`i 256 razli~itih vektora (00-FF). Svaki ulaz IVT-a pokazuje na lokaciju odgovraju}e ISR. Naravno, kada procesor startuje sa radom ova tabela je

Page 11: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-10

prazna. Zbog toga punjenje IVT-a sa odgovaraju}im adresama potprograma je jedna od prvih operacija koju procesor mora da obavi. Pre nego {to preda upravljanje ISR-u procesor mora da obavi jedan veoma va`an zadatak: Da sa~uva teku}u programsku adresu i markere uslova u magacin. Zatim predaje upravljanje ISR-u. Kada ISR zavr{i, ova rutina koristi instrukciju IRET (return from interrupt) koja omogu}ava da se obnovi stanje markera kao i da se iz magacina "vrati" stara adresa programa. Na ovaj na~in procesor mo`e da nastavi sa izvr{enjem prekinutog programa sa onog mesta gde je i stao.

Pointer to ISR 254

Pointer to ISR 255

Pointer to ISR 4 Overflow

Pointer to ISR 3 Breakpoint

Pointer to ISR 2 NMI

Pointer to ISR 1 Single-Step

Pointer to ISR 0 Divide Error

Interrupt vector table (IVT)

1K (real mode)

2K (protected mode)

4 bytes (real mode) or8 bytes (protected mode)

5

4

2

0

1

3

6

FE

FF

Interrupt vector (type number)

Address 00000000-000003FF

Procesor

Real Mode

Protected Mode

Pointer Size

4 bytes

8 bytes

IVT Location

Anywhere in Physical Memory

Slika B.8 Vektorska tabela prekida ~uva pokaziva~e na ISR za svaki od 256 mogu}ih prekida Veliki broj vektora kod IVT-a je rezervisan za potrebe samog procesora, drugi su rezervisani za MS-DOS kernel i BIOS, i td. Na Slici B.9 prikazana je lista vektor brojeva, njihov opis, i inicijator. Uo~imo ,da u zavisnosti od procesora, neki prekidi su dostupni a drugi nisu. Na primer, prekid 11, provera poravnjanja (allignment check), javlja se kod procesora 486 pa navi{e. Neki od prekida imaju dve funkcije, kao na primer broj 5. Procesorski prekidi (tipovi 0 - 12) -ove prekide generi{e sam procesor, obi~no kao odziv na neki uslov koji je uzro~nik gre{ke. Na primer, prekid tipa 0 javlja se kada se poku{a deljenje sa nulom. Prekid 0D - gre{ka usled op{te za{tite - je drugi primer. Ovaj prekid }e se generisati uvek kada

Page 12: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-11

program koji se izvr{ava u za{ti}enom na~inu rada poku{a da pristupi podacima ili kodu kojima je dodeljen vi{i nivo privilegije. Softverski prekidi - svi prekidi koje generi{e procesor nisu rezultat neke gre{ke. Na primer prekidi tipa 3 i 4 su softverski prekidi. To su specijalne instrukcije procesora 80x86 koje iniciraju izvr{enje ISR-a. Op{ti oblik instrukcije koja inicira softverski prekid je :

Int broj

Jedna od glavnih prednosti softverskih prekida je ta {to oni omogu}avaju aplikacionom softveru pristup potprogramima bez poznavanja apsolutnih adresa ovih potprograma.

Na primer, programer ne mora da zna apsolutnu adresu ISR-a koja se odnosi na prekidnu ta~ku (breakpoint). On jednostavno ubacuje u program instrukciju INT 3.

Na sli~an na~in, softverski prekidi obezbedjuju pristup BIOS-u i MS-DOS kernelu. Kao {to se vidi sa Slici B.9 prekidi od 10 - 1A se koriste od strane BIOS-a (postoje neka preklapanja sa procesorom), dok prekidi 20 - 3F se koriste od strane MS-DOS kernela. Veliki broj ovih prekida ima svoje subservise ili subfunkcije.

Na Slici B.10 izlistana su 22 subservisa koja su karakteristi~na (prate) prekid 10 - BIOS-ovi video servisi obi~no ovim subservisima i funkcijama pristupa na slede}i na~in: Pre izvr{enja instrukcije Int broj u registar AH se puni broj servisa ili funkcije. Na primer, da bi ispisali jedan znak na video ekranu, koriste}i teku}i video na~in prikaza, potrebno je napisati slede}u sekvencu (kôd)

Mov AH, 0Ah ; BIOS-ov servis 10 u registar AH

Mov AL, ZNAK ; ASCII kod za znak koji }e se prikazivati u AL Int 10h ; poziv BIOS -ove prekidne rutine Hardverski prekidi - inicirani su od strane spoljnih uredjaja. Procesor 80x86 ima rezervisano dva pina za ovu namenu. Prvi se naziva NMI a drugi INTR. Uloga ovih pinova je slede}a: NMI (nonmaskable interrupt) - usponskom ivicom signala na ovom pinu generi{e se prekid tipa 2 i prenosi upravljanje na odgovraju}u prekidnu rutinu (ISR). Ovaj prekid je nemaskiraju}i, a to zna~i da se ne mo`e blokirati. Kod PC-ma{ina ovaj prekid se koristi da prekine rad sistema (shut the system down) kada se kod ~itanja memorije javi gre{ka parnosti u prenosu podataka (~itanje ili upis u memoriju). Drugi pin za prekid je INTR. Ovaj pin omougu}ava spoljnom hardveru da aktivira bilo koji od 256 tipova vektora. Tehnika rada je slede}a: Kada procesor potvrdi da je prihvatio zahtev za prekid preko magistrale podataka predaje mu se broj prekida. Sa ovim jedinstvenim ulaznim pinom, izgleda kao da je procesor ograni~en na prihvatanje samo jednog zahteva za prekid. Ipak, kori{}enjem programibilnog kontrolera prekida kakav je ~ip 8259 mogu}e je sa jednim 8259 prihvatiti do 8 zahteva za prekid a do 64 ulaza sa osam ~ipova 8259. PC ma{ina koristi ovu tehniku za prihvatanje 16 zahteva za prekid preko linija IRQ0 - IRQ15 (koriste se dva ~ipa 8259).

BIOS i DOS programiranje na asemblerskom jeziku

Postoje izuzetno korisni BIOS-ovi i DOS-ovi potprogrami koji su dostupni preko izvr{enjem instrukcije Int. Format ove instrukcije je slede}i

Int n ; broj prekida n se nalazi u opsegu od OO do FF

Ovo zna~i da ukupno postoje 256 prekida. Od svih prekida najpoznatiji su Int 10h i Int 21h. Svaki od ovih prekida mo`e da obavi ve}i broj funkcija. Lista raspolo`ivih funkcija data je na u prilogu na kraju ovog teksta Va`no je zapamtiti slede}e: Pre nego {to se zahteva usluga (servis) Int 10h ili Int 21h, u zavisnosti od funkcije koju `elimo da obavimo, potrebno je napuniti specifi~ne vrednosti u odredjene

Page 13: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-12

registre. Izbor funkcija koju obavlja Int 21h ili Int 10h zavisi od vrednosti koja se upisuje u registar AH.

Interrupt Vector

Number Description CPU BIOS MS-DOS PC 0 Divide error all 1 Single-step all 2 Non-maskable interrupt(NMI) all 3 Breakpoint all 4 Interrupt on overflow all 5 Bound 286 Print screen

6 Invalid op-code 286 7 Coprocesor not available 286,386 7 Device not available 486 8 Double fault 286 Timer IRQ0

9 Coprocessor segment overrun 286,386 IRQ1 Reserved 486 Keyboard

A Invalid task state segment 386 Video IRQ2

B Segment not present 386 Serial port 2 IRQ3

C Stack fault 386 Serial port 1 IRQ4

D General protection fault 286 Second parallel port IRQ5

E Page fault 386 Floppy disk IRQ6

F Reserved X First parallel port IRQ7

10 Coprocessor error 286 Video services X

11 Alignment check 486 Equipment list service X

12 Machine check Pentium Memory size service X

13 Disk services X 14 Communications services X 15 System services X 16 Standard keyboard services X 17 Printer services X 18 Activate ROM BASIC X 19 Activate bootstrap start-up routine X 1A Time and data service X

1B-1F PC hardware specific X 20 Program terminate X 21 General MS-DOS services X 22 Terminate address X 23 Control-C handler X 24 Critical error handler address X 25 Absolute disk read X 26 Absolute disk write X 27 Terminate and stay resident X 28 MS-DOS idle interrupt X

29-2E MS-DOS internal use X 2F Multiplex interrupt X

30-3F MS-DOS internal use X

Page 14: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-13

40-FF PC hardware specific IRQ8-15

Slika B.9 Vektorska tabela kod 80x86

Interrupt Subservice Description 10H 0 Set video mode 1 Set cursor size 2 Set cursor position 3 Read cursor position 4 Read light-pen position 5 Set active display page 6 Scroll window up 7 Scroll window down 8 Read character and attribute 9 Write character and attribute 0A Write character 0B Set 4-color palette 0C Write pixel 0D Read pixel 0E Write character in teletype mode 0F Get current video mode 10 Color palette interface 11 Character generator interface 12 Alternate select 13 Write character string 14 (PC-convertible onli) 15 (PC-convertible onli) 1A Read/write display combination page 1B Return functionality state information 1C Save/restore video state

Slika B.10 BIOS-ovi video servisi

Programiranje koriste}i BIOS-ov Int 10 h

Kod svih PC ma{ina potprogrami (tj. ISR) Int 10h se ~uvaju u ROM BIOS-u a koriste se za komuniciranje sa ekranom ra~unara. Najve}i deo manipulacija sa tesktualnim ili grafi~kim prikazom slike na ekranu monitora se obavlja preko Int 10h. Postoji ve}i broj funkcija koje su pridru`ene Int 10h. Karakteristi~ne su one koje menjaju boju znaka (karaktera), boju pozadine, bri{u sadr`aj slike na ekranu, menjaju lokaciju kursora i dr. Ove opcije se biraju upisom specifi~ne vrednosti u registar AH. Prikaz teksta na ekranu monitora : prikaz tekstualne informacije na ekranu monitora PC ma{ine organizovan je kako je to prikazano na Slici B.11 u 80 kolona*25 vrsta. Ovaj prikaz je identi~an nezavisno od toga da li su monitori crno beli ili kolor. Kada se PC ma{ina uklju~i na napajanje monitor se inicijalno (by default) postavi u tekstualni re`im rada.

Page 15: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-14

00,00 00,79

centar ekrana12,39

24,00 24,79

00,00 00,4F

centar ekrana0C,27

18,00 18,4F

decimalni heksadecimalni

Slika B.11 Lokacija kursora (vrsta, kolona) Brisanje ekrana koriste}i Int 10h funkciju 06h - veoma ~esto pre nego {to se vr{i prikaz potrebno je obrisati podatke na ekranu. Da bi obavili ovu aktivnost koristi se Int 10h i potrebno je postaviti registre na slede}e vrednosti AH = 06, AL = 00, BH = 07, CX =0000, DH = 24 i DL = 79. Programska sekvenca brisanja ima}e oblik

Mov AH, 06 ; AH = 06 bira se funkcija kru`enja

Mov AL, 00 ; AL = 00 cele stranice

Mov BH, 07 ; BH = 07 za standardne atribute

Mov CH, 00 ; CH = 00 vrednost vrste po~etne ta~ke

Mov CL, 00 ; CL = 00 vrednost kolone po~etne ta~ke

Mov DH, 24 ; DH = 24 vrednost vrste krajnje ta~ke

Mov DL, 79 ; DL = 79 vrednost kolone krajnje ta~ke

Int 10h ; poziv prekida

U su{tini opcija AH = 06 prekida Int 10h naziva se funkcija "scroll window up". Efikasnije kodiranje ima slede}i oblik:

Mov AX, 0600h ; "scroll" ceo ekran

Mov BH, 07 ; standardni atribut

Mov CX, 0000 ; po~etak 00, 00

Mov DX, 184Fh ; kraj na 24, 79 (heksa = 18,4 F)

Int 10h Postavljanje kursora na specifi~nu lokaciju: Int 10h funkcija 02 - pomo}u Int 10h funkcije AH = 02 pozicionira se kursor na bilo koju lokaciju. @eljena pozicija kursora se identifikuje pomo}u vrednosti vrste = DH i vrednosti kolone = DL. Nakon izvr{enja Int 10h (ili Int 21h) vrednosti registara ostaju nepromenjene. Sekvenca koja }e postaviti kursor na poziciju vrste=15=0Fh i kolone=25=19h je oblika:

Mov AH, 02 ; postavi poziciju kursora

Mov BH, 00 ; stranica 0

Mov DL, 25 ; pozicija kolone

Mov DH, 15 ; pozicija vrste

Int 10h ; poziv prekida Int 10h

Page 16: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-15

Programska sekvenca koja }e: (1) obrisati sadr`aj ekrana, i (2) postaviti kursor na sredini bi}e oblika

; brisanje ekrana

Mov AX, 06000h Mov BH, 07 Mov CX, 0000 Mov DX, 184Fh Int 10h

; postavljanje kursora na centar ekrana

Mov AH, 02 Mov BH, 00 Mov DL, 39 ; pozicija centralne kolone

Mov DH, 12 ; pozicija centralne vrste

Int 10h Odredjivanje teku}e pozicije kursora pomo}u Int 10 h funkcije 03 - u tekstualnom na~inu rada ~esto se javlja potreba za odredjivanjem lokacije kursora. Sekvenca kojom se obavlja ova aktivnost oblika je :

Mov AH, 03 ; opcija 03

Mov BH, 00 ; stranica 00

Int 10h Nakon izvr{enja ove sekvence DH = teku}a vrsta, DL = teku}a kolona, a u CX bi}e sme{tene informacije o obliku kursora. U tekstualnom na~inu rada, stranica 00 se bira kao teku}e vidljiva stranica. Promena video "mode" - prvo treba naglasiti da nezavisno od tipa adaptera (MDA, CGA, EGA, MCGA, ili VGA) koji se koristi svi {to se ti~e rada su navi{e kompatibilni. Na primer VGA emulira sve funkcije MCGA, EGA, CGA i MDA. Na sli~an na~in EGA emulira funkcije CGA i MDA, i td. Zbog ovoga mora da postoji na~in za promenu video "mode" na `eljeni "mode". Da bi uradili ovo, treba koristiti Int 10h sa AH = 00 i AL = video-"mode". Lista video-"mode"-ova je oblika kao na Slici B.12. Atribut bajt kod monohromatskih monitora - svakom znaku (karakteru) koji se prikazuje na ekranu pridru`uje se atribut. Atribut pru`a informaciju kolima za procesiranje video signala o boji i intenzitetu znaka (foreground) kao i o pozadini (background). Atribut bajt svakog znaka kod monohromatskog monitora je ograni~en a definicija bitova ima oblik kao na Slici B.13.

Page 17: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-16

Char Text/ Max Buffer AL Pixels Characters Box Graph Colors Aadapter Pages Start OHH 320x200 40x25 8x8 text 16* CGA 8 B8000h 320x350 40x25 8x14 text 16* EGA 8 B8000h 360x400 40x25 9x16 text 16* VGA 8 B8000h 320x400 40x25 8x16 text 16* MCGA 8 B8000h 01H 320x200 40x25 8x8 text 16 CGA 8 B8000h 320x350 40x25 8x14 text 16 EGA 8 B8000h 360x400 40x25 9x16 text 16 VGA 8 B8000h 320x400 40x25 8x16 text 16 MCGA 8 B8000h 02H 640x200 80x25 8x8 text 16* CGA 8 B8000h 640x350 80x25 8x14 text 16* EGA 8 B8000h 720x400 80x25 9x16 text 16* VGA 8 B8000h 640x400 80x25 8x16 text 16* MCGA 8 B8000h 03H 640x200 80x25 8x8 text 16 CGA 8 B8000h 640x350 80x25 8x14 text 16 EGA 8 B8000h 720x400 80x25 9x16 text 16 VGA 8 B8000h 640x400 80x25 8x16 text 16 MCGA 8 B8000h 04H 320x200 40x25 8x8 graph 4 CGA 1 B8000h 320x200 40x25 8x8 graph 4 EGA 1 B8000h 320x200 40x25 8x8 graph 4 VGA 1 B8000h 320x200 40x25 8x8 graph 4 MCGA 1 B8000h 05H 320x200 40x25 8x8 graph 4* CGA 1 B8000h 320x200 40x25 8x8 graph 4* EGA 1 B8000h 320x200 40x25 8x8 graph 4* VGA 1 B8000h 320x200 40x25 8x8 graph 4* MCGA 1 B8000h 06H 640x200 80x25 8x8 graph 2 CGA 1 B8000h 640x200 80x25 8x8 graph 2 EGA 1 B8000h 640x200 80x25 8x8 graph 2 VGA 1 B8000h 640x200 80x25 8x8 graph 2 MCGA 1 B8000h 07H 720x350 80x25 9x14 text mono MDA 8 B0000h 720x350 80x25 9x14 text mono EGA 4 B0000h 720x400 80x25 9x16 text mono VGA 8 B0000h 09H reserved 0AH reserved 0BH reserved 0CH reserved 0DH 320x200 40x25 8x8 graph 16 EGA 2/4 A0000H 320x200 40x25 8x8 graph 16 VGA 8 A0000H 0EH 640x200 80x25 8x8 graph 16 EGA 1/2 A0000H 640x200 80x25 8x8 graph 16 VGA 4 A0000H 0FH 640x350 80x25 9x14 graph mono EGA 1 A0000H 640x350 80x25 8x14 graph mono VGA 2 A0000H 10H 640x350 80x25 8x14 graph 4 EGA 1/2 A0000H 640x350 80x25 8x14 graph 16 VGA 2 A0000H 11H 640x480 80x30 8x16 graph 2 VGA 1 A0000H 640x480 80x30 8x16 graph 2 MCGA 1 A0000H 12H 640x480 80x30 8x16 graph 16 VGA 1 A0000H 13H 320x200 40x25 8x8 graph 256 VGA 1 A0000H 320x200 40x25 8x8 graph 256 MCGA 1 A0000H

Slika B.12 Video-"mode"-lista

Page 18: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-17

D7 D6 D5 D4 D3 D2 D1 D0

intenzitet znaka (foreground)

0=normalni intenzitet1=poja~ani intenzitet

intenzitet pozadine (background)

0=bez blinkanja1-sa blinkanjem

Slika B.13 Atribut bajt kod monohromatskog monitora

Neke mogu}e varijacije atributa su: Binarna vrednost heksadecimalna vrednost rezultat

0000 0000 00 belo-na- belo (nema prikaz) 0000 0111 07 belo-na-crno (normalni intgenzitet) 0000 1111 0F belo-na-crno(poja~an intenzitet) 1000 0111 87 belo-nacrno sa blinkanjem 0111 0111 77 crno-nacrno (nema prikaz) 0111 0000 70 crno-na-belo 1111 0000 F0 crno-na-belo sa blinkanjem

Atribut bajt kod CGA tekstualni "mode" - s obzirom da je rad kola za precisiranje video signala kod svih kolor monitora navi{e kompatibilan, za obja{njenje manipulisanja sa bojama koristi}emo CGA "mode" koji je zajedni~ki "sadr`ilac" za sve kolor monitore. Definicija bitova atribut bajta kod kolor monitora koji radi u CGA tekstualni "mode" prikazana je na Slici B.14.

D3D7 D6 D5 D4 D2 D1 D0

boja znaka (foreground)

intenzitet

boja pozadine

blinkanje

(blinkanje i intenzitet se odnose samona “foreground”)

B R G B I R G B

Slika B.14 Atribut bajt kod CGA

Analiziraju}i Sliku B.14 mo`e se zaklju~iti slede}e: (a) kombinovanjem primarnih boja R, G i B pozadina mo`e bitri obojena u jednoj od osam boja (b) kominovanjem primarnih boja R, G i B sa bitom za intenzitet I tekstualna informacija koja se prikaxuje se mo`e prikazati u 16 razli~itih boja (definicija 16 mogu}ih boja prikazana je na Slici B.13).

Page 19: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-18

I R G B boja 0 0 0 0 crna 0 0 0 1 plava 0 0 1 0 zelena 0 0 1 1 cijan 0 1 0 0 crvena 0 1 0 1 magenta 0 1 1 0 braon 0 1 1 1 bela 1 0 0 0 siva 1 0 0 1 svetlo plava 1 0 1 0 svetlo zelena 1 0 1 1 svetlo cijan 1 1 0 0 svetlo crvena 1 1 0 1 svetlo magenta 1 1 1 0 `uta 1 1 1 1 jako bela

Slika B.15: 16 mogu}ih boja

Ilustracije radi, programska sekvenca kojom se ispisuju po celom ekranu karakteri 20h (ASCII blanko) koriste}i jako belo na plavoj pozadini za CGA "mode" ima}e oblik Mov SH,00 ; postavi opciju mode

Mov AL, 03 ; CGA kolor tekstualni mode formata 80 * 25

Int 10h Mov AH, 09 ; opcija prikaza

Mov BH, 00 ; stranica 0

Mov AL, 20h ; ASCII kod za blanko

Mov CX, 800h ; ponovi 800h puta

Mov BL, 1Fh ; jako belo na plavo

Int 10h Direktni pristup memoriji ekrana za tekstujalni prikaz - I pored toga {to se ne preporu~uje, "hrabriji" programeri se ~esto odlu~uju za direktni pristup video-memoriji ekrana u tekstualnom na~inu rada. Da bi pokazali kako se to radi analizira}emo VGA 25*80 tekstualni "mode". Memorija ekrana po~inje od lokacije B800:0000. Znak koji se prikazuje na poziciji 00,00 (Slika B.11) je sme{ten u memorijskim lokacijama B800:0000 i B800:0001. Naredni karakter bi}e sme{ten na lokacijama B800:0002 i B800:0003, itd. Ovo zna~i da svaki znak (karakter) zauzima prostor od dve memorijske lokacije. Prvi predstavlja ASCII kodirani znak koji se prikazuje, a drugi se odnosi na atribut bajt kojim se opisuje boja znaka, boja pozadine i da li znak blinka ili ne. Analizira}emo sada jednu kratku programsku sekvencu kojom se smek{ta ASCII kod blanko (20h) na svim pozicijama teku}e stranice ekrana i atribut kojim se defini{e beo znak, crna pozadina, bez blinkanja. Sekvenca je oblika

CODE SEGMENT brisanje ; po~etak kodnog segmenta

ASUME CS : CODE MAIN PROC FAR ; po~etak procedure MAIN

ced ; izbor autokrementalnai na~in rada

Page 20: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-19

Mov AX, 0B800h ; adresa segmenta memorije prikaza

Mov ES, AX Mov DI, 0 ; ofset adresa memorije prikaza

Mov CX, 25*80 ; CX = broja~ karaktera

Mov AX, 0720h ; napuni karakter i boju

Rep Stosw ; ponovi Stosw 2000 puta

Mov AX, 4C00h ; izlaz na DOS

Int 21h MAIN Endp CODE Ends End MAIN Vi{e detalja o naredbi Int 21h je dato u okviru prekida Int 21h (tekst koji sledi).

DOS funkcijski poziv Int 21 h

Pored BIOS-ih servisa kakav je Int 10h koji se ~uva u ROM-u, i DOS mo`e da obezbedi usluge koje su obi~na slo`enije od BIOS-ih. Pristup DOS-im funkcijskim pozivima ostvaruje se na identi~an na~in kao i kod BIOS-a - softrverskim prekidima. Int 21h je tipi~an funkcijski poziv DOS-a koji obavlja izuzetno korisne funkcije. Delimi~na lista ovih opcija prikazana je u prilogu na kraju teksta. U tekstu koji sledi ukaza}emo samo na neke od njih. Int 21h opcija 09 : predaja niza podataka monitoru Int 21h se mo`e koristiti za predaju skupa ASCII podataka ka monitoru. Ova aktivnost se obavlja na slede}i na~in: Postavlja se AH = 09 a DX = ofset adresa ASCII podataka koji se prikazuju. Zatim se poziva Int 21h. Kraj teksta koji se prikazuje markiran je znakom '$'. Jedna tipi~na programska sekvenca ima oblik

ASCII_TEKST DB "Test koji se prikazuje", '$' Mov AH, 09 ; opcija 09 prikaz niza podataka

Mov DX,OFFSET ASCII_TEKST;DS:DX par segmenta i ofset adresa podataka

Int 21h ; poziv prekida

Int 21 h opcija 02 : predaja jednog podatka monitoru

Postoje slu~ajevi kada postoji potreba da se preda samo jedan podatak monitoru. Da bi se obavilo to neophodno je postaviti AH = 02 a DL = podatak koji se prikazuje, a zatim se poziva Int 21 h. Sekvenca kojom se vr}i prikaz slova 'M' ima oblik Mov AH, 02 ; izbor opcije 02 prikaz jednog karaktera Mov DL, 'M' ; DL = karakter koji se prikazuje Int 21h ; poziv prekida Int 21 h opcija 01 : unos jednog znaka sa ehom Ova funkcija ~eka da se znak primi sa tastature a zatim ga predaje monitoru ~ime ostvaruje subjektivni ose}aj eha prema korisniku. Nakon izvr{enja prekida, ulazni karakter se nalazi u AL. Sekvenca je oblika:

Mov AH, 01 ; opcija 01 - unos jednog podatka

Int 21 h ; nakon prekida AL = uneti ASCII znak

Page 21: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-20

Slede}a programska sekvenca kombinuje Int 10h sa Int 21h. Program obavlja slede}e aktivnosti : (1) bri{e ekran; (2) postavlja kursor na centar ekrana, i (3) po~ev{i od te ta~ke ispisuje poruku "Ovaj tekst predstavlja rutinu za prikaz".

TITLE PROG_D Program za prikaz PAGE 60, 132

; segment magacina

SMAG SEGMENT DB 64 DUP (?) SMAG Ends

; segment podataka

SPOD SEGMENT PORUKA DB 'Ovaj tekst predstavlja rutinu za prikaz','S' SPOD Ends

; kodni segment

SKOD SEGMENT GLAVNI PROC FAR ASSUME CS : SKOD, DS : SPOD, SS : SMAG Mov AX, SPOD Mov DS, AX Call BRISANJE ; obri{i ekran

Call KURSOR ; postavi poziciju kursora

Call PRIKAZ ; prika`i poruku

Mov AH, 4Ch Int 21h ; povratak na DOS

GLAVNI Endp ; ovaj potprogram bri{e ekran

BRISANJE PROC Mov AX, 0600h ; "scroll" funkcija za ekran

Mov BH, 07 ; normalni atribut

Mov CX, 0000 ; bri{i od vrste=00,i kolone=00

Mov DX, 184Fh ; do vrste=18 h, i kolone=4Fh

Int 10h ; pozivi prekid za brisanje

Ret BRISANJE Endp

; ovaj 'potprogram' se koristi za postavljanje kursora na centar enrana

KURSOR PROC Mov AX, 02 ; postavi funkciju kursora Mov BH, 00 ; stranica 00

Page 22: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-21

Mov DX, 12 ; centralna vrsta Mov DL, 39 ; centralna kolona

Int 10h ; pozivi prekid da postavi kursor

Ret KURSOR Endp

; ovaj potprogram prikazuje niz na ekranu

PRIKAZ PROC Mov AH, 09 ; funkcija prikaza

Mov DX, OFFSET PORUKA ; DX pokazuje na izlazni bafer

Int 21h ; pozovi prekid-prikaz poruke

Ret PRIKAZ Endp SKOD Ends END GLAVNI Int 21 h opcija 0A h : ulaz niza podataka sa tastature Opcija 0Ah od Int 21h obezbedjuje da se prihvate podaci sa tastature i smeste u unapred definisanu oblast memorije u segmentu podataka. Da bi obavitili ovo neophodno je da : AH=0Ah, DX=ofset adresa na koji se sme{ta niz podataka. Oblast gde se sme{taju podaci naziva se baferska oblast. DOS zahteva da oblast bafera bude definisana u segmentu podataka a da pri bajt specificira obim bafera. DOS }e sme{tati broj karaktera koji se prihvataju preko tastature u drugom bajtu u podatak koji se prihvata preko tastature se sme{ta u baferu po~ev od tre}eg bajta. Slede}a programska sekvenca prihvati}e do 6 karaktera sa tastature, uklju~uju}i i "carriage return" dirku. [est lokacija je rezervisano u baferu i one su popunjene sa FFh.

ORG 0010h PODACI DB 6,?,6 DUP (FF) ; 0010h = 06, 0-012h do 0017h =FF

Mov AH, 0Ah ; opcija unos niza preko Int 21h

Mov DX, OFFSET PODACI ; napuni ofset adresu u bafer

Int 21h ; pozovi prekid 21h

Sadr`aj memorije na ofset adrese 0010 h pre poziva Int 21h je ofset adresa sadr`aj 0010 06 0011 00 0012 FF 0013 FF 0014 FF 0015 FF 0016 FF 0017 FF Kada se program izvr{ava on ~eka da se primi informacija sa tastature. Pod uslovom da smo otkucali "ELEF"<RETURN>, sadr`aj memorije po~ev od ofset lokacije 0010 h bi}e

0010 06 ; obim bafera 0011 04 ; otkucana su ~etiri karaktera 0012 45 ; ASCII kod E 0013 4C ; ASCII kod L

Page 23: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-22

0014 45 : ASCII kod E 0015 46 ; ASCII kod F 0016 0D ; ASCII kod CR (carriage return) 0017 FF

Interesantno je sagledati kako se od strane DOS-a pristupa broja~u karaktera, tj. drugom bajtu. Jedan od na~ina je slede}i

Mov AH,0Ah Mov DX,OFFSET PODACI Int 21h ; nakon {to je podatak sa tastature prihva}en, pribavi se ; vrednost broja~a na slede}i na~in

Mov BX, OFFSET PODACI Sub CH, CH ; Ch = 00

Mov CL, BX + 1 ; kopiraj broja~ u CL

Da bi locirali karakter CR, tj. vrednost 0Dh, u nizu i zamenili je sa, recimo 00h, potrebno je izvr{iti slede}u sekvencu

Mov SI, CX Mov BYTE PTR BX+SI+2,00 Aktuelno uneti podatak se memori{e na lokaciju BX + 2.

Unos ve}eg broja podataka od obima bafera

Analizirajmo sada {to }e se desiti ako se unese ve}i broj karaktera od {est (5 znakova + CR = 6). Unos poruke "ELEF se nalazi u Ni{u" <RETURN> uzrokova}e da ra~unar generi{e tonski signal a sadr`aj bafera bli}e slede}i:

ofset adresa sadr`aj 0010 06 0011 05 0012 45 0013 4C 0014 45 0015 46 0016 20 ; blanko 0017 OD ; ASCII kod za CR

Lokacija 0016 ~uva ASCII 20h za blanko karakter koji se u izvornom tekstu nalazi izmedju 'ELEF' i 'se nalazi u Ni{u'. Interesantno je sagledati {ta }e se desiti ako se aktivira samo dirka CR, kao u slede}em primeru

ORG 20h POD_2 DB 5, ?, 5 DUP (FF) Sadr`aj memorije nakon izvr{enja sekvence bi}e:

ofset adresa sadr`aj 0020 05 0021 00 0022 0D

Page 24: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-23

0023 FF 0024 FF 0025 FF 0026 FF Stvarni broj karaktera koji je unet iznosi 0 i on se nalazi na lokaciji 0021. Treba ukazati da svaki podatak koji se unosi preko tastature prikazuje se na ekranu, tj. koristi se princip eho. Program koga }emo analizirati obavlja slede}e aktivnosti: (a) bri{e ekran; (b) postavlja kursor na po~etak tre}e linije od vrha ekrana, (c) prihvata poruku "Studiram na ELEF-u", (d) konvertuje mala slova poruke u velika, (e) prikazuje rezultat konvertovane poruke u narednoj liniji.

TITLE PROG2 Student Mika page 60,132

; segment magacina

SMAG SEGMENT DB 100 DUP((?) SMAG Ends

; segment podataka

SPOD SEGMENT BAFFER DB 19,?,19 DUP(?) ;bafer podataka sa tastature

ORG 18h OB_POD DB CR,LF,19 DUP(?),'$'; oblast gde se sme{taju podaci nakon konverzije

SPOD Ends CR EQU 0Dh LF EQU 0Ah

; kodni segment

PSEG SEGMENT GLAVNI PROC FAR ASSUME CS : PSEG, DS : SPOD; SS : SMAG Mov AX, SPOD Mov DS, AX Call OBRISI : obri{i ekran

Call KURSOR : postavi poziciju kursora

Call PRIHVAT ; upi{i niz u bafer

Call KONVER ; konverziju niza u velika slova

Call PRIKAZ ; prika`i oblast podataka

Mov AH, 4Dh Int 21h ; povratak na DOS

GLAVNI Endp ; potprogram za brisanje ekrana

OBRISI PROC

Page 25: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-24

Mov AX, 0600 ; funcija "scroll" ekrana

Mov BH, 07 ; standardni atribut

Mov CX, 0000 ; vrsta = 00, kolona = 00

Mov DX,184Fh ; do vrste 18h, kolone 4Fh

Int 10h Ret OBRISI Endp

; ovaj potprogram postavlja kursor na po~etak tre}e vrste

KURSOR PROC Mov AX,06 ; funcija postavi kursora

Mov BH,00 ; stranica 00

Mov DL,01 ; kolona 1

Mov DH,03 ; vrsta 3

Int 10h ; pozovi funciju postavi kursora

Ret KURSOR Endp

; ovaj potprogram prikazuje niz na ekranu

PRIKAZ PROC Mov AH,09 ; funkcija prikaz niza

Mov DX,OFFSET OB_POD ; DX pokazuje na bafer

Int 21h ; poziv prekida~a prikaz

Ret PRIKAZ Endp

; ovaj potprogram sme{ta podatke sa tastature u bafer

PRIHVAT PROC Mov AH,0Ah ; funkcija unos niza

Mov DX, OFFSET BAFER ; DX pokazxuje na bafer

Int 21h ; poziv prekida

Ret PRIHVATI Endp

; ovaj potprogram konvertuje mala slova u velika

KONVER PROC Mov BX,OFFSET BAFER Mov CL,BX + 1 ; dobavi broj karaktera

Sub CH, CH ; CX=ukupan broj karaktera

Mov DI, CX ; indeks bafera

Mov BYTE PTR BX+DI +2, 20h ; zameni CR sa blanko

Mov SI,OFFSET OB_POD+2 ; adresa niza

Ponovi: Mov AL, BX + 2 ; dobavi otkucani podatak

Page 26: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-25

Cmp 61h ; provera da li je 'a'

JB Naredni ; ako je manji, idi na Naredni

Cmp AL, 7A h ; proveri sa 'Z'

JA Naredni ; ako je iznad ili na Naredni

And AL,11011111b ; konvertuj ga u veliko slovo

Naredni Mov SI,AL ; smesti u oblast podataka

Inc Si ; inkrementiraj broja~a

Inc BI Loop Ponovi ; broja~ petlje = 0

Ret KONVER Endp PSEG Ends End GLAVNI

Kori{}enje CR i LF

U prethodnoj programskoj sekvenci pomo}u EQU iskaza CR (carriage return) je bio dodeljen ASCII kôd 0Dh, a LF (line fead) ASCII kôd 0Ah. Rezultat konverzije je bio slede}i: Prikaz konvertovanog teksta je bio u novi red zahvaljuju}i tome {to su poruci prethodili karakteri CR i LF. Za slu~aj da ne postoji CR, tekst bi se prikazivao od one pozicije korsora koja se teku}e zatekne pa nadalje. U slu~aju da ima CR a nema LF, konvertovani niz bi se prikazivao u istoj liniji i to od po~etka tako da bi se preko starih karaktera kucali novi (konvetovani), tj. stari tekst bi bio zamenjen novim. Kombinacija CR i LF dovodi do pozicioniranja kursora na po~etak novog reda (u konkretnom slu~aju je to ~etvrti red). Programska sekvenca koja sledi prikazuje ime i prezime korisnika. Prezime mo`e biti duga~ko maksimalno 8 slova. Nakon uno{enja prezimena program prikazuje njegovu du`inu na ekranu. Ova sekvenca prikazuje veliki broj funkcija koje su do sada bile analizirane.

TITLE PROG_3 citaj ime i prezime i prika`i du`inu PAGE 60, 32 ; segment magacina SMAG SEGMENT DB 100 DUP (?) SMAG Ends ; segment podataka SPOD SEGMENT PORUKA1 DB 'Vase prezime?''$' ORG 20 h BAFFER1 DB 9, ?, 9 DUP (0) ORG 30h PODUKA 2 DB, CR,LF, ' Broj slova u va{em imenu je:','$' SPOD Ends VRSTA EQU 08

Page 27: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-26

KOLONA EQU 05 CR EQU 0D h ; CR = 0Dh LF EQU 0A h ; LF = 0Ah

; segment programa

PSEG SEGMENT GLAVNI PROC FAC ASSUME CS : PSEG, DS : SPOD, SS : SMAG Mov AX,SPOD Mov DSAX Call OBRISI Call KURSOR Mov AH,09 ; prika`i PROMPT

Mov DX,OFFSET PORUKA 1 Int 21h Mov AH,0Ah ; prihvati ime sa tastature

Mov DX,OFFSET BAFER1 InT 21h Mov BX,OFFSET BAFER1 ; odredi broj slova u prezimenu

Mov CL,BX + 1 ; dobavi broj slova u CL

Or CL, 30h ; kodiraj ih kao ASCII

Mov PORUKA2 + 40, CL ; smesti na kraju niza

Mov AH,09 ; prika`i drugu poruku

Mov DX, OFFSET PORUKA 2 Int 21h Mov AH, 4Ch Int 21h ; povratak na DOS

GLAVNI Endp ; procedura za brisanje

BRISANJE PROC ; obri{i ekran

Mov AX, 0600h Mov BH, 07 Mov CX, 0000 Mov DX, 184Fh Int 10h Ret OBRISI Endp

; procedura kursor

KURSOR PROC ; postavi kursor na poziciju

Mov AH,02

Page 28: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-27

Mov BH,00 Mov DL,KOLONA Mov DH,VRSTA Int 10h Ret KURSOR Endp PSEG Ends End GLAVNI

BIOS Int 16H - programiranje tastature

Int 16 h je BIOS-ov prekid koji se isklju~ivo koristi za tastaturu. Provera da li je pritisnuta dirka - da bi proveriti da li neka dirka pritisnuta koristi se Int 16h funkcija AH = 01 na slede}i na~in

Mov AH,01 ; proveri pritisnutu dirku

Int 16h ; pozovi Int 16h

Nakon povratka ZF = 0 ako nije pritisnuta dirka, a ZF = 1 ako je bilo koja dirka pritisnuta. Koja je dirka pritisnuta - ~esto je potrebno da saznamo ne samo da li je neka dirka pritisnuta nego i kod te dirke. Da bi obavili to odmah nakon Int 16h, funkcija AH = 01, treba koristiti Int 16h funkciju 00 h, tj.

Mov AH,00 ; dobavi kôd pritisnute dirke

Int 16h Nakon povratka u AL se nalazi kod pritisnute ASCII dirke. Slede}a programska sekvenca prikazuje na~in kori{}enja Int 16h.

TITLE PROG4 Kori{}enje prekida Int 16 h ; ovaj program generi{e tonski signal uvek nakon {to se

; pritisne bilo koja dirka

.MODEL SMALL .STACK .DATA PORUKA DB 'Pritisni bilo koju dirku da bi ukinuo ton ','$' .CODE GLAVNI PROC Mov AX,DATA Mov DS,AX Mov AH,09 Mov DX,OFFSET PORUKA ; prika`i poruku

Int 21h PONOVI Mov AH,02 ; {alji ka monitoru jedan znak

Moy DL,07 ; predaj znak tonskog signala

Int 21h

Page 29: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-28

Moy AH,01 ; proveri pritisnutu dirku

Int 16h JZ PONOVI ; ako nije pritisnuta vrati se u petlju

Mov AH, 4Ch ; ako je pritisnuta bilo koja dirka vrati se na DOS

Int 21h GLAVNI Endp End

Page 30: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-29

Section B.2 DOS INTERRUPT 21H AND 33H LISTING

This appendix lists many of the DOS 21H interrupts, which are used primarily for iNput, output, and file and memory management. In addition, this appendix covers some functions of INT 33 H, the mouse handLing interrupt. As was mentioned in Chapter 6, this interrupt is not a part of DOS or BIOS, but is part of the mouse driver software.

Section B.2.1 DOS 21H INTERRUPTS

First, before covering the DOS 21H interrupts, a few notes are given about file management under DOS. There are two commonly used ways to access files in DOS. One is through what is called a file handle, the other is through an FCB, or file control block. These terms are defined in detail below. Function calls 0FH through 28H use FCBs to access files. Function calls 39 H through 62 H use file handles. Handle calls are more powerful and easier to use. However, FCB calls maintain compatibillity down to DOS version 1.10 FCB calls have the furher lilmitation that they reference only the files in the current directory, wheras handle calls reference any file in any directory. FCB calls use the file control block to perorm any function on a file. Handle calls use an ASCIIZ string (defined below) to open, create, delete or rename a file, and use a file handle for I/O requests. There are some terms used in the interrupt listing that will be unfamiliar to many readers. DOS manuals provide complete coverage of the details of file managment, but a few key terms are defined below.

ASCIIZ string

This is a string composes of any combination of ASCII characters and terminated with one byte of binary zeros (00H). It is frequently used in DOS 21 H interrupt calls to specify a filename or path. The following is an example of an ASCIIZ string that was defined in the data segment of a program: NAME_1 DB ’C:\PROGRAMS/SYSTEM_A\PROGRAM5.ASM’,0

Directory

DOS keeps track of where files are located by means of a directory. Each disk can be partitioned into one or more directories. The directory lists each file in that directory, the number of bytes in the file, the date and time the file was created, and other information that DOS needs to access that file. The familiar DOS command “DIR” lists the directory of the current drive to the monitor.

DTA Disk transfer area

This is essentially a buffer area that DOS will use to hold data for reads or writes performed with FCB function calls. This area can be set up by your program anywhere in the data segment. Function call 1AH tells DOS the location of the DTA. Only one DTA can be active at a time.

FAT File allocation table

Each disk has a file allocation table that gives information about the clulsters on a disk. Each disk is divided into sectors, which are grouped into clulsters. The size of sectors and clusters varies among the different disk types. For each cluster in the disk, the FAT has a code indicating whether the cluster is being used by a file, is available, is reserved, or has been marked as a bad clulster. DOS this information in storing and retrieving files.

FCB File control block

One FCB is associated with each open file. It is composed of 37 bytes of data that give information about a file, such as drive, filename and extension, size of the file in bytes, and date and time it was

Page 31: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-30

created. It also stores the current block and record numbers, which serve as pointers ilnto a file when it is being read or written to. DOS INT 21H function calls 0FH through 28H use FCBs to access files. Function 0FH is used to open a file, 16H to create a new file. Function calls 14H - 28H perform read/write functions on the file, and 16H is used to close the file. Typically, the filename information is set up with function call 29H (Parse File- name), and then the address of the FCB is placed in DS:DX and is used to access the file.

File handle

DOS function calls 3CH through 62H use file handles. When a file or device is created or opened with one of these calls, its file handle is returned. The file handle is used thereafter to refer to that file for input, closing the file, and so on. DOS has a few predefined file handles that can be used by any Assembly language program. These do not need to be opened before they are used: Handle value Refers to 0000 standard input device (typicallly, the keyboard) 0001 standard output device (typically, the monitor) 0002 standard error output device (typically, the monitor) 0003 standard auxiliary device (AUX1) 0004 standard printer device (PTR1)

PSP Program segment prefix

The PSP is a 256-byte area of memory reserved by DOS for each program. It provides an area to store chared information between the program and DOS. AH Function of INT 21H 00 Terminate the program Additional Call Register Result Registers CS = segment address of None

PSP (program segment prefix) Note: Files should be closed previously or data may be lost.

01 Keyboard input with echo Additional Call Registers Result Registers None AL = input character

Note: Checks for ctri-break. 02 Output character to monitor

Additional Call Register Result Registers DL = character to be displayed None

03 Asynchronous input from auxiliary device (serial device)

Additional Call Registers Result Registers None AL = input character

Page 32: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-31

AH Function of INT 21H 04 Asynchronous character output

Additional Call Registers Result Registers DL = charactet to be output None

05 Output character to printer

Additional Call Registers Result Registers DL = character to be printed None

06 Console I/O

Additional Call Registers Result Registers DL = OFFH if input AL = 0H if no character available or character to be = character that was input, if input successful displayed, if output

Note: if input, ZF is cleared and AL will have the character. ZF is set if input and no character was available.

07 Keyboard input without echo

Additional Call Registers Result Registers None AL = input character

Note: Does not check for ctrl-break. 08 Keyboard input without echo

Additional Call Registers Result Registers None AL= input character

Note: Checks for ctrl-break. 09 String output Additional Call Registers Result Registers

DS:DX = string address None Note: Displays characters beginning at address until a “$” (ASCII 36) is encountered.

0A String input Additional Call Registers Result Registers

DS:DX = address at which to store string None Note: Specify the maximum size of the string in byte 1 of the buffer. DOS will place the actual size of the string in byte 2. The string begins in byte 3.

Page 33: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-32

AH Function of INT 21H 0B Get keyboard status Additional Call Registers Result Registers

None AL= 00 if no character waiting = CFFH if character waiting

Note: Checks for ctrl-break. 0C Reset input buffer and call keyboard input function Additional Call Registers Result Registers

AL = keyboard function number None 01H, 06H, 07H, 08H or OAH Note: This function waits until a character is typed in.

0D Reset disk Additional Call Registers Result Registers

None None

Note: Flushes DOS file buffers but does not close files. 0E Set default drive Additional Call Registers Result Registers DL = code for drive AL = number of logical drives

(0=A, 1=B, 2=C, etc.) in system 0F Open file Additional Call Registers Result Registers DS:DX = address of FCB AL = 00 if succesful

= 0FFH if file not found

Note: Searches current directory for file. If found, FCB is filled. 10 Close file Additional Call Registers Result Registers DS:DX = address of FCB AL = 00 if successful

= 0FFH if file not found

Note: Flushes all buffers. Also updates directory if file has been modified. AH Function of INT 21H

Page 34: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-33

11 Search for first matching filename Additional Call Registers Result Registers DS:DX = address of FCB AL = 00 if match is found

`= 0FFH if no match found

Note: File names can contain wildcards “?” and “”. 12 Search for next match

Additional Call Registers Result Registers DS:DX = address of FCB AL = 00 if match is found

= 0FFH if no match found

Note: This call should be used only if previous call to 11H has been successful. 13 Delete file(s)

Additional Call Registers Result Registers DS:DX = address of FCB AL = 00 if file(s)deleted

= 0FFH if no files deleted

Note: Deletes all files in current directory matching filename, provided that they are not read-only. Files should be closed before deleting.

14 Sequential read

Additional Call Registers Result Registers DS:DX = address of operand FCB AL = 00H if read successful

= 01H if end of file and no date is read = 02H if DTA is too smail to hold the record. = 03H if partial recortd read and end of file is reached

Note: The file pointer, block pointer, and FCB record pointer are updated automatically by DOS

15 Sequential write

Additional Call Registers Result Registers DS:DX = address of operand FCB AL = 00H if write successful

= 01H if diskis ful = 02H if DTA is too small to hold the record.

Note: The file pointer, block pointer, and FCB record pointer are updated automatically by DOS. The record may not be written physically until a cluster is full or the file is closed.

AH Function of INT 21H

Page 35: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-34

16 Crate/open a file

Additional Call Registers Result Registers DS:DX = address of unopened FCB AL = 00H if successful

= 0FFH if unsuccessful

Note: If the file already exists, it will be truncated to length 0. 17 Rename file(s)

Additional Call Registers Result Registers DS:DX = address of FCB AL = 00H if file(s) renamed

= 0FF if file not found or new name already exists.

Note: The old name is in the name position of the FCB: the new name is at the size (offset 16H) position.

18 Reserved 19 Get default drive Additional Call Registers Result Registers

None AL = 0H fore drive A = 1H for drive B = 2H for drive C

1A Specify DTA (disk transfer address)

Additional Call Registers Result Registers DS:DX = DTA None Note: Only one DTA can be current at a time. This function must be called before FCB reads, writes, and directory searches.

1B Get FAT (file allocation table) for default drive Additional Call Registers Result Registers None AL = number of sectors per cluster

CX = number of bytes per sector DX = number of cluster per disk DS:BX FAT id

1C Get FAT (file allocation table) for any drive Additional Call Registers Result Registers

DL = drive code AL = number of sectors per cluster 0 for A; 1 for B; 2 for C CX = number of bytes per sector DX = number of cluster per disk

DS:BX FAT id AH Function of INT 21H

Page 36: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-35

1D Reserved 1E Reserved 1F Reserved 20 Reserved 21 Random read

Additional Call Registers Result Registers DS:DX = address of operand FCB AL = 00H if read successful

= 01H if end of file and no data read = 02H if DTA too smail for record. = 03H if end fo file and partial read.

Note: Reads record pointed at by current block and record fields into DTA 22 Random write

Additional Call Registers Result Registers DS:DX = address of operand FCB AL = 00H if write successful

= 01H if disk is full = 02H if DTA too small for record

Note: Writes from DTA to record pointed at by current block and record fields. 23 Get file size

Additional Call Registers Result Registers DS:DX = address of unopened FCB AL = 00H if file found, number of records is

set in FCB random-record field (offset 0021 H) = 0FFH if no match found

Note: The FCB should contain the record size before the interrupt.

24 Set random record field

Additional Call Registers Result Registers DS:DX = address of opened FCB None Note: This sets the random-record field (offset 0021H) in the FCB. It is used prior to switching from sequential to random processing.

AH Funcion of INT 21H

Page 37: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-36

25 Set interrupt vector

Additional Call Registers Result Registers DS:DX = interrupt handler addr. None AL = machine interrupt number

Note: This is used to change the way thesystem handles interrupts.

26 Create a new PSP (program segment prefix)

Additional Call Registers Result Registers DX = segment addr. of new PSP None Note: DOS versions 2.0 and higher recommend not using this service, but using service 4B (exec).

27 Random block read Additional Call Registers Result Registers DS:DX = address of opened FCB AL = 00H if read successful CX = number records to be read = 01H if end of file and no data read = 02H if DTA too smail for block = 03H if EOF and partial block read CX = number of records actually read

Note: Set the FCB random record and record size fields prior to the interrupt. DOS will update the random record, current block, and current record fields after the read.

28 Random block write Additional Call Registers Result Registers DS:DX = address of opened FCB AL = 00H if read successful CX = number records to be write = 01H if disk is full = 02H if DTA too smail for block = 03H if EOF and partial block read CX = number of records actually written

Note: Set the FCB random record and record size fields prior to the interrupt. DOS will update the random record, current block and current record fields after the write. If CX = 0 prior to the interrupt, nothing is written to the file and the file is truncated or extended to the length computed by the random record and redord size fields.

AH Function of INT 21H 29 Parse filename

Page 38: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-37

Additional Call Registers Result Registers DS:SI = address of command line DS:SI = address of first char after ES:DI = address of FCB ES:DI = address of first byte of AL = parsing flags in bits 0-3 formatted unopened FCB Bit 0 = 1 if leading separators AL = 00H if no wildcards were in are to be ignored: otherwise filename of extension no scan-off takes place = 01H if wildcard found Bit 1 = 1 if drive ID in FCB = 0FFH if drive specifier is invalid will be changed only if drive was specified in command line Bit 2 = 1 if filename will be changed only if filename was specified in command line Bit 3 = 1 if extension will be changed only if extension was specified in command line

Note: The command line is parsed for a filename, then an unopened FCB is created at DS:SI. The command should not be used if path names are specified.

2A Get system date Additional Call Registers Result Registers None CX = year (1980-2099) DH = month (1-12) DL = day (1-31) AL = day of week code (0 = Sunday,..., 6 = Saturday) 2B Set system date Additional Call Registers Result Registers CX = year (1980-2099) AL = 00H if date set DH = month (1-12) = 0FFH if date not valid DL = day (1-31) 2C Get system time Additional Call Registers Result Registers None CH = hour (0..23) CL = minute (0..59) DH = second (0..59) DL = hundredth of second (0..99)

Note: The format returned can be used in calculations but can be converted to a printable format.

AH Function of INT 21H 2D Set system time

Page 39: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-38

Additional Call Registers Result Registers CH = hour (0..23) AL = 00H if time set CL = minute = 0FFH if time invalid DH = second DL = hundredth of second 2E Set/reset verify switch Additional Call Registers Result Registers AL = 0 to turn verify off None = 1 to turn verify on

Note: If verify is on. DOS will perform a verify every time data is written to disk. An interrupt call to 54H gets the setting of the verify switch.

2F Get DTA (disk transfer area) Additional Call Registers Result Registers None ES:BX = address of DTA 30 Get system time Additional Call Registers Result Registers None AL = major version number (0,2,3,etc.) AH = minor version number 31 Terminate process and stay resident (KEEP process) Additional Call Registers Result Registers AL = binary return code None DX = memory size in paragraphs

Note: This interrupt call terminates the current process and attempt to place the memory size in paragraphs in the initial allocation block, but does not release any other allocation blocks. The return code in AL can be retrieved by the parent process using interrupt 21 call 4DH.

32 Reserved 33 Ctrl-break control Additional Call Registers Result Registers AL = 00 to get state of ctrl-break check DL = 00 if ctrl-break check off = 01 to modify state of ctrl-break check = 01 if ctrl-break check on DL = 00 to turn check off = 01 to turn check on

Note: When ctrl-break check is set to off, DOS minimizes the times it checks for ctrl-break input. When it is set to on, DOS checks for ctrl-break on most operations.

AH Function of INT 21H 34 Reserved

Page 40: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-39

35 Get interrupt vector address Additional Call Registers Result Registers AL = interrupt number ES:BX = address of interrupt handler 36 Get free disk space Additional Call Registers Result Registers DL = drive code AX = FFFFH if drive code invalid (0 = default, = sectors per cluster if valid 1 = A, 2 = B, etc.) BX = number of available clusters CX = bytes per sector DX = total clusters per drive 37 Reserved 38 Country dependent information Additional Call Registers Result Registers DS:DX = address of 32-byte None block of memory AL = function code 39 Create subdirectory (MKDIR) Additional Call Registers Result Registers DS:DX = address of ASCIIZ path Carry flag = 0 if successful name of new subdirectory = 1 if failed = 5 if access denied AX = 3 if path not found 3A Remove subdirectory (RMDIR) Additional Call Registers Result Registers DS:DX = address of ASCIIZ path Carry flag = 0 if successful name of new subdirectory = 1 if failed AX = 3 if path not found = 5 if directory not empty = 15 if drive invalid

Note: The current directory cannot be removed. AH Function of INT 21H 3B Change the current subdirectory (CHDIR)

Page 41: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-40

Additional Call Registers Result Registers DS:DX = address of ASCIIZ path Carry flag = 0 if successful name of new subdirectory = 1 if failed AX = 3 if path not found 3C Create a file Additional Call Registers Result Registers DS:DX = address of ASCIIZ path Carry flag = 0 if successful and file name = 1 if failed CX = file attribute AX = handle if successful = 3 if path not found = 5 if access denied

Note: Creates a new file if filename does not exist, otherwise truncates the file to lenght zero. Opens the file for reading or writing. A 16-bit handle will be returned in AX if the create was successful.

3D Open file Additional Call Registers Result Registers DS:DX = address of ASCIIZ path Carry flag = 0 if successful and file name = 1 if failed AL = mode flags (see below) AX = 16-bit handle if successful = 1 if function number invalid = 2 if file not found = 3 if path not found = 4 if handle not available = 5 if access denied = 0CH if access code invalid AL mode flag summary: 7 6 5 4 3 2 1 0 (bits) Result 0 0 0 open for read 0 0 1 open for write 0 1 0 open for read/write 0 reserved 0 0 0 give other compatible access 0 0 1 read/write access denied to others 0 1 0 write access denied to others 0 1 1 read access denied to others 1 0 0 give full access to tohers 0 file inherited by child process 1 file private to current process AH Function of INT 21H 3E Close file

Page 42: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-41

Additional Call Registers Result Registers BX = file handle Carry flag = 0 if successful = 1 if failed AX = 6 if invalid handle or file not open

Note: All internal buffers are flushed before the file is closed. 3F Read from file or device Additional Call Registers Result Registers DS:DX = buffer address Carry flag = 0 if successful BX = file handle = 1 if failed CX = number of bytes to read AX = number of bytes actually read, = 5 if access denied = 6 if file not open or invalid handle

Note: When reading from the standard device (keyboard), at most one line of text will be read, regardless of the value of CX.

40 Write to fiile or device Additional Call Registers Result Registers DS:DX = buffer address Carry flag = 0 if successful BX = file handle = 1 if failed CX = number of bytes to write AX = number of bytes actually written if successful = 5 if access denied = 6 if file not open or invalid handle

Note: If the carry flag is clear and AX is less than CX, a partital record was written or a disk full or other error was encountered.

41 Delete file (UNLINK) Additional Call Registers Result Registers DS:DX = address of ASCIIZ file specification Carry flag = 0 if successful = 1 if failed AX = 2 if file not found = 5 if access denied

Note: This function cannot be used to delete a file that is read-only. First, change the file's attribute to 0 by using interrupt 21 call 43H, then delete the file. No wildcard characters can be used in the filename. This function works by deleting the directory entry for the file.

AH Function of INT 21H 42 Move file pointer (LSEEK)

Page 43: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-42

Additional Call Registers Result Registers BX = file handle Carry flag = 0 if successful CX:DX = offset = 1 if fail AL = 0 to move pointer offset AX = 1 if invalid function number bytes from start of file = 6 if file not open or invalid handle = 1 to move pointer offset DX:AX = absolute offset from start of bytes from current location file if successful = 2 to move pointer offset bytes from end-of-file

Note: To determine file size, call with AL =2 and offset = 0. 43 Get or set file mode (CHMOD) Additional Call Registers Result Registers DS:DX = address of ASCIIZ Carry flag = 0 if successful file specifier = 1 if fail AL = 0H to get attribute CX = current attribute if set = 1H to set attribute AX = 1 if invalid function number CX = attribute if setting = 2 if file not found = attribute codes if = 3 if file does not exist or path not found getting (see below) = 5 if attribute cannot be changed 7 6 5 4 3 2 1 0 attribute code bits 0 reserved 0 reserved x archive 0 directory (do not set with 43H; use extended kFCB) 0 volume-label (do not set with 43H; use ext. FCB) x system x read-only AH Function of INT 21H 44 I/O device control (IOCTL)

Page 44: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-43

Additional Call Registers Result Registers AL = 00H to get device info AX = number of bytes = 01H to set device info transferred if CF = 0 = 02H char read device to buffer otherwise = error code = 03H char write buffer to device = 04H block read device to buffer = 05H block write buffer to device = 06H check input status = 07H check output status = 08H test if block device changeable = 09H test if drive local or remote = 0AH test if handle local or remote = 0BH to change sharing retry count = 0CH char device I/O control = 0DH block device I/O control = 0EH get map for logical drive = 0FH set map for logical drive DS:DX = data buffer BX = file handle; CX = number of bytes 45 Duplicate a file handle (DUP) Additional Call Registers Result Registers BX = opened file handle Carry flag = 0 if successful = 1 if fail AX = returned handle if successful = 4 if no handle available = 6 if handle invalid or not open

Note: The two handles will work in tandem; for example, if the file pointer of one handle is moved, the other will also be moved.

46 Force a duplicate of a handle (FORCCDUP) Additional Call Registers Result Registers BX = first file handle Carry flag = 0 if successful CX = second file handle = 1 if fail AX = 4 if no handle available = 6 if handle invalid or not open

Note: If the file referenced by CX is open, it will be closed first. The second file handle will be forced to point identically to the first file handle. The two handles will work in tandem; for example, if the file pointer of one handle is moved, the other will also be moved.

AH Function of INT 21H 47 Get current directory

Page 45: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-44

Additional Call Registers Result Registers DL = drive code Carry flag = 0 if successful (0 = default, 1 = A,...) = 1 if fail DS:SI = address of 64-byte buffer DS:SI = ASCIIZ path specifier AX = 0FH if drive specifier invalid

Note: The returned pathname does not include drive information or the leading "\". 48 Allocate memory Additional Call Registers Result Registers Carry flag = 0 if successful BX = number paragraphs = 1 if fail AX = points to block if successful = 7 if memory control blocks destroyed = 8 if insufficient memory BX = sixe of largest block available if failed 49 Free allocate memory Additional Call Registers Result Registers ES = segment address of block Carry flag = 0 if successful being released = 1 if fail AX =7 memory control blocks destroyed = 9 if invalid memory block address in ES

Note: Frees memory allocated by 48H. 4A Modify memory allocation (SETBLOCK) Additional Call Registers Result Registers ES = segment adddress of block Carry flag = 0 if successful BX = requested new block size = 1 if fail in paragraphs BX = max available block size in failed AX = if memory control blocks destroyed = 9 if invalid memory block address in ES

Note: Dynamically reduces or expands the memory allocated by a previous call to interrupt 21 function 48H.

AH Function of INT 21H 4B Load and/or execute program (EXEC)

Page 46: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-45

Additional Call Registers Result Registers DS:DX = address of ASCIIZ path AX = error code if CF not zero and filename to load ES:BX = address of parameter block AL = 0 to load and execute = 3 to load, not execute 4C Terminate a proces (EXIT) Additional Call Registers Result Registers AL = binary return code None

Note: Terminates a process, returning control to parent process or to DOS. A return code can be passed back in AL.

4D Ger return code of a Subprocess (WAIT) Additional Call Registers Result Registers None AL = return code AH = 00 if normal termination = 01 if terminated by ctrl-break = 02 if terminated by critical device error = 03 if terminated by call to interrupt 21

function 31H

Note: Returns the code sent via interrupt 21 function 4CH. The code can be returned only once.

4E Search for first match (FIND FIRST) Additional Call Registers Result Registers DS:DX = address of ASCIIZ Carry flag = 0 if successful file specification = 1 if failed CX = attribute to use in search AX = error code

Note: The filename should contain one or more wildcard characters. Befor this call, a previous call to interrupt 21 function 1AH must set the address of the DTA. If a matching filename is found, the current DTA will be filled in as follows: Bytes 0 - 20 reserved by DOS for use on subsequent search calls 21 : attribute found 22-23 : file time 24-25 : file date 26-27 : file size (least significant word) 28-29 : file size (most significant word) 30-42 : ASCIIZ file specification

AH Function of INT 21H 4F Search for next filename match (FIND NEXT)

Page 47: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-46

Additional Call Registers Result Registers None Carry flag = 0 if successful = 1 if failed AX = error code

Note: The current DTA must be filled in by a previous interrupt 21 4EH of 4FH call. The DTA will be filled in as outlined on interrupt 21 function 4E.

50 Reserved 51 Reserved 52 Reserved 53 Reserved 54 Get verify state Additional Call Registers Result Registers None AL = 00 if verify OFF = 01 if ventfy ON

Note: The state of the verify flag is changed via interrupt 21 function 2EH. 55 Reserved 56 Rename file Additional Call Registers Result Registers DS:DX = address of old ASCIIZ Carry flag = 0 if successful filename specification = 1 if failed ES:DI = address of new ASCIIZ AX = 2 if file not foun filename specification = 3 if path or file not foun = 5 if access denied = 11H if different device in new name

Note: If a drive specification is used, it must be the same in the old and new filename specifications. However, the directory name may be different, allowing a move and rename in one operation.

AH Function of INT 21H 57 Get/set file date and time

Page 48: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-47

Additional Call Registers Result Registers AL = 00 to get Carry flag = 0 if successful = 01 to set = 1 if failed BX = file handle CX = time if getting CX = time if setting DX = date if getting DX = date if setting AX = 1 if function code invalid = 6 if handle invalid

Note: The file must be open before the interrupt. The format of date and time is: TIME: DATE: Bits 0BH-0FH hours (0-23) Bits 09H-0FH year (rel.1980) 05H-0AH minutes (0-59) 05H-08H month (0-12) 00H-04H number of 2- 00H-04H day (0-31) second increments (0-29)

58 Get/set allocation strategy Additional Call Registers Result Registers AL = 00 to get strategy Carry flag = 0 if successful = 01 to set strategy = 1 if failed BX = strategy if setting AX = strategy if getting 00 if first fit = error code if setting 01 if best fit 02 if last fit 59 Get extended error information Additional Call Registers Result Registers BX = 00 AX = extended error code (see Table B.1) BH = error class BL = suggested remedy CH = error locus

Warning! This function destroys the contents of registers CL, DX, SI, DI, BP, DS, and ES. Error codes will change with future version of DOS.

5A Create temporary file Additional Call Registers Result Registers DS:DX = address of ASCIIZ path Carry flag = 0 if successful CX = file attribute = 1 if failed (00 if normal, 01 if read-only, AX = handle if successful 02 if hidden, 04 if system) = error code if failed DS:DX = address of ASCIIZ path specification if successful

Note: Filies created with this interrupt function are nod delted when the program terminates.

AH AL Function of INT 21H 5B Create new file Additional Call Registers Result Registers

Page 49: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-48

DS:DX = address of ASCIIZ Carry flag = 0 if successful file specification = 1 if failed CX = file attribute AX = handle if successful 00 if normal = error code if failed 01 if read-only 02 if hidden 04 if system

Note: This function works similarly to interrupt 21 function 3CH; however, this function fails if the file already exists, whereas function 3CH truncates the file to length zero.

5C Control record access Additional Call Registers Result Registers AL = 00 to lock, = 01 to unlock Carry flag = 0 if successful BX = file handle = 1 if failed CX:DX = region offset AX = error code SI:DI = region length

Note: Locks or unlocks records in systems that support muitatsking or networking. 5D Reserved 5E 00 Get machine name Additional Call Registers Result Registers DS:DX = address of buffer Carry flag = 0 if successful = 1 if failed CH = 0 if name undefined = 0 if name defined CL = NETBIOS number if successful DS:DX = address of identifier if successful AX = error code

Note: Returns a 15-byte ASCIIZ string computer identifier.

5E 02 Set printer setup Additional Call Registers Result Registers BX = redirection list index Carry flag = 0 if successful CX = setup strength length = 1 if failed DS:DX = address of setup string AX = error code

Note: This function specifies a string that will precede all files sent to the network printer form the local node in a LAN. Microsoft Networks must be running in order to use this function.

AH AL Function of INT 21H 5E 03 Get printer setup Additional Call Registers Result Registers BX = redirection list index Carry flag = 0 if successful

Page 50: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-49

ES:DI = address of buffer = 1 if failed AX = error code CX = length of setup string ES:DI = setup string if successful 5F 02 Get redirection list Additional Call Registers Result Registers BX = redirection list index Carry flag = 0 if successful = 1 if failed DS:SI = address of 16- byte BH = device status flag device name buffer bit 1 = 0 if valid device ES:DI = address of 128-byte = 1 in invalid device network name buffer BL = device type CX = parameter value DS:SI = addr. ASCIIZ local device name ES:DI = addr. ASCIIZ network name AX = error flag 5F 03 Redirect device Additional Call Registers Result Registers BL = device type Carry flag = 0 if successful 03 printer = 1 if failed 04 drive AX = error code CX = caller value DS:SI = address of ASCIIZ local device name ES:DI = address of ASCIIZ network name

Note: Used when operating under a LAN, this function allows you to add devices to the network redirection list.

5F 04 Cancel redirection Additional Call Registers Result Registers DS:SI = address of ASCIIZ Carry flag = 0 if successful local device name = 1 if failed AX = error code

Note: Used when operating under a LAN, this function allows you to delete devices from the network radirection list.

60 Reserved AH AL Function of INT 21H 61 Reserved 62 Get PSP (program segment prefix) address

Page 51: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-50

Additional Call Registers Result Registers None BX = address of PSP

Page 52: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-51

A summary of th IBM error codes Table B.16: Extended Error Code Information Code Error 1 invalid function number 2 file not found 3 path not found 4 too many open files 5 access denied 6 invalid handle 7 memory control blocks destroyed 8 insuifficient memory 9 invalid memory block address 10 invalid environment 11 invalid format 12 invalid access code 13 invalid data 14 unknown unit 15 invalid disk drive 16 attempt to remove current directory 17 not same device 18 no more files 19 attempt to write on write-protected diskette 20 unknown unit 21 drive not ready 22 unknown command 23 data error (CRC) 24 bad request structure length 25 seek error 26 unknown media type 27 sector not found 28 printer out of paper 29 write fault 30 read fault 31 general failure 32 sharing violation 33 lock violation 34 invalid disk change 35 FCB unavailable 36 sharing buffer overflow 37-49 reserved 50 network request not supported 51 remote computer not listening 52 duplicate name on network 53 network name not found 54 network busy 55 network device no longer exists 56 net BIOS command limit exceeded 57 network adapter hardware error 58 incorrect response from network 59 unexpected network error 60 incompatible remote adapter 61 print queue full 62 not enough space for print file 63 print file was deleted 64 network name not found 65 access denied

Page 53: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-52

66 network device typoe incorrect 67 network name not found 68 network name limit exceeded 69 net BIOS session limit exceeded 70 temporarily paused 71 network request not accepted 72 print or disk redirection is paused 73-79 reserved 80 file exists 81 reserved 82 cannot make directory entry 83 fail on INT 24 84 too many redirections 85 duplicate redirection 86 invalid password 87 invalid parameter 88 network device fault

Reprinted by permission from "IBM Disk Operating System Technical Reference" c. 1987 by International Business Machines Corporation.

Page 54: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-53

SECTION B.2: MOUSE INTERRUPTS 33H Mouse interrupts are covered in Chapter 6. The following is a partial list of commonly used functions of the mouse handler interrupt, 33H. This interrupt is loaded into the system with the mouse interrupt handler, which is loaded upos reading the "device=" directive in the CONFIG.SYS file. AH Function of INT 33H 00 Initialize the mouse

Additional Call Registers Result Registers None AX = 0H if mouse not available = FFFFH if mouse avasilable BX = number of mouse buttons

Note: This function is called only once to initialize the mouse. If mouse support is present, AX = FFFFH and the mouse driver is intialized, the mouse pointer is set to the center of the screen and concealed.

01 Display mouse pointer Additional Call Registers Result Registers None None

Note: This function displays the mouse pointer and cancels any excusion area. 02 Condeal mouse pointer Additional Call Registers Result Registers None None

Note: This function hides the mouse pointer but the mouse driver monitors its position. Most programs issue this command before they terminate.

03 Get mouse location and button status

Additional Call Registers Result Registers None BX = mouse button status bit 0 - left button bit 1 - right button bit 2 - center button = 0 if up; = 1 if down CX = horizontal position DX = vertical position

Note: The horizontal and vertical coordinates are returned in pixels.

AH Function of INT 33H

Page 55: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-54

04 Set mouse pointer location

Additional Call Registers Result Registers CX = horizontal position None DX = vertical position

Note: The horizontal and vertical coordinates are in pixels. Will display the mouse pointer only within set limits; will not display in exclusion areas.

05 Get button press information Additional Call Registers Result Registers BX = button: 0 for left; AX = button status 1 for right; 2 for center bit 0 - left button bit 1 - right button bit 2 - center button = 0 if up: = 1 if down BX = button press count CX = horizontal position DX = vertical position

Note: This returns the status of all buttons as well as the number of presses for the button indicated in BX when called. The poisition of the mouse pointer is given in pixels and represents the position at the last button press.

06 Get button release information Additional Call Registers Result Registers BX = button: 0 for left; AX = button status 1 for right; 2 for center bit 0 - left button bit 1 - right button bit 2 - center button = 0 if up: = 1 if down BX = button release count CX = horizontal position DX = vertical position

Note: This returns the status of all buttons as well as the number of presses for the button indicated in BX when called. The poisition of the mouse pointer is given in pixels and represents the position at the last button release.

07 Set horizontal limits for mouse pointer Additional Call Registers Result Registers CX = minimum horizontal position None DX = maximum horizontal position

Note: This sets the horizontal limits (in pixels) for the mouse pointer. After this call, the mouse will be displayed within these limits.

AH Function of INT 33H

Page 56: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-55

08 Set vertical limits for mouse pointer Additional Call Registers Result Registers CX = minimum vertical position None DX = maximum vertical position

Note: This sets the vertical limits (in pixels) for the mouse pointer. After this call, the mouse will be displayed within these limits.

10 Set mouse pointer exclusion area Additional Call Registers Result Registers CX = upper left horizontal coordinate None DX = upper left vertical coordinate SI = lower right horizontal coordinate DI = lower right vertical coordinate

Note: This defines an area in which the mouse pointer will not display. An exclusion area can be cancelled by calling functions 00 or 01.

24 Get mouse information Additional Call Registers Result Registers None BH = major version BL = minor version CH = mouse type CL = IRQ number

Note: This returns the version number (e.g., version 7.5: BH = 7, BL = 5). Mouse type: 1 for bus; 2 for serial; 3 for InPort; 4 for PS/2; 5 for HP; IRQ = 0 for PS/2; otherwise = 2, 3, 4, 5 or 7.

Page 57: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-56

SECTION B.3: BIOS INTERRUPTS

This section covers the most commonly used BIOS interrupts. INT 10H is used extensivbely for graphics programming. INT 11H returns the equipment configuration and INT 12H returns the memory size. INT 14H is used for asynchronous communication. Two functions of INT 15H are included: one to initiate a wait and another to return extended memory size. INT 16H is used for the keyboard and INT 17H for the printer. INT 1AH handles the timer and RTC.

SECTION B.3.1: INT 10H VIDEO FUNCTION CALLS

AH Function 00 Set video mode Additional Call Registers Result Registers AL = video mode None

See Table B.2 for a list of available video modes and their definition. 01 Set cursor type Additional Call Registers Result Registers CH = beginning line of cursor None (bits 0 - 4) CL = ending line of cursor (bits 0 - 4)

Note: All other bits should be set to zero. The blinking of the cursor is hardware controlled. 02 Set cursor position Additional Call Registers Result Registers BH = page number None DH = row DL = column

Note: When using graphics modes, BH must be set to zero. Text coordinates of the upper left-hand corner will be (0.0).

03H Read cursor position and size Additional Call Registers Result Registers BH = page number CH = beginning line of cursor CL = ending line of cursor DH = row DL = column

Note: When using graphics modes, BH must be set to zero. AH Function

Page 58: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-57

04H Read light pen position Additional Call Registers Result Registers None AH = 0 if light pen not triggered = 1 if light pen triggered BX = pixel column CH = pixel row (modes 04H - 06H) CX = pixel row (modes 0DG - 13H) DH = character row DL = character column 05H Select active display page Additional Call Registers Result Registers AL = page number None (see Table E-1 below)

Table B.3: Display Pages for Different Modes and Adapters

Mode Pages Adapters 00H 0-7 CGA EGA MCGA VGA 01H 0-7 CGA EGA MCGA VGA 02H 0-3 CGA 0-7 EGA MCGA VGA 03H 0-3 CGA 0-7 EGA MCGA VGA 07H 0-7 EGA VGA 0DH 0-7 EGA VGA 0EH 0-3 EGA VGA 0FH 0-1 EGA VGA 10H 0-1 EGA VGA

All other mode-adapter combinations support only one page.

06 Scroll window up Additional Call Registers Result Registers AL = number of lines to scroll None BH = display attribute CH = y coordinate of top left CL = x coordinate of top left DH = y coordinate of lower right DL = x coordinate of lower right

Note: If AL = 0, the entrire window is blank. Otherwise, the screen will be scrolled upward by the number of lines in AL. Lines scrolling off the top of the screen are lost, blank lines are scrolled in at the bottom according to the attribute in BH.

AH Function

Page 59: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-58

07 Scroll window down Additional Call Registers Result Registers AL = number of lines to scroll None BH = display sttribute CH = y coordinate of top left CL = x coordinate of top left DH = y coordinate of lower right DL = x coordinate of lower right

Note: If AL = 0, the entrire window is blank. Otherwise, the screen will be scrolled down by the number of lines in AL. Lines scrolling off the bottom of the screen are lost, blank lines are scrolled in at the top according to the attribute in BH.

08 Read character and attribute at cursor position Additional Call Registers Result Registers BH = display page AH = attribute byte AL = ASCII character code 09 Write character and attribute at cursor position Additional Call Registers Result Registers AL = ASCII character code None BH = display page BH = attribute CX = number of characters to write

Note: Does not update cursor position. Use interrupt 10 Function 2 to set cursor position. 0A Write character at cursor position Additional Call Registers Result Registers AL = ASCII character code None BH = display page BL = graphic color CX = number of characters to write

Note: Write character(s) using existing video attribute. Does not update cursor position. Use interrupt 10 Function 2 to set cursor position.

AH Function

Page 60: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-59

0B Set color palette Additional Call Registers Result Registers BH = 00H to set border or None background colors = 01H to set palette BL = palette/color

Note: If BH = 00H and in text mode, this function will set the border color only. If BH = 00H and in graphics mode, this function will set background and border colors. If BH = 01H, this function will select the palette. In 320 x 200 four-color graphics, palettes 0 and 1 are available.

Pixel Colors for Palettes 0 and 1 Pixel Palette 0 Palette 1 0 background background 1 green cyan 2 red magenta 3 brown/yellow white

0C Write pixel Additional Call Registers Result Registers AL = pixel value None CX = pixel column DX = pixel row BH = page

Note: Coordinates and pixel value depend on the current video mode. Setting bit 7 of AL causes the pixel value in AL to be XORed with the current value of the pixel.

0D Read pixel Additional Call Registers Result Registers CX = pixel column AL = pixel value DX = pixel row BH = page 0E TTY character output Additional Call Registers Result Registers AL = character None BH = page BL = foreground color

Note: Writes character to the display and updates cursor position. TTY mode indicates minimal character processing. ASCII codes for bell, backspace, linefeed, and carriage return are translated into the appropriate action.

AH AL Function 0F Get video mode

Page 61: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-60

Additional Call Registers Result Registers None AH = width of screen in characters AL = video mode BH = active display page

Note: See Table B.2 for a list of possible video modes. 10 00 SubFunction 00H: set palette register to color correspondence Additional Call Registers Result Registers AL = 00H None BH = color CL = palette register (00H to 0FH) 10 01 SubFunction 01H: set border color Additional Call Registers Result Registers AL = 01H None BH = border color 10 02 SubFunction 02H: set palette and border Additional Call Registers Result Registers AL = 02H None ES:DX = address of color list 13 Write String Additional Call Registers Result Registers AL = write mode None = 00H, attribute in BL,cursor not moved = 01H, attribute in BL. cursor moved = 02H, attributes follow char, cursor

not moved = 03H, attributes follow char, cursor moved ES:BP = address of string CX = character count DH = initial row position DL = intial column position BH = page

Note: For AL = 00 and 01, the string consists of characters only, which will all be displayed with the attribute in BL. For AL = 02 and 03, the data is stored with the attributes (char, attrib, char, attrib, and so on).

Table B.2: Video Modes and Their Definition char text/ Max Buffer AL Pisels Characters box graph Colors Adapter pages start 00H 320x200 40 x 25 8x8 text 16* CGA 8 B8000h 320x350 40 x 25 8x14 text 16* EGA 8 B8000h

Page 62: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-61

360x400 40 x 25 9x16 text 16* VGA 8 B8000h 320x400 40 x 25 8x16 text 16* MCGA 8 B8000h 01H 320x200 40 x 25 8x8 text 16 CGA 8 B8000h 320x350 40 x 25 8x14 text 16 EGA 8 B8000h 360x400 40 x 25 9x16 text 16 VGA 8 B8000h 320x400 40 x 25 8x16 text 16 MCGA 8 B8000h 02H 640x200 80 x 25 8x8 text 16* CGA 8 B8000h 640x350 80 x 25 8x14 text 16* EGA 8 B8000h 720x400 80 x 25 9x16 text 16* VGA 8 B8000h 640x400 80 x 25 8x16 text 16* MCGA 8 B8000h 03H 640x200 80 x 25 8x8 text 16 CGA 8 B8000h 640x350 80 x 25 8x14 text 16 EGA 8 B8000h 720x400 80 x 25 9x16 text 16 VGA 8 B8000h 640x400 80 x 25 8x16 text 16 MCGA 8 B8000h 04H 320x200 40 x 25 8x8 graph 4 CGA 4 B8000h 320x200 40 x 25 8x8 graph 4 EGA 1 B8000h 320x200 40 x 25 8x8 graph 4 VGA 1 B8000h 320x200 40 x 25 8x8 graph 4 MCGA 1 B8000h 05H 320x200 40 x 25 8x8 graph 4* CGA 1 B8000h 320x200 40 x 25 8x8 graph 4* EGA 1 B8000h 320x200 40 x 25 8x8 graph 4* VGA 1 B8000h 320x200 40 x 25 8x8 graph 4* MCGA 1 B8000h 06H 640x200 80 x 25 8x8 graph 2 CGA 1 B8000h 640x200 80 x 25 8x8 graph 2 EGA 1 B8000h 640x200 80 x 25 8x8 graph 2 VGA 1 B8000h 640x200 80 x 25 8x8 graph 2 MCGA 1 B8000h 07H 720x350 80 x 25 9x14 text mono MDA 8 B8000h 720x350 80 x 25 9x14 text mono EGA 4 B8000h 720x400 80 x 25 9x16 text mono VGA 8 B8000h 08H reserved 09H reserved 0AH reserved 0BH reserved 0CH reserved 0DH 320x200 40 x 25 8x8 graph 16 EGA 2/4 A0000h 320x200 40 x 25 8x8 graph 16 VGA 8 A0000h 0EH 640x200 80 x 25 8x8 graph 16 EGA 1/2 A0000h 640x200 80 x 25 8x8 graph 16 VGA 4 A0000h 0EH 640x350 80 x 25 9x14 graph mono EGA 1 A0000h 640x350 80 x 25 8x14 graph mono VGA 2 A0000h 10H 640x350 80 x 25 8x8 graph 4 EGA 1/2 A0000h 640x350 80 x 25 8x14 graph 16 VGA 2 A0000h 11H 640x480 80 x 30 8x16 graph 2 VGA 1 A0000h 640x480 80 x 30 8x16 graph 2 MCGA 1 A0000h 12H 640x480 80 x 30 8x16 graph 16 VGA 1 A0000h 13H 320x200 40 x 25 8x8 graph 256 VGA 1 A0000h 320x200 40 x 25 8x8 graph 256 MCGA 1 A0000h

* - color burst off

SECTION B.3.2: -- INT 11H - EQUIPMENT DETERMINATION

Get equipment configuration

Page 63: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-62

Call Registers Result Registers None AX = equipment coee (see below)

Note: BIOS data area 40:10 is set during POST according to the equipment code word, which shows the optional equipment that is attached to the systsem.

Equipment Code Word

d15 d14 d13 d12 d11 d10 d9 d8 d7 d6 d5 d4 d3 d2 d1 d0

floppy disk drive installedmath coprocessor installedpointing device installednot usedinitial video mode (see below)floppy drives (see below)not usednumber RS-232 cardsnot usedintermal modern installednumber printers installed

Initial Video Mode Number of Floppy Drives 00 = Reserved 00 = 1 drive 01 = 40x25 color 01 = 2 drives 10 = 80x25 color 11 = 80x25 monochrome

SECTION B.3.3: -- INT 12H - MEMORY SIZE DETERMINATION

Get Conventional Memory Size Call Registers Result Registers None AX = memory size (kB)

Note: Returns amount of conventional memory available to DOS and application programs.

SECTION B.3.4 -- INT 14H - ASYNCHRONOUS COMMUNICATION

AH Function

Page 64: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-63

00 Initialize COM Port Additional Call Registers Result Registers AL = parameter (see below) AH = port status (see below) DX = port number (0 if COM1. AL = modem status (see below0 1 if COM2, etc.)

Note 1: The parameter byte in AL is defined as follows.

7 6 5 4 3 2 1 0 Indicates x x x Baud rate (000=110, 001=150, 010=300, 011=600, 100=1200, 101=2400, 110=4800, 111=9600) x x Parity (01=odd, 11=even, x0=none) x Stop bits (0=1, 1=2) x x Word length (10=7 bits, 11=8 bits) Note 2: The port status returned in AH is defined as follows: 7 6 5 4 3 2 1 0 Indicates 1 Timed-out 1 Transmit shift register empty 1 Transmit holding register empty 1 Break detected 1 Framing error detected 1 Party error detected 1 Overrun error detected

1 Received data ready

Note 3: The modem status returned in AL is defined as follows: 7 6 5 4 3 2 1 0 Indicates 1 Received line signal detect 1 Ring indicator 1 DSR (data set ready) 1 CTS (clear to send) 1 Change in receive line signal detect 1 Trailing edge ring indicator 1 Change in DSR status 1 Change in CTS status

AH Function 01 Write character to COM Port

Page 65: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-64

Additional Call Registers Result Registers AL = character AH bit 7 = 0 if successful, 1 if not DX = port number (0 if COM1, AH bits 0 - 6 = status if successful 1 if COM2, etc.) AL = character

Note: The status byte in AH, bits 0 - 6, after the call is as follows:

7 6 5 4 3 2 1 0 Indicates 1 Transmit shift register empty 1 Transmit holding register empty 1 Break detected 1 Framing error detected 1 Party error detected 1 Overrun error detected 1 Received data ready

02 Read character from COM Port Additional Call Registers Result Registers DX = port number (0 if COM1, AH bit 7 = 0 iv successful, 1 if not AH bits 0 - 6 = status if successful 1 if COM2, etc.) AL = character read

Note: The status byte in AH, bits 1 - 4, after the call is as follows:

4 3 2 1 Indicates 1 Break detected 1 Framing error detected 1 Party error detected 1 Overrun error detected

03 Read COM Port Status Additional Call Registers Result Registers DX = port number (0 if COM1, AH = port status 1 if COM2, etc.) AL = modem status

Note: The port status and modem status returned in AH and AL are the same format as INT 14H function 00H, described above.

AH Function 04 Extended Initialize COM Port

Additional Call Registers Result Registers AL = 00H (break), 01H (no break) AH = port status (see function AH=0)

Page 66: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-65

DX = port number (0 if COM1, AL = modem status (see function AH=0) 1 if COM2, etc.) BH = parity = 00H none = 01H odd = 02H even = 03H stick parity odd = 04H stick parity even BL = stop bits = 00H (one stop bit) = 01H (1,5 bits for 5-bit word) = 01H (2 bits for > 5-bit word) CH = word length = 00H 5-bit = 01H 6-bit = 02H 7-bit = 03H 8-bit CL = baud rate = 00H 110 baud = 01H 150 baud = 02H 300 baud = 03H 600 baud = 04H 1200 baud = 05H 2400 baud = 06H 4800 baud = 07H 9600 baud = 08H 19200 baud 05 Extended COM Port Control

Additional Call Registers Result Registers AL = 00H (read control register) If read subfunction, = 01H (write to control register) BL = modem control register DX = port number (0 if COM1, If write subfunction, 1 if COM2, etc.) AL = modem status BL = Modem control register AH = line status bits 7 - 5 reserved bit 4: loop bit 3: out2 bit 2: out1 bit 1: RTS bit 0: DTR

Note: Subfunction AL = 00H returns the modem control register contents in BL. Subfunction AL = 01H writes the contents of BL into the modem control register and returns modem and line status register contents in AL and AH.

SECTION B.3.5: -- INT 15H - SYSTEM SERVICES

AH Function 86 Wait

Page 67: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-66

Additional Call Registers Result Registers CX:DX time to wait in ms CF = 0 for successful wait = 1 if wait not performed

Note: The duration of the wait always be a multiple of 976 microseconds. 88 Extended memory size determination Additional Call Registers Result Registers None AX = extended memory (kB)

Note: Returns the amount of installed extended memory in kB, that is, the memory beginning at address 100000H, as determined by the POST. If DOS memory management is in control. 0 will be returned in AX even if you have extended memory.

SECTION B.3.6: -- INT 16H - KEYBOARD

AH Function 00 Keyboard read Additional Call Registers Result Registers None AH = key scan code AL = ASCII char

Note: Reads one character from the keyboard buffer and updates the head pointer. 01 Get keyboard status Additional Call Registers Result Registers None If no key waiting, ZF = 1. If key waiting, ZF = 0, AH = key scan code, AL = ASCII char.

Note: If a key is waiting, the scan code and character are returned in AH and AL, but the head pointer of the keyboard buffer is not updated.

AH Function 02 Get shift status Additional Call Registers Result Registers None AL = status byte

Page 68: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-67

bit 7: Insert pressed bit 6: Caps Lock pressed bit 5: Num Lock pressed bit 4: Scroll Lock pressed bit 3: Alt pressed bit 2: Ctrl pressed bit 1: Left Shift pressed bit 0: Right Shift pressed

Note: The keyboard status byte returned in AL indicates whether certain keys have been pressed. If the bit = 1, the key has been pressed.

03 Set typematic rate Additional Call Registers Result Registers AL = 05H None BH = repeat delay (see below) BL = repeat rate (see below)

Note: Sets the rate at which repeated keystrokes are accepted. The delay value in BH can be 00H (for 250), 01H (for 500), 02H (for 750), or 03H (for 1000). All values are in milliseconds. The repeat rate in BL represents the number of characters per second. Options are: 00H: 30.0 0BH: 10.9 16H: 4.3 01H: 26.7 0CH: 10.0 17H: 4.0 02H: 24.0 0DH: 9.2 18H: 3.7 03H: 21.8 0EH: 8.6 19H: 3.3 04H: 20.0 0FH: 8.0 1AH: 3.0 05H: 18.5 10H: 7.5 1BH: 2.7 06H: 17.1 11H: 6.7 1DH: 2.5 07H: 16.0 12H: 6.0 1DH: 2.3 08H: 15.0 13H: 5.5 1EH: 2.1 09H: 13.3 14H: 5.0 1EH: 2.0 0AH: 12.0 15H: 4.6 20H to FFH - reserved

10 Extended keyboard read Additional Call Registers Result Registers None AH = key scan code AL = ASCII char

Note: Used in place of INT 16H function 00H to allow program to detect F11, F12, and other keys of the extended keyborad. After the read, the head pointer of the keyboard buffer is updated.

AH Functrion 11 Extended keyboard status Additional Call Registers Result Registers None If no key waiting,

Page 69: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-68

ZF = 1. If key waiting, ZF = 0, AH = key scan code, AL = ASCII char.

Note: This function is used instead of INT 16H function 01H so that programs can detect keys of the extended keyboard such as F11 and F12. If a key is waiting, the scan code and character are returned in AH and AL, but the head pointer of the keyboard buffer is not updated.

12 Extended shift status Additional Call Registers Result Registers None AL = shift status bit 7: Insert locked bit 6: Caps Lock locked bit 5: Num Lock locked bit 4: Scroll Lock locked bit 3: Alt pressed bit 2: Ctrl pressed bit 1: Left Shift pressed bit 0: Right Shift pressed AH = extended shift status bit 7: SysRq pressed bit 6: Caps Lock pressed bit 5: Num Lock pressed bit 4: Scroll Lock pressed bit 3: Right Alt pressed bit 2: Right Ctrl pressed bit 1: Left Alt pressed bit 0: Left Ctrl pressed

Note: The keyboard status byte returned in AL and AH indicate whether certain keys have been pressed. If the bit = 1, the key has been pressed.

SECTION B.3.6 -- INT 17H - PRINTER

AH Function

Page 70: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-69

00 Print charactrer Additional Call Registers Result Registers AL = character to print AL = status DX = printer (0 for LPT1, bit 7: printer not busy 1 for LPT2, 2 for LPT3) bit 6: printer acknowledge bit 5: out of paper bit 4: printer selected bit 3: I/O error bits 2-1: reserved bit 0: printer timed-out 01 Initilize port Additional Call Registers Result Registers AL = status (see function 00h) DX = printer (0 for LPT1, 1 for LPT2, 2 for LPT3) 02 Read status Additional Call Registers Result Registers AL = status (see function 00h) DX = printer (0 for LPT1, 1 for LPT2, 2 for LPT3)

SECTION B.3.7 -- INT 1AH TIMER AND REAL-TIME CLOCK SERVICES

AH Function 00 Read system-timer time counter Additional Call Registers Result Registers None CX = high portion of count DX = low portion of count AL = 0 if 24 hours has not passed sincew last read > 0 if 24 has passed since last read

Note: This function returns the number of ticks since midnight. A second is about 18.2 ticks. When the number of tivcks indicates that 24 hours has-passed, AL is incremented and the tick count is reset to zero. Calling this function resets AL so that whether 24 hours has passed can only be determined once a day.

AH Function 01 Set system-timer time conter Additional Call Registers Result Registers

Page 71: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Zbirka zadataka iz Mikroprocesora i mikrora~unara

B-70

CX = high portion of tick count None DX = low portion of tick count

Note: Calling this function will cause the timer overflow flag to be reset. 02 Read real-time clock time Additional Call Registers Result Registers None CH = hours CL = minutes DH = seconds DL = 01 for daylight savings option = 00 for no option CF = 0 if clock operating, otherwise = 1

Note: Hours, minutes, and seconds are returned in BCD format. This function is used to get the time in the CMOS time/date chip.

03 Set real-time clock time Additional Call Registers Result Registers CH = hours None CL = minutes DH = seconds DL = 01 for daylight savings option = 00 for no option

Note: Nours, minutes, and seconds are in BCD format. This function is used to set the time in the CMOPS time/date chip.

04 Read real-time clock date Additional Call Registers Result Registers None CH = century (19 od 20) CL = year DH = month DL = day CF = 0 if clock operating, otherwise = 1

Note: Century, year, month and day are in BCD format. This function is used to get the time in the CMOS time/date chip.

AH Function 05 Set real-time clock date Additional Call Registers Result Registers

Page 72: Memory Blocks Memory Manager XMA memorijsku oblast (XMA ...es.elfak.ni.ac.rs/Books/StaraZbirka/dodatakB.pdfKomanda SHELL specificira koji interpreter komandi (komandni procesor) koristi

Dodatak B

B-71

CH = century (19 od 20) None CL = year DH = month DL = day

Note: Century, year, month and day are in BCD format. This function is used to set the date in the CMOS time/date chip.