SHL and SHR / Using Interrupts in Protect Mode 
Author Message
 SHL and SHR / Using Interrupts in Protect Mode

I have heard that SHL and SHR are considerably faster than standard divide
and multiply commands, but how do I use them? For 2*2 I tried 2 shl 2 (and
2 shr 2) but I didn't anything close to a right answer. So how can I
effectively use them when I need to do a LOT of multiplying and dividing?
(examples would help!)

Also, I wanted to use interrupts in a protected-mode application to call
the Sound Blaster, and to do a few graphic effects. (page flipping,
palette rotation, etc..)

However, it seems like interrupts don't work well in protected-mode (it
flips to real mode or somthing..) and i'd like to know if there is a
*safe* way to use them with out crashing my computer. Also, what interrupt
would I use if I wanted to (for instance) call a procedure that would
change x colors each time it was called? Is there a "standard" interrupt
for this? Or do I have to pick a certain one? (and if so, which one!!) I
don't want to end up grabbing the hard drive interrupt and causing
havoc....

Thanks! Email me if possible.



Wed, 18 Jun 1902 08:00:00 GMT  
 SHL and SHR / Using Interrupts in Protect Mode

Quote:

>I have heard that SHL and SHR are considerably faster than standard divide
>and multiply commands, but how do I use them? For 2*2 I tried 2 shl 2 (and
>2 shr 2) but I didn't anything close to a right answer. So how can I
>effectively use them when I need to do a LOT of multiplying and dividing?
>(examples would help!)

http://www.geocities.com/Paris/3537/Pascal07.txt


Wed, 18 Jun 1902 08:00:00 GMT  
 SHL and SHR / Using Interrupts in Protect Mode

Quote:

>I have heard that SHL and SHR are considerably faster than standard divide
>and multiply commands, but how do I use them? For 2*2 I tried 2 shl 2 (and
>2 shr 2) but I didn't anything close to a right answer. So how can I
>effectively use them when I need to do a LOT of multiplying and dividing?
>(examples would help!)
>Thanks! Email me if possible.


Email has been sent as requested but others seem to have this problem
to. Hopefully this simple example will help.

Regards,
Clif

Program ShiftOps;
{ Turbo v.6.0 demo of SHL and SHR for multiplying and integer dividing
POSITIVE integers by multiples of two. No overflow or underflow

VAR
n, ans:LongInt; (* 32 bit maximum values *)
shift:Byte;

Begin
     Writeln; Writeln; Writeln;
     n := 1;
     For shift := 1 to 20  Do
     Begin
          ans := n SHL 1;
          Writeln('2 ^ ', shift:2, ' = ', ans:8);
          n := ans;
     End;
     Write('  <<< Press Enter>>> '); Readln;  Writeln;

     For shift := 1 to 20 Do
     Begin
          ans := n SHR 1;
          Writeln(n:7, ' div 2 = ', ans);
          n := ans;
     End;

     n := 537169;
     ans := n SHL 3;
     Writeln(n, ' * 8 = ', ans);

     ans := n SHR 4;
     Writeln(n, ' div 16 = ', ans);
     Write('  <<< Press Enter>>> '); Readln;
End.



Wed, 18 Jun 1902 08:00:00 GMT  
 SHL and SHR / Using Interrupts in Protect Mode

Quote:
>I have heard that SHL and SHR are considerably faster than standard divide
>and multiply commands, but how do I use them? For 2*2 I tried 2 shl 2 (and
>2 shr 2) but I didn't anything close to a right answer. So how can I
>effectively use them when I need to do a LOT of multiplying and dividing?
>(examples would help!)

The shift left and right shift an integer left or right n places, eg:
  2 shl 1     = 2*(2^1)     = 4.
  1 shl 10    = 1*(2^10)    = 1024
  1024 shr 10 = 1024/(2^10) = 1
  1345 shr 5  = 1324/(2^5)  = 42
(psuedocode follows)
      1111xB shl 3 = 1111000xB
  10101010xB shr 3 =   10101xB

It can be interpreted as shifting the binary point.
--

Quote:
>:-P


...And on the seventh day, He connected to the WWW and did nothing...


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. SHL and SHR / Using I

2. SHR / SHL

3. SHR and SHL ??

4. shl and shr

5. Real mode Interrupts and pointers in Protected Mode

6. Protected mode interrupt registers and stack?

7. protected mode and interrupts ???

8. Interrupts in Protected Mode

9. Interrupt-Handler in Protected Mode

10. Chaining to timer interrupt from protected mode

11. interrupt-based coppering routines in protected mode?

 

 
Powered by phpBB® Forum Software