Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4106
Number of posts: 14016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
3 questions Posted by dolev9 on 26 Aug 2004 at 10:35 AM
since i sighned in only today
i have questions in 3 deferent subjects that i didnt resolved in
the few last weeks.
ill be glad to recieve an answer.


1) about interrupt creation:

i found a that throught it i found what interrupts are being used and what are free without any program/hardware who use them.
i tryed to replace the interrupt from an interrupt procedure of my own.

here what i did.



program setsbwav;
uses Dos,crt;
var
pt : pointer;

{$F+,S-,W-}
Procedure int60; Interrupt;
Begin
write(' hi ');
End;
{$F-,S+}

begin
clrscr;
GetIntVec($60,pt);
SetIntVec($60,@int60);
intr($60,reg);
{here it should of write hi many time until i press}
{a key - but it wrote hi only once}
readkey;
SetIntVec($60,@pt);
end.

ill be glad to recieve an answer soon.



2) about xms:
is there any way do make an ems array that is bigger then 64k?
is there any usefull things to do with it but copying the screen?
what is better about it from pointers?



3) about reading pcx image files:
the program part below is the part you read from 256 color pcx after u got the palette and the header, when you read the pixels colors.

header.linebytes = bytes per line.
height = header.maxy - header.miny.



For i := 0 to height - 1 do
begin
i2 := 0;
n := 0;
While (n < header.linebytes) do
begin
blockread(pcx,color,1);


if (color >= 192)
then begin
run := color - 192;
blockread (pcx,color,1);
n := n + run;
For w := 0 to run-1 do
begin
putpixel(i2,i,color);
inc(i2);
end;
end

else begin
n := n + 1;
putpixel(i2,i,color);
inc(i2);
end;
end;
end;
readkey;
end;


well i studied the pcx to the bone but i cant figger
why we need the red text part?



ill be very very glad to finally figer these out.
thenk you very much to the man who answer this long letter (sorry for the size).
dolev


Report
Re: 3 questions - Answer 2 Posted by zibadian on 26 Aug 2004 at 11:47 AM
: since i sighned in only today
: i have questions in 3 deferent subjects that i didnt resolved in
: the few last weeks.
: ill be glad to recieve an answer.
:
:
: 1) about interrupt creation:
:
: i found a that throught it i found what interrupts are being used and what are free without any program/hardware who use them.
: i tryed to replace the interrupt from an interrupt procedure of my own.
:
: here what i did.
:
:
:
: program setsbwav;
: uses Dos,crt;
: var
: pt : pointer;
:
: {$F+,S-,W-}
: Procedure int60; Interrupt;
: Begin
: write(' hi ');
: End;
: {$F-,S+}
:
: begin
: clrscr;
: GetIntVec($60,pt);
: SetIntVec($60,@int60);
: intr($60,reg);
: {here it should of write hi many time until i press}
: {a key - but it wrote hi only once}
: readkey;
: SetIntVec($60,@pt);
: end.
:
: ill be glad to recieve an answer soon.
:
:
:
: 2) about xms:
: is there any way do make an ems array that is bigger then 64k?
: is there any usefull things to do with it but copying the screen?
: what is better about it from pointers?
:
:
:
: 3) about reading pcx image files:
: the program part below is the part you read from 256 color pcx after u got the palette and the header, when you read the pixels colors.
:
: header.linebytes = bytes per line.
: height = header.maxy - header.miny.
:
:
:
: For i := 0 to height - 1 do
: begin
: i2 := 0;
: n := 0;
: While (n < header.linebytes) do
: begin
: blockread(pcx,color,1);
:
:
: if (color >= 192)
: then begin
: run := color - 192;
: blockread (pcx,color,1);
: n := n + run;
: For w := 0 to run-1 do
: begin
: putpixel(i2,i,color);
: inc(i2);
: end;
: end

