:

. . -21

³ .

2005.

DOS BIOS ( NT).

IBM PC - . ' 0000h 03FFh - , (). , - . , , , , 0 ( 0) 0, 1− 4, 2− 8 .. N , , ' N*4 N*4+2. ' 256 .

, , ( CS IP) CS IP , ( 1).

IRET, 䳿 - IP, CS , , .

. , INT, , , DOS BIOS. , , , , ( , ), ( ). , , , , , .

; . :

00h - 0;

0lh - ( TF=1);

02h - ( NMI )

03h - INT ;

04h - INTO - ( , INTO);

08h - ();

09h - ();

0Ah - ();

0Bh - COM2 ();

0h - 1 ();

0Dh - (); 0Eh - ();

0Fh - ( LPT1) ();

10h - BIOS;

13h - BIOS ;

16h - BIOS ;

17h - BIOS ;

1Bh - /;

1Ch - BIOS (18,2 );

1Dh - , BIOS;

lEh - , BIOS;

1Fh - 4...6, BIOS;

21n - DOS;

22h - , DOS;

23h - /C;

24h - ;

25h - ;

26h - ;

2Fh - DOS;

43h - , BIOS;

60h...66h - ;

67h - ' LIM EMS;

68h...6Fh - ;

70h...7Fh - AT;

78h...7Fh - ;

Flh...FFh - .

, :

(08h...0Fh 70h...77h);

BIOS (10h, 13h, 16h ..);

DOS (21h, 22h, 23h ..);

DOS BIOS (1Dh, lEh, 43h ..).

, , , , . , BIOS (l0h) , , , . 21h, DOS: , , , ' , ..

. ( !), − , . ϳ INT , () , , INT 21h.

DOS BIOS CF . CF=0, - CF=1. ( ) . , :

mov ,fun ; fun -

; (AL, BX, ES,

.)

;,

...

int 21h ; MS-DOS

jc error

;

...

error:cmp AX,1 ;

je err1

cmp AX2

je err

...

BIOS.

IBM PC 8253 8254. , . 16- , ( ). (clk) (gate). 1,19 . 0 ( 18,2 ). 1 15 . ' .

2 . . 0 1 ( 8255). 0 2 . 2 "", 1 . 2 , 2 ( 0 ) 1 .

- 61h, - 40h, 41h, 42h, 43h - 0, 1, 2 , , . 1 , . .

1. , '1' '2'. 1 . 'q'.

Assume CS: Code, DS: Code

Code SEGMENT

org 100h

frequency1 equ 300 ; 1

frequency2 equ 500 ; 2

number_cycles1 equ 1000 ; ʳ (.)

number_cycles2 equ 600 ; ʳ (.)

port_b equ 61h ;

.286

Start proc near

mov ax,cs

mov ds,ax ; DS = CS

beg1: call kbin ;

cmp al,'1' ; = '1' ?

jnz beg2 ; ͳ

call ton1 ; 1

jmp beg1 ;

beg2: cmp al,'2' ; = '2' ?

jnz beg3 ; ͳ

call ton2 ; 2

jmp beg1 ;

beg3: cmp al,'q' ; = 'q' ?

jnz beg1 ; ͳ

int 20h ;

start endp

ton2 proc near ; 2

mov dx,number_cycles2 ; 2

mov di,frequency2 ; 2

jmp ton0 ;

ton1 proc near ; 1

mov dx,number_cycles1 ; 1

mov di,frequency1 ; 1

;

; DX - , DI -

ton0 proc near

cli ;

in al,port_b ; .

and al,11111110b ; ³.

ton01: or al,00000010b ;

out port_b,al ;

mov cx,di ; ˳

loop $ ;

;

and al,11111101b ;

out port_b,al ;

mov cx,di ; ˳

loop $ ;

dec dx ;

jnz ton01 ;

sti ;

ret ;

ton0 endp ; ʳ

ton1 endp ; ʳ 1

ton2 endp ; ʳ 2

kbin proc near ;

mov ah,0 ; 0

int 16h ;

ret ;

kbin endp ; ʳ

code ends ; ʳ ()

END Start ;

2. , '1' '2'. 2 . 'q'.

Assume CS: Code, DS: Code

Code SEGMENT

org 100h

frequency1 equ 1000 ; . 1

frequency2 equ 3000 ; . 2

duration equ 50000 ;

port_b equ 61h ;

.286

Start proc near ;

mov ax,cs

mov ds,ax ; DS = CS

beg1: call kbin ;

cmp al,'1' ; = '1' ?

jnz beg2 ; ͳ

call ton1 ; 1

jmp beg1 ;

beg2: cmp al,'2' ; = '2' ?

jnz beg3 ; ͳ

call ton2 ; 2

jmp beg1 ;

beg3: cmp al,'q' ; = 'q' ?

jnz beg1 ; ͳ

int 20h ;

start endp ; ʳ

ton2 proc near ; 2

mov dx,duration ;

mov di,frequency2 ; 2

jmp ton0 ;

ton1 proc near ; 1

mov dx,duration ;

mov di,frequency1 ; 2

;

; DX - , DI - .

ton0 proc near

cli ;

;

in al,61h ;

or al,3 ; ( 0 1)

out 61h,al ;

; 2

mov ax,di ;

out 42h,al ; .  2

xchg al,ah ; AH  AL

out 42h,al ; .  2

;

mov cx,dx ; ˳

ton01: push cx ; ,

pop cx ; .

loop ton01 ;

;

in al,61h ;

and al,0fch ; ( 0 1)

out 61h,al ;

sti ;

ret ;

ton0 endp ; ʳ

ton1 endp ; ʳ 1

ton2 endp ; ʳ 2

kbin proc near ;

kbin endp

code ends ; ʳ ()

END Start ;

. . MS-DOS. .: 1993.

. . . .

contact://www.BankReferatov.ru , .