Thread: Stuck in 90s program. please help

  1. #1
    Registered User
    Join Date
    May 2017
    Posts
    2

    Stuck in 90s program. please help

    Hey guys,

    I am still stuck in 90s program of c language looking for someone's help.

    I am trying to develop a terminate and stay resident program(TSR) which can displays "HELLO" in bold whenever I press the 'N' key from keyboard.

    This is my code here
    Code:
    #include<dos.h>
    #include<bios.h>
    #include<stdio.h>
    #include<conio.h>
    void interrupt (*old)(void);
    void interrupt myname(unsigned int AX);
    char far *scr=(char far* ) 0xb8000000;
    
    void main()
    {
       clrscr();
       old=getvect(0x09);    //SAVE OLD VECTOR IN 'OLD'
       setvect(0x09,myname);//SET NEW VECTOR
       keep(0,1000);        //USED IN TSR TO KEEP MEMORY WHEN TERMINATED
       getch();
    
        }
    
         void interrupt myname (unsigned int AX)
          {
          if(*((char*) &AX) == 0x31)
          {
            (*(scr))=0x7048;    //H
            (*(scr+1))=0x7045;    //E
            (*(scr+2))=0x704C;    //L
            (*(scr+3))=0x704C;    //L
            (*(scr+4))=0x704F;    //O
    
            }
            else{
            (*old)();}        
    
          }
    
    

    Looking forward for help

    Regards

    Jessica


  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Let's assume for the moment you're running on an actual DOS machine, or a virtual machine running an actual DOS machine, and that you're running an actual 90's era 16-bit DOS 'C' compiler like TurboC.

    > void interrupt myname(unsigned int AX);
    ISR's don't have parameters.
    If you want to inspect registers, then you use whatever magic comes with your compiler. Maybe it's a magic variable like _AX, maybe it's a 'struct regs' of some sort.

    > (*old)();
    I don't think you need an else here, you should always pass on the interrupt to the next service in the chain.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    May 2017
    Posts
    2
    Quote Originally Posted by Salem View Post
    Let's assume for the moment you're running on an actual DOS machine, or a virtual machine running an actual DOS machine, and that you're running an actual 90's era 16-bit DOS 'C' compiler like TurboC.

    > void interrupt myname(unsigned int AX);
    ISR's don't have parameters.
    If you want to inspect registers, then you use whatever magic comes with your compiler. Maybe it's a magic variable like _AX, maybe it's a 'struct regs' of some sort.

    > (*old)();
    I don't think you need an else here, you should always pass on the interrupt to the next service in the chain.
    OK. but which condition should I use in order to intercept the 'N' key from keyboard?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Tell us which compiler you're using, and someone might be able to tell you how to access registers within ISR's.

    TBH, why are you even learning this stuff? Are you looking for a job as a curator of software in a museum?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 03-15-2016, 06:35 AM
  2. A little stuck with this program.
    By joshrod921 in forum C Programming
    Replies: 5
    Last Post: 05-31-2014, 07:32 PM
  3. Stuck in a MPI program.
    By jeffwang in forum C Programming
    Replies: 2
    Last Post: 01-05-2012, 06:33 PM
  4. Stuck on a program
    By Northstar in forum C Programming
    Replies: 4
    Last Post: 10-12-2007, 03:02 AM
  5. Stuck On Program
    By Robert Parker in forum C++ Programming
    Replies: 5
    Last Post: 06-04-2002, 01:41 PM

Tags for this Thread