: else begin
: n := n + 1;
: putpixel(i2,i,color);
: inc(i2);
: end;
: end;
: end;
: readkey;
: end;
:
:
: well i studied the pcx to the bone but i cant figger
: why we need the red text part?
:
:
:
: ill be very very glad to finally figer these out.
: thenk you very much to the man who answer this long letter (sorry for the size).
: dolev
:
:
:
You can create an EMS array up-to the maximum size of the EMS memory, as long as the individual elements aren't larger than 64k. Instead of dumping an heap array into the EMS memory, I would suggest that you use it element for element. This way it is quite simple to overcome the 64k barrier of Pascal (or even the 640k heap size). If each element has the same size, the position of the i-th element is easy to calculate:
  ElementPos(i) = i * ElementSize

This way the EMS memory acts as a zero-indexed array. The steps of setting the i-th value are simple:
  1: Seek ElementPos(i)
  2: Set Element

Reading a value is the same, but uses "Get Element" instead of "Set Element". The number of elements is easily calculated by using:
  ElementCount = EMSStream Size div ElementSize

and an element position setting a value at the ElementCount-th position allows you to add elements to the array.
As for what you can do with this is almost only limited by your imagination, and of course the EMS memory size. As for its potential over pointers: The maximum usable memory size you can access with pointers is around 400-500 kB. With the EMS memory you can use up to 16 MB of memory. The downside is that it is somewhat slower than pointers.
Report
Re: 3 questions - Answer 1 Posted by Alcatiz on 26 Aug 2004 at 3:28 PM
: : since i sighned in only today
: : i have questions in 3 deferent subjects that i didnt resolved in
: : the few last weeks.
: : ill be glad to recieve an answer.
: :
: :
: : 1) about interrupt creation:
: :
: : i found a that throught it i found what interrupts are being used and what are free without any program/hardware who use them.
: : i tryed to replace the interrupt from an interrupt procedure of my own.
: :
: : here what i did.
: :
: :
: :
: : program setsbwav;
: : uses Dos,crt;
: : var
: : pt : pointer;
: :
: : {$F+,S-,W-}
: : Procedure int60; Interrupt;
: : Begin
: : write(' hi ');
: : End;
: : {$F-,S+}
: :
: : begin
: : clrscr;
: : GetIntVec($60,pt);
: : SetIntVec($60,@int60);
: : intr($60,reg);
: : {here it should of write hi many time until i press}
: : {a key - but it wrote hi only once}
: : readkey;
: : SetIntVec($60,@pt);
: : end.
: :
: : ill be glad to recieve an answer soon.
: :
: :
: : ill be very very glad to finally figer these out.
: : thenk you very much to the man who answer this long letter (sorry for the size).
: : dolev
: :
: :
: :
: You can create an EMS array up-to the maximum size of the EMS memory, as long as the individual elements aren't larger than 64k. Instead of dumping an heap array into the EMS memory, I would suggest that you use it element for element. This way it is quite simple to overcome the 64k barrier of Pascal (or even the 640k heap size). If each element has the same size, the position of the i-th element is easy to calculate:
:
:   ElementPos(i) = i * ElementSize
: 

: This way the EMS memory acts as a zero-indexed array. The steps of setting the i-th value are simple:
:
:   1: Seek ElementPos(i)
:   2: Set Element
: 

: Reading a value is the same, but uses "Get Element" instead of "Set Element". The number of elements is easily calculated by using:
:
:   ElementCount = EMSStream Size div ElementSize
: 

: and an element position setting a value at the ElementCount-th position allows you to add elements to the array.
: As for what you can do with this is almost only limited by your imagination, and of course the EMS memory size. As for its potential over pointers: The maximum usable memory size you can access with pointers is around 400-500 kB. With the EMS memory you can use up to 16 MB of memory. The downside is that it is somewhat slower than pointers.
:
Hi !

In your code you make an interrupt and you call it once : so your message is displayed only once - that's normal.

Maybe there is a confusion in your mind between interrupt 60h and port 60h ? You may read port 60h to get the code of the last pressed or released key.

