Работа С Прерываниями

AyratT18rus

New member
19.06.2013
1
0
#1
Помогите разобраться с кодом, краткое описание.
Нарисовать алгоритмы этой программы:


program Lab2;
{$G+}
uses DOS;
var r:registers;
VM,PN:byte;
hour,minute,secund,secund100:word;
a,time,timenow:real;
c,d,radius,h,i,j,l,kol,kolasm,kolbrez,kolbrezasm:integer;

Procedure setVM;
begin
r.ah:=0;
r.al:=$13;
intr($10,r);
end;

Procedure getVM;
begin
r.ah:=$F;
intr($10,r);
VM:=r.al;
PN:=r.bh;
end;

Procedure RestoreVM;
begin
r.ah:=0;
r.al:=VM;
intr($10,r);
r.ah:=5;
r.al:=PN;
intr($10,r);
end;

Procedure PutPixelDos(x,y,col:integer);
begin
r.ah:=$C;
r.al:=col;
r.cx:=x;
r.dx:=y;
intr($10,r);
end;

Procedure PutPixelAsm (x,y:integer); assembler;
asm
mov Ax,$A000
mov Es,Ax
mov Ax,Y
shl Ax,6
mov Di,Ax
shl Ax,2
add Di,Ax
add Di,X
mov Al,12
mov Es:[Di],Al
end;

procedure BrezenDos(x0, y0, r: integer);
var
x, y: integer;
dv, dd, dh: integer;
procedure sim(x, y: integer);
begin
putpixeldos(x0+x, y0+y, 50);
putpixeldos(x0+x, y0-y, 50);
putpixeldos(x0-x, y0+y, 50);
putpixeldos(x0-x, y0-y, 50);
end;
begin
x:=0;
y:=r;
while((y>=0)or(x<r)) do
begin
sim(x,y);
dv:=abs(r*r - x*x - (y-1)*(y-1));
dh:=abs(r*r - (x+1)*(x+1) - y*y);
dd:=abs(r*r - (x+1)*(x+1) - (y-1)*(y-1));
if(dv<dh) then
begin
dec(y);
if(dd<dv) then inc(x);
end
else
begin
inc(x);
if(dd<dh) then dec(y);
end;
end;
end;

procedure BrezenAsm(x0, y0, r: integer);
var
x, y: integer;
dv, dd, dh: integer;
procedure sim(x, y: integer);
begin
putpixelasm(x0+x, y0+y);
putpixelasm(x0+x, y0-y);
putpixelasm(x0-x, y0+y);
putpixelasm(x0-x, y0-y);
end;
begin
x:=0;
y:=r;
while((y>=0)or(x<r)) do
begin
sim(x,y);
dv:=abs(r*r - x*x - (y-1)*(y-1));
dh:=abs(r*r - (x+1)*(x+1) - y*y);
dd:=abs(r*r - (x+1)*(x+1) - (y-1)*(y-1));
if(dv<dh) then
begin
dec(y);
if(dd<dv) then inc(x);
end
else
begin
inc(x);
if(dd<dh) then dec(y);
end;
end;
end;


{Body}
begin
write ('Insert R: ');
readln (Radius);
write ('Insert h: ');
readln (h);
setVM;
getVM;
GetTime(hour,minute,secund,secund100);
time:=hour*3600+minute*60+secund+secund100/100;
repeat
for j:=1 to h do
for i:= 1 to 720 do
begin
a:=i*3.141592/180;
l:=15;
c:=round(155-h/2+j+round(sin(a)*radius));
d:=100+round(cos(a)*radius);
PutPixelDos(c,d,l);
end;
inc(kol);
GetTime (Hour,minute,secund,secund100);
timenow:=3600*hour+60*minute+secund+secund100/100;
until time+10<timenow;
GetTime(hour,minute,secund,secund100);
time:=hour*3600+minute*60+secund+secund100/100;
repeat
for j:=1 to h do
for i:= 1 to 720 do
begin
a:=i*3.141592/180;
c:=round(155-h/2+j+round(sin(a)*radius));
d:=100+round(cos(a)*radius);
PutPixelAsm(c,d);
end;
inc(kolAsm);
GetTime (Hour,minute,secund,secund100);
timenow:=3600*hour+60*minute+secund+secund100/100;
until time+10<timenow;
GetTime(hour,minute,secund,secund100);
time:=hour*3600+minute*60+secund+secund100/100;
c:=round(155-h/2);
d:=100;
repeat
for j:=1 to h do
brezenDos(c+j,d,radius);
inc(kolBrez);
GetTime (Hour,minute,secund,secund100);
timenow:=3600*hour+60*minute+secund+secund100/100;
until time+10<timenow;
GetTime(hour,minute,secund,secund100);
time:=hour*3600+minute*60+secund+secund100/100;
c:=round(155-h/2);
d:=100;
repeat
for j:=1 to h do
brezenAsm(c+j,d,radius);
inc(kolBrezAsm);
GetTime (Hour,minute,secund,secund100);
timenow:=3600*hour+60*minute+secund+secund100/100;
until time+10<timenow;
restoreVM;
writeln ('Kol-vo Dos ',kol);
writeln ('Kol-vo Asm ',kolasm);
writeln ('Kol-vo BrezDos ',kolBrez);
writeln ('Kol-vo BrezAsm ',KolBrezAsm);
Writeln ('BrezAsm faster Dos in ',round(KolBrezAsm/kol));
readln;
end.