Like Tree6Likes

Need pointer help: Interrupt vectors

This is a discussion on Need pointer help: Interrupt vectors within the C Programming forums, part of the General Programming Boards category; One last suggestion, since we're getting you out of the stone age... You should probably download a copy of the ...

  1. #16
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    One last suggestion, since we're getting you out of the stone age...
    You should probably download a copy of the Windows 7 API documentation and have it at the ready as you work.

    Download Details - Microsoft Download Center - Microsoft Windows 7 SDK (ISO)

    Note: if you are on 32 bit OS you want GRMSDK ... if you are on 64 bits it's GRMSDKX

    Just burn the ISO to a DVD and then run the setup program from the disk.

    (There is a newer version but this one is better, trust me!)

    There is also a copy of an older SDK (90% of the calls are there) that can be integrated right into POIDE giving you access to most API calls with F1 (just like your C library calls)...

    http://www.pellesc.de/files/help/setup_Win98SDK.exe

    If you are on Vista or Win7 you may need to download this upgrade...
    Users may be unable to open Help (.hlp) files

    Once you have it set up, simply open POIDE...
    Click -> Tools -> Customize -> Help Files -> New (square box icon)
    Enter menu text "Windows 98 SDK"
    Browse and find guide.hlp in the win98sdk's folder...
    Make sure this is the first item on the list.

    Ok your way out... Exit and restart POIDE and put your cursor on a windows function call (eg. SetTimer()) and press F1... It should pop right up.
    Similarly placing your text cursor on any C keyword should also bring up it's information by pressing F1 ...

    The big Win7 SDK has to be accessed separately...

  2. #17
    Registered User
    Join Date
    Sep 2011
    Posts
    9
    Quote Originally Posted by CommonTater View Post
    One last suggestion, since we're getting you out of the stone age...
    You should probably download a copy of the Windows 7 API documentation and have it at the ready as you work.

    Download Details - Microsoft Download Center - Microsoft Windows 7 SDK (ISO)

    Note: if you are on 32 bit OS you want GRMSDK ... if you are on 64 bits it's GRMSDKX

    Just burn the ISO to a DVD and then run the setup program from the disk.

    (There is a newer version but this one is better, trust me!)

    There is also a copy of an older SDK (90% of the calls are there) that can be integrated right into POIDE giving you access to most API calls with F1 (just like your C library calls)...

    http://www.pellesc.de/files/help/setup_Win98SDK.exe

    If you are on Vista or Win7 you may need to download this upgrade...
    Users may be unable to open Help (.hlp) files

    Once you have it set up, simply open POIDE...
    Click -> Tools -> Customize -> Help Files -> New (square box icon)
    Enter menu text "Windows 98 SDK"
    Browse and find guide.hlp in the win98sdk's folder...
    Make sure this is the first item on the list.

    Ok your way out... Exit and restart POIDE and put your cursor on a windows function call (eg. SetTimer()) and press F1... It should pop right up.
    Similarly placing your text cursor on any C keyword should also bring up it's information by pressing F1 ...

    The big Win7 SDK has to be accessed separately...
    I have installed everything suggested in CommonTater's post (above), and that proves to be a big help.

    I am still struggling with trying to get a timer operational. In my original DOS C program, I tapped into the BIOS 18.x MS heartbeat timer interrupt, and simply decremented a couple of integer countdown timers, if they were non-zero. That way, my application software could load a timer, go on about its business, then check the timer later to see if it had expired. In moving this old DOS app to a WIN32 app, I'd like to have a periodic timer which would decrement the same countdown timers as before, in order to minimize changes to program structure, until I get something working. Later, I would be able to consider whether there might be a better way of doing things.

    In an earlier post, CommonTater suggested:
    Code:
    // timer with callback
    #define WIN32_DEFAULT_LIBS
    #include<windows.h>
    #include <stdio.h>
    
    void CALLBACK TimeProc(HWND wnd, UINT msg, UINT event, DWORD time)
      { 
        printf("Hello world... on a timer!\n");
        Beep(500,100);
      }
    
    
    int main (void)
      { MSG msg;
    
    
        if (! SetTimer(NULL,0,1000,TimeProc) )
          printf("Well that didn't work");  
    
       
        while( GetMessage(&msg,NULL,0,0) )
          DispatchMessage(&msg);
    
     
      return 0;
    }
    This works fine (after I discovered that I had to enable "Microsoft Extensions" in Pelles C), but I have been unsuccessful in getting this intergrated into my application, such that it checks and decrements my prior countdown timers.

    I also tried creating a Thread, and having it run:
    Code:
    DWORD myTimerWrapper ( void *p ) {
      while ( 1 ) {
        MyTimer();  // do your thing
        Sleep(x);   // how often your DOS TIMER interrupt happened.
      }
    }
    I have not been able to get that working, either. As well as just not working, it also complains about the "endless loop".

    If anyone can give me some help on implementing the simple, global down-counter variables at a constant periodic rate (say 10 - 20 MS), I would certainly appreciate it.

    Thanks,
    jhilory

  3. #18
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,671
    >> That way, my application software could load a timer, go on about its business, then check the timer later to see if it had expired.
    If your are only checking for "expiration", then you could just calculate how much time has elapsed:
    Code:
    #include <windows.h>
    #include <stdio.h>
    
    DWORD TimeElapsed(DWORD start)
    {
        DWORD end = GetTickCount();
        if (end < start)
            return (0xFFFFFFFFU - start) + end;
    
        return end - start;
    }//TimeElapsed
    
    int main()
    {
        DWORD start = GetTickCount();
    
        Sleep(3000);
    
        printf("%ums elapsed\n", TimeElapsed(start));
    
        return 0;
    }//main
    gg

  4. #19
    Registered User
    Join Date
    Sep 2011
    Posts
    9
    Quote Originally Posted by Codeplug View Post
    >> That way, my application software could load a timer, go on about its business, then check the timer later to see if it had expired.
    If your are only checking for "expiration", then you could just calculate how much time has elapsed:
    Code:
    #include <windows.h>
    #include <stdio.h>
    
    DWORD TimeElapsed(DWORD start)
    {
        DWORD end = GetTickCount();
        if (end < start)
            return (0xFFFFFFFFU - start) + end;
    
        return end - start;
    }//TimeElapsed
    
    int main()
    {
        DWORD start = GetTickCount();
    
        Sleep(3000);
    
        printf("%ums elapsed\n", TimeElapsed(start));
    
        return 0;
    }//main
    gg
    Oh, Thank you, thank you! Sometimes we make things much more complicated than we should. Or, maybe it is just "I've always done it this way, and, by Golly, I'm going to continue doing it this way, because thats the way I've always done it"!

    Again, thanks.

    jhilory
    Maz likes this.

  5. #20
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by jhilory View Post
    Oh, Thank you, thank you! Sometimes we make things much more complicated than we should. Or, maybe it is just "I've always done it this way, and, by Golly, I'm going to continue doing it this way, because thats the way I've always done it"!

    Again, thanks.

    jhilory
    Yo mean, kinda like you're doing with this code?

  6. #21
    Registered User
    Join Date
    Sep 2011
    Posts
    9
    Quote Originally Posted by CommonTater View Post
    Yo mean, kinda like you're doing with this code?
    Yes! Sometimes, when I get started down a path, I cannot see the forrest for the trees!

    I guess I'm having trouble with the basic concepts of Windows programming, as well as the API syntax. I don't really want a window, a command line with minimal display is all that I need. I guess I've let that cloud my thinking, somewhat, and resisted learning anything about Windows programming for years. I appreciate the help I am getting from this group. Please bear with me, I will try to not be a pest!

    Thanks,
    jhilory
    Maz likes this.

  7. #22
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Well for starts... you only get a "window" if you make a window... Create your projects as Windows Console projects and you are writing command line code, just like you see everyone here posting about. What many people forget is that a "console" program is still a windows program... which means you can use any of the Windows API calls to complete your task. You also have the standard C-99 library, much of which you will be familiar with and a whole lot of new stuff you many need to read up on...

    Fortunately Pelles C is fully documented which is one of the reasons I keep recommending it to newbies; no excuses for not looking stuff up! Anyhow... At your disposal you have what is probably the best help system I've ever seen... Every library call is fully documented as are the language keywords and just about everythig else. It's all under F1 ... just put your cursor on a keyword or libarary function and press F1... voila everything you need to know.

    I think one of the biggest errors I see people making is trying to make the wonderful new thing be just like the tired old thing... We don't want to re-learn or study --heaven forbid we should actually read the owner's manual-- so we start trying to get the wonderful new tool to behave just like the old one that didn't do the job. It doesn't take much head scratching to suss out the result...

    This of course is my roundabout way of suggesting that perhaps you should consider a full rewrite and update of your old DOS software instead of trying to drag Pelles C down to Turbo C's level... In my experience, unless you've got, figuratively speaking, a million lines of code it might actually better and faster to just redo the thing, in the new way.

  8. #23
    Maz
    Maz is offline
    Registered User Maz's Avatar
    Join Date
    Nov 2005
    Location
    Finland
    Posts
    194
    I just had to like this a bit more =) command line terminal with minimal display... Resisting everything new... Recognized some parts suiting me. Utopia is still the best strategy computer game. Unix command line is still what i use. Vim+ctags is my "ide" etc.

    But even though its hard to admitt, sometimes something new is usefull. I admitt I've written some simple guis for my command line programs using Qt and qdevelop - naturally not for use but to know my enemy... Although it may be that when no one sees... =p

  9. #24
    Registered User
    Join Date
    Sep 2011
    Posts
    9
    Well for starts... you only get a "window" if you make a window... Create your projects as Windows Console projects and you are writing command line code, just like you see everyone here posting about. What many people forget is that a "console" program is still a windows program... which means you can use any of the Windows API calls to complete your task. You also have the standard C-99 library, much of which you will be familiar with and a whole lot of new stuff you many need to read up on...
    I really am listening, and trying to learn. I am aware that a console program is a Windows program, and that I can use the Windows APIs. I am, however, so inexperienced with this Windows thing, and how to use what is available ..., it's pretty overwhelming!
    Fortunately Pelles C is fully documented which is one of the reasons I keep recommending it to newbies; no excuses for not looking stuff up! Anyhow... At your disposal you have what is probably the best help system I've ever seen... Every library call is fully documented as are the language keywords and just about everythig else. It's all under F1 ... just put your cursor on a keyword or libarary function and press F1... voila everything you need to know.
    I followed your suggestions in an earlier post and downloaded and installed the Windows SDK (it's 1.4 GB!), then downloaded and installed the Win98SDK from the Pelles C site. I got it linked into Pelles C, such that F1 does bring up API references. It appears, however, that it is mostly "Windows 95" and older, I found some of the help for APIs, that I was trying to use, was missing. When you say "fully documented", is there something other than the help file, that I may be missing?
    I think one of the biggest errors I see people making is trying to make the wonderful new thing be just like the tired old thing... We don't want to re-learn or study --heaven forbid we should actually read the owner's manual-- so we start trying to get the wonderful new tool to behave just like the old one that didn't do the job. It doesn't take much head scratching to suss out the result...
    I hear what you are saying, and I have not, really, buried my head in the sand. I'm just trying to understand some of the Windows concepts, enough to get something up and going. Later, after more experience, I can start thinking more about "is there a better way?".
    This of course is my roundabout way of suggesting that perhaps you should consider a full rewrite and update of your old DOS software instead of trying to drag Pelles C down to Turbo C's level... In my experience, unless you've got, figuratively speaking, a million lines of code it might actually better and faster to just redo the thing, in the new way.
    Right now, I don't know enough about Windows programming and its basic concepts to undertake a full rewrite.., maybe later. Most of my code is pretty straight-forward -- receiving a serial data input, converting hexidecimal input chars, getting everything in the proper structure (byte, word, etc.), and writing it all to several CSV files for later database input. This is already written in C, and not much required to move it into Pelles C. This program is called by Windows' Scheduler on a periodic basis to collect data from several different sources. My original program is written to work with COM1 and COM2 (the std PC COM ports), but now, since PCs don't come with any COM ports, I was faced with making changes to handle any higher-numbered COM port, virtual or otherwise, and, eventually, ethernet. That is what spurred my interest in moving my program into a Windows environment.

    I have Windows 8 Developers Preview installed on one machine, and it came with Visual C++ 2011 Express Edition Preview. I have played around with it a little, and it makes me like Pelles C even more! Thanks for turning me on to Pelles C!
    jhilory

  10. #25
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by jhilory View Post
    I really am listening, and trying to learn. I am aware that a console program is a Windows program, and that I can use the Windows APIs. I am, however, so inexperienced with this Windows thing, and how to use what is available ..., it's pretty overwhelming!
    Yes it is. I've been programming C/WinAPI for about 7 years now and it *still* overwhelms me. Hey, between the Windows API, Pelles C (with it's expanded library), Direct X, SDL and a couple of others, we're looking at very near 50,000 function calls! This is where one either gets real good at "looking stuff up" or finds a new career...

    I followed your suggestions in an earlier post and downloaded and installed the Windows SDK (it's 1.4 GB!), then downloaded and installed the Win98SDK from the Pelles C site. I got it linked into Pelles C, such that F1 does bring up API references. It appears, however, that it is mostly "Windows 95" and older, I found some of the help for APIs, that I was trying to use, was missing. When you say "fully documented", is there something other than the help file, that I may be missing?
    Nope it's all there.

    Pelles help file is a full disclosure of his toolchain, IDE, C-99 and libraries. There's even a mini-tutorial in there.

    The SDK version I linked to is the last version that installs the Windows API reference directly on your hard disk. It's current to Win7 sp1. All newer versions link to their online reference... which mean's you're dinked if you don't have Internet access at the moment. Hense my recommendation for that version.

    The Win98 sdk that comes up from F1 is old, but still perfectly valid and useable... about 90% of the Win7 Api is covered in there, but it really only for "quick reference"... the SDK should be the final authority on what's current and what's not.

    Between those files you have pretty much the whole schebang.

    I hear what you are saying, and I have not, really, buried my head in the sand. I'm just trying to understand some of the Windows concepts, enough to get something up and going. Later, after more experience, I can start thinking more about "is there a better way?".
    Think of it as an opportunity for professional growth... Especially important since the world is moving to 64bit processing and most amd64 OSs will not even run 16 bit code anymore...

    Right now, I don't know enough about Windows programming and its basic concepts to undertake a full rewrite.., maybe later. Most of my code is pretty straight-forward -- receiving a serial data input, converting hexidecimal input chars, getting everything in the proper structure (byte, word, etc.), and writing it all to several CSV files for later database input. This is already written in C, and not much required to move it into Pelles C. This program is called by Windows' Scheduler on a periodic basis to collect data from several different sources. My original program is written to work with COM1 and COM2 (the std PC COM ports), but now, since PCs don't come with any COM ports, I was faced with making changes to handle any higher-numbered COM port, virtual or otherwise, and, eventually, ethernet. That is what spurred my interest in moving my program into a Windows environment.
    Believe me, you will learn real fast when you have to use CreateFile(), ReadFile(), WriteFile() and CloseFile() with your com ports... THAT is an education in and of itself...

    I have Windows 8 Developers Preview installed on one machine, and it came with Visual C++ 2011 Express Edition Preview. I have played around with it a little, and it makes me like Pelles C even more! Thanks for turning me on to Pelles C!
    jhilory
    Hey... I know exactly what you're saying... I keep going off to try wonderful new languages and compilers, I discover some of the niftyiest stuff (Like D and HLA) but no matter what I do, I somehow always wind up back on Pelles C... And to be honest, it's mostly because of POIDE and it's various facilities; help file, resource editors, etc.

    If you check into the Pelles C forums... Pelles C forum - Index ... you will discover a very competent and helpful crew of people. You will also discover AddIns, Wizards and Libraires that you can download... You might even recognize one of the authors ...

    I'm glad its working out so well for you!
    jhilory likes this.

  11. #26
    Registered User
    Join Date
    Sep 2011
    Posts
    9
    Quote Originally Posted by CommonTater View Post
    If you check into the Pelles C forums... Pelles C forum - Index ... you will discover a very competent and helpful crew of people. You will also discover AddIns, Wizards and Libraires that you can download... You might even recognize one of the authors ...

    I'm glad its working out so well for you!
    Thanks for the kind words, and the advice. I started browsing the Pelles C forum earlier this week. I intend to spend some more time there!

    I am busy, now, in the guts of my program, making the changes necessary for the serial port handling.

    Jhilory

  12. #27
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by jhilory View Post
    I am busy, now, in the guts of my program, making the changes necessary for the serial port handling.
    Jhilory
    ATV1E1 ... ATA... ATH1 ... My friend.

  13. #28
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by CommonTater View Post
    ATV1E1 ... ATA... ATH1 ... My friend.
    You rang?


    Quzah.
    CommonTater likes this.
    Hope is the first step on the road to disappointment.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Vectors in vectors - pointers and iterators
    By fisherking in forum C++ Programming
    Replies: 8
    Last Post: 07-27-2010, 09:34 AM
  2. Help with writing an interrupt
    By David_O in forum C Programming
    Replies: 5
    Last Post: 02-17-2010, 10:26 AM
  3. ASM interrupt and others
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 06-08-2002, 07:18 PM
  4. interrupt
    By juandy in forum C++ Programming
    Replies: 4
    Last Post: 05-21-2002, 08:24 AM
  5. Interrupt???
    By GiSH in forum C++ Programming
    Replies: 1
    Last Post: 11-15-2001, 11:27 AM

Tags for this Thread


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