Am I wrong ?
Report
Re: 3 questions - Answer 1 Posted by dolev9 on 27 Aug 2004 at 12:07 PM
: : : since i sighned in only today
: : : i have questions in 3 deferent subjects that i didnt resolved in
: : : the few last weeks.
: : : ill be glad to recieve an answer.
: : :
: : :
: : : 1) about interrupt creation:
: : :
: : : i found a that throught it i found what interrupts are being used and what are free without any program/hardware who use them.
: : : i tryed to replace the interrupt from an interrupt procedure of my own.
: : :
: : : here what i did.
: : :
: : :
: : :
: : : program setsbwav;
: : : uses Dos,crt;
: : : var
: : : pt : pointer;
: : :
: : : {$F+,S-,W-}
: : : Procedure int60; Interrupt;
: : : Begin
: : : write(' hi ');
: : : End;
: : : {$F-,S+}
: : :
: : : begin
: : : clrscr;
: : : GetIntVec($60,pt);
: : : SetIntVec($60,@int60);
: : : intr($60,reg);
: : : {here it should of write hi many time until i press}
: : : {a key - but it wrote hi only once}
: : : readkey;
: : : SetIntVec($60,@pt);
: : : end.
: : :
: : : ill be glad to recieve an answer soon.
: : :
: : :
: : : ill be very very glad to finally figer these out.
: : : thenk you very much to the man who answer this long letter (sorry for the size).
: : : dolev
: : :
: : :
: : :
: : You can create an EMS array up-to the maximum size of the EMS memory, as long as the individual elements aren't larger than 64k. Instead of dumping an heap array into the EMS memory, I would suggest that you use it element for element. This way it is quite simple to overcome the 64k barrier of Pascal (or even the 640k heap size). If each element has the same size, the position of the i-th element is easy to calculate:
: :
: :   ElementPos(i) = i * ElementSize
: : 

: : This way the EMS memory acts as a zero-indexed array. The steps of setting the i-th value are simple:
: :
: :   1: Seek ElementPos(i)
: :   2: Set Element
: : 

: : Reading a value is the same, but uses "Get Element" instead of "Set Element". The number of elements is easily calculated by using:
: :
: :   ElementCount = EMSStream Size div ElementSize
: : 

: : and an element position setting a value at the ElementCount-th position allows you to add elements to the array.
: : As for what you can do with this is almost only limited by your imagination, and of course the EMS memory size. As for its potential over pointers: The maximum usable memory size you can access with pointers is around 400-500 kB. With the EMS memory you can use up to 16 MB of memory. The downside is that it is somewhat slower than pointers.
: :
: Hi !
:
: In your code you make an interrupt and you call it once : so your message is displayed only once - that's normal.
:
: Maybe there is a confusion in your mind between interrupt 60h and port 60h ? You may read port 60h to get the code of the last pressed or released key.
:
: Am I wrong ?
:



i saw 2 interrupts (number $1C - clock interrupt and interrupt
number sound blasters irq+8 (sound irq - in my computer specificly is 544). when i run them they repeat themselves in my entire program until i set the real interrupt back. but they are the only one who repeated themselves. i succeed making the sound port repeating itself by setting few variables to few ports (will succeed only to my sound blasters irq + 8). and the clock one i do not know why it succeeds... (no any special port variables needed...)
meaning - im still confused...
well thx anyway.
dolev

if interrupts do not repeat all the time - what special about them?
Report
Re: 3 questions - Answer 1 Posted by zibadian on 28 Aug 2004 at 6:30 AM
: : : : since i sighned in only today
: : : : i have questions in 3 deferent subjects that i didnt resolved in
: : : : the few last weeks.
: : : : ill be glad to recieve an answer.
: : : :
: : : :
: : : : 1) about interrupt creation:
: : : :
: : : : i found a that throught it i found what interrupts are being used and what are free without any program/hardware who use them.
: : : : i tryed to replace the interrupt from an interrupt procedure of my own.
: : : :
: : : : here what i did.
: : : :
: : : :
: : : :
: : : : program setsbwav;
: : : : uses Dos,crt;
: : : : var
: : : : pt : pointer;
: : : :
: : : : {$F+,S-,W-}
: : : : Procedure int60; Interrupt;
: : : : Begin
: : : : write(' hi ');
: : : : End;
: : : : {$F-,S+}
: : : :
: : : : begin
: : : : clrscr;
: : : : GetIntVec($60,pt);
: : : : SetIntVec($60,@int60);
: : : : intr($60,reg);
: : : : {here it should of write hi many time until i press}
: : : : {a key - but it wrote hi only once}
: : : : readkey;
: : : : SetIntVec($60,@pt);
: : : : end.
: : : :
: : : : ill be glad to recieve an answer soon.
: : : :
: : : :
: : : : ill be very very glad to finally figer these out.
: : : : thenk you very much to the man who answer this long letter (sorry for the size).
: : : : dolev
: : : :
: : : :
: : : :
: : : You can create an EMS array up-to the maximum size of the EMS memory, as long as the individual elements aren't larger than 64k. Instead of dumping an heap array into the EMS memory, I would suggest that you use it element for element. This way it is quite simple to overcome the 64k barrier of Pascal (or even the 640k heap size). If each element has the same size, the position of the i-th element is easy to calculate:
: : :
: : :   ElementPos(i) = i * ElementSize
: : : 

