 |
-
- :
- ... -...( ).. .. , ?
.model small
.386
.stack 256h
.data
; 1193180/
music dw 4063, 2559, 3835 ; = 293,7 - = 466,2 - = 311,1
;
duration dw 27, 36, 18 ; = 1,5 - = 2 - = 1 = > 18.2*
dlina dw 3
.code
start:
mov ax, @data
mov ds, ax
mov si, 0
cli ;ape pepa
play:
mov dx, duration[si] ;eoc oa dx
in al, port_b ;oae aee opa b
and al, 11111110b ;oae a o aepa
next_cycle:
or al, 00000010b ;ae a
out port_b, al ;ocae oa op b
mov cx, music[si] ;aepa a o-a cx
first_half:
loop first_half ;eae aep
and al, 11111101b ;ae a
out port_b, al ;ocae oa op b
mov cx, music[si] ;aepa a o-a cx
second_half:
loop second_half ;eae aep
dec dx ;ae e cea
jnz next_cycle ;ec 0, o ao oa
dec dlina
mov cx, dlina
inc cx
inc si
inc si
loop play
sti ;papeae pepa
mov ax, 4c00h
int 21h
end start
- :
-
BIOS ah=86h, 15h.
CX:DX( : ).
:
()=( 1 000 000 / ) / 2
= .
=(1 000 000/293,7)/2=1 70210=6A610
:
N= *
= 293,7 * 1,5 = 44010
, , () 0.
tasm.
ps: , first_half: loop first_half, .
, , , 20.
model tiny
.186
.code
org 100h
start:
;
in al, 61h ;oae aee opa b
and al, 11111100b ;oae a o aepa
;
cli ;ape pepa
;
mov cx,3
play: push cx
;
mov cx, duration[si];eoc oa x
mov dx, music[si]; - dx
next_cycle:
push cx
;
call beep;
call beep;
;
pop cx
loop next_Cycle
;
pop cx
;
inc si
inc si
;
loop play
sti;papeae pepa
;
xor ax,ax
int 16h
; DOS
ret
; -
beep: xor al,00000010b
out 61h,al
;
push ax
;
push dx
;
xor cx,cx
;
mov ah,86h
int 15h
;
pop dx
pop ax
ret
;
music dw 6a6h,430h,647h; = 293,7 - = 466,2 - = 311,1
;
duration dw 440, 892, 311; = 1,5 - = 2 - = 1
end start
|  |