Calling ISR w/o interrupt

This is a discussion on Calling ISR w/o interrupt within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I'm using VESA modes 10Eh and 111h. In real mode bank switching is slow, but a necessary evil. So, instead ...

  1. #1
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596

    Calling ISR w/o interrupt

    I'm using VESA modes 10Eh and 111h. In real mode bank switching is slow, but a necessary evil. So, instead of calling the ISR via an interrupt I figured that a far call would be faster.

    Obviously I was wrong. Why is the far call slower than the interrupt when interrupts are known for being notoriously slow?

    Here is my code:
    Code:
    void far (*VideoINT)();
    void far *ISR;
    
    int main(void)
    {
      WORD vidoffset
      WORD vidsegment
    
      asm
      {
        mov ax,0
        mov es,ax
        mov [vidoffset],es:[010h*4]
        mov [vidsegment],es:[010h*4+2]
      }
      ISR=MK_FP(vidsegment,vidoffset);
      (void far *)VideoInt=(void far *)ISR;
      ...
      ...   //this portion sets up the rendering system
      ...   //Not relevant to question, didn't include
    return 0;
    }
    so for bank switch:

    Code:
    void PlotPixel(DWORD offset,WORD color)
    {
      static WORD bank;
      WORD actualoffset=offset & 0xFFFF;
      WORD curbank=offset>>16;
      asm
     {
        START:
          mov ax,[curbank]
          cmp ax,[bank]
          jz PLOTPIXEL
        BANKSWITCH:
          mov ax,04f05h
          mov bx,0
          mov dx,[curbank]
          push dx                //Preserve dx across call
          call VideoINT        //far call to int 10 based on int vector table
          pop dx
          mov [bank],dx     //Set bank to curbank
        PLOTPIXEL:
          mov ax,0a000h
          mov es,ax
          mov di,word(actualoffset)
          mov ax,color
          stosw
      }
    }
    If I was to replace call VideoINT with int 10h, the entire function is faster.

    This does not make sense to me. It is faster to plot pixels via a far pointer than to use an ISR to do so. Why isn't it faster to call the INT 10 ISR instead of invoking it via an interrupt? I thought this would be a way to circumvent the slow bank switch interrupt call, but I guess not.

    I'm also only specifying 0 in BX because it is too slow to call or invoke the ISR twice for 0 and 1. Besides, it works fine just using 0, so I left it.


    Never mind....I'm so careless. In my actual code I forgot to preserve dx across the call. So when I called the ISR, dx was obviously changed. When I assigned dx to curbank, dx did not really represent the correct bank. This forced a bank switch on every single pixel (hitting myself in the head). Sorry everyone, but I figured it out amidst writing this.


    Well, anyways, this is a fast plot pixel function for VESA modes.
    For those that don't like or know assembly (mine is far from perfect) this can be done in C as well.

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Did some more testing. It seems that my failure to preserve dx across the call was also costing me frames on my function that uses int 10h.

    It is slightly faster to use the interrupt than the far pointer. Still don't know why. Both operations have to push the return address or the address of the caller onto the stack. Perhaps C does one more operation or two on a far call. Obviously the ISR lies too far away from my segment for it to be a near pointer. My ISR is at df5f:000f for int 10. My segment according to DOS is way away from there.

    I know what happens when the CPU encounters an interrupt. I don't know for sure what exactly happens during a far call in C. This might be where the speed discrepancy is.

    Anyone know?

  3. #3
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    look up how you'd go about extracting the Linear Frame Buffer (LBF) address... then you can do pixel pushing as if it were a 13h style mode... however, if you are still using real mode, you won't be able to do any double buffering... in fact, if you are still < 1024K, i don't even think you can use LBF... well ttyl... hth...
    hasafraggin shizigishin oppashigger...

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Yes, I know how to get the address of the LFB, and no I cannot use it in real mode. VBE 2.0+ cannot be done in real mode, as far as I know. I don't even think I could get around the problem in assembly. The pixel offset will always extend beyond a 64K segment. I have downloaded several IDEs, NASM, TASM, MASM, DPMI16, and DPMI32 so I am going to port to protected mode soon - after I make sure they are virus free.

    I also downloaded the new Art of Assembly lanugage for protected mode. It seems that the original site for AoA has been moved (link was broken for some time), but now www.webster.cr.edu (look up art of assembly language on excite) There is also a free version of HLA or High Level Assembly language assembler. From what I've seen it looks like it uses C/C++ constructs, which makes it easier to learn asm.

    Check it out, if you are interested.

    I've been looking for DOS4GW, but not much is available. Not sure if Rational Systems is still around. No info on DOS4GW in the interrupt listing.

  5. #5
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    okay, i thought you'd go so far as to know about LFB-mode and protected mode/extended memory... i don't see why you'd go about doing VESA stuff in real mode tho... i used protected mode from scratch... why are you doing this? i don't know where you'd be able to get dos4gw... that's a good question, and i don't think they are around anymore...
    hasafraggin shizigishin oppashigger...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 06:49 PM
  2. Interrupt sharing
    By Roaring_Tiger in forum Networking/Device Communication
    Replies: 8
    Last Post: 10-09-2004, 04:05 PM
  3. DOS, Serial, and Touch Screen
    By jon_nc17 in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 01-08-2003, 04:59 PM
  4. Calling Interrupt
    By vnrabbit in forum C Programming
    Replies: 2
    Last Post: 05-02-2002, 08:33 AM
  5. Sound card interrupt problems
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 12-05-2001, 04:38 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21