: : : This way the EMS memory acts as a zero-indexed array. The steps of setting the i-th value are simple:
: : :
: : :   1: Seek ElementPos(i)
: : :   2: Set Element
: : : 

: : : Reading a value is the same, but uses "Get Element" instead of "Set Element". The number of elements is easily calculated by using:
: : :
: : :   ElementCount = EMSStream Size div ElementSize
: : : 

: : : and an element position setting a value at the ElementCount-th position allows you to add elements to the array.
: : : As for what you can do with this is almost only limited by your imagination, and of course the EMS memory size. As for its potential over pointers: The maximum usable memory size you can access with pointers is around 400-500 kB. With the EMS memory you can use up to 16 MB of memory. The downside is that it is somewhat slower than pointers.
: : :
: : Hi !
: :
: : In your code you make an interrupt and you call it once : so your message is displayed only once - that's normal.
: :
: : Maybe there is a confusion in your mind between interrupt 60h and port 60h ? You may read port 60h to get the code of the last pressed or released key.
: :
: : Am I wrong ?
: :
:
:
:
: i saw 2 interrupts (number $1C - clock interrupt and interrupt
: number sound blasters irq+8 (sound irq - in my computer specificly is 544). when i run them they repeat themselves in my entire program until i set the real interrupt back. but they are the only one who repeated themselves. i succeed making the sound port repeating itself by setting few variables to few ports (will succeed only to my sound blasters irq + 8). and the clock one i do not know why it succeeds... (no any special port variables needed...)
: meaning - im still confused...
: well thx anyway.
: dolev
:
: if interrupts do not repeat all the time - what special about them?
:
Interrupts interrupt the normal program flow to perform some processing. This is determined system-wide instead of process-wide. Thus an TSR program can hook an interrupt and be called during the execution of another program.
As for the code you gave the Intr() procedure only calls the interrupt once. In this case it is the same as calling Int60 directly.
Report
Re: 3 questions - Answer 1 Posted by bog2k3 on 28 Aug 2004 at 10:43 AM
hi. i think you are very confused about these interrupts. i was to at the beggining.
here's how they work:

an interrupt procedure doesn NOT repeat itself NEVER. they are always called by the CPU when it receives a signal from a specific hardware inside the computer. they are called at the very time when the CPU is signalled by the hardware, so they can interrupt a task that is running at that moment. That's why they are called interrupt procedures.
there is a real-time clock inside the computer that generates a tick every 55 miliseconds (18.2 times per second). Each time the CPU receives this clock tick, it calls interrupt 1ch (timer interrupt) so that's why it looks like the interrupt repeats itself.
For instance, when you press a key, a signal is sent to the CPU and the CPU generates int 9 (keyboard interrupt) in order to handle the key that was pressed and so on.
I hope you understand how they work now.

There is one more thing. You can modify interrupt vectors (set them to point to your own procedures) and you can also manually call a specific interrupt (via intr()). In this case it is called a "software interrupt". I suggest you don't mess whith modifying the interrupt vectors unless you know exactly what you are doing.

There is also a technique called "hooking" that alows you to modify an interrupt vector, go resident (via keep) and when that interrupt occurs your program can pop-up and do whatever you need it to. (this is how API works)



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.