且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何通过ctrl + alt + l键的组合生成中断。?

更新时间:2023-12-02 23:45:10

请参阅我对问题的评论,这是答案的主要部分。有关BIOS中断,请参阅: INT 16H - ***,免费的百科全书 [ ^ ]。



在这个级别上,你可以在键盘扫描码的水平上工作。



正如我已经在我的评论中试图解释的那样,生成中断是荒谬的。这不是事情的运作方式。对于某些教育,请参阅:控制反转 - ***,免费的百科全书 [ ^ ]。



-SA

Write a TSR program in C that will clear all the contents of the screen and print your VU ID and Name (BC0000000-Name) at the center of the video text memory available at 0xB8000000 whenever Alt+Ctrl+D combination is pressed from keyboard.

Note that you have to take the backup of the contents of video text memory before clearing the screen. And, whenever Alt+Ctrl+R combination is pressed from the keyboard, all the contents of video text memory should be restored.



My Code for this Problem:
Problem occurs at the end of the code for keyboard interrupt

//CLRSCREEN AND Character Printing Program
#include<DOS.H>
#include<stdio.h>
void interrupt (*old)();
void interrupt scrnsvr();
//void interrupt (*oldkey)();
//void interrupt newkey();
//void cls();              SALMAN HAIDER

unsigned char far *scr = (unsigned char far*)0xb8000680;
unsigned char far *src = (unsigned char far*)0xb8000000;
unsigned char far *sch = (unsigned char far*)0x00400017;
int i,j;
char charsrc[4000];

void interrupt scrnsvr(){

//saving contents
    for(i=0; i < 4000; i++)
    charsrc[i] = *(src+i);
//Clearing Screen
    for(i=0; i < 4000; i+=2)
    {
        *(src + i) = 0x20;
        *(src + i + 1) = 0x07;
    }
}
//Prints RollNo and Name at Center of Graphics Text Memory
void charPrint(){
    *scr = 0x6D;
    *(scr+1) = 0x70;
    *(scr+2) = 0x63;
    *(scr+3) = 0x07;
    *(scr+4) = 0x31;
    *(scr+5) = 0x07;
    *(scr+6) = 0x34;
    *(scr+7) = 0x07;
    *(scr+8) = 0x30;
    *(scr+9) = 0x07;
    *(scr+10) = 0x34;
    *(scr+11) = 0x07;
    *(scr+12) = 0x30;
    *(scr+13) = 0x07;
    *(scr+14) = 0x32;
    *(scr+15) = 0x07;
    *(scr+16) = 0x32;
    *(scr+17) = 0x07;
    *(scr+18) = 0x39;
    *(scr+19) = 0x07;
    *(scr+20) = 0x37;
    *(scr+159) = 0x07;
    *(scr+160) = 0x53;
    *(scr+161) = 0x07;
    *(scr+162) = 0x61;
    *(scr+163) = 0x07;
    *(scr+164) = 0x6C;
    *(scr+165) = 0x07;
    *(scr+166) = 0x6D;
    *(scr+167) = 0x07;
    *(scr+168) = 0x61;
    *(scr+169) = 0x07;
    *(scr+170) = 0x6E;
    *(scr+171) = 0x07;
    *(scr+172) = 0x20;
    *(scr+173) = 0x07;
    *(scr+174) = 0x48;
    *(scr+175) = 0x07;
    *(scr+176) = 0x61;
    *(scr+177) = 0x07;
    *(scr+178) = 0x69;
    *(scr+179) = 0x07;
    *(scr+180) = 0x64;
    *(scr+181) = 0x07;
    *(scr+182) = 0x65;
    *(scr+183) = 0x07;
    *(scr+184) = 0x72;
}
void restore(){
    for(j=0; j < 4000; j++)
        *(src + j) = charsrc[j];
}
/*
void interrupt newkey(){
    *sch = 24;
    *(sch+1) = 34;
       geninterrupt(0x65);
       charPrint();
       (*oldkey)();
*/

void main(){
//Cls
//  oldkey = getvect(0x09);
//  setvect(0x09, newkey);

    old = getvect(0x65);
    setvect(0x65,scrnsvr);
    keep(0,1000);
//Function
    _AH = 0x09;
       if(_AL==0x1D && _AL==0x38 && _AL==0x20)
     {
      geninterrupt(0x65);
      charPrint();
     }
      else if(_AL==0x1D && _AL==0x38 && _AL==0x13)
    {
      restore();
     }
}
}



What I have tried:

I tried many times to put the scan code of Keyboard buttons in Ah but failed please correct me the code.

Please see my comment to the question, which is the major part of the answer. For BIOS interrupt, please see: INT 16H — Wikipedia, the free encyclopedia[^].

On this level, you can work at the level of keyboard scan codes.

As I already tried to explain in my comment, "generate interrupt" is absurd. This is not how things work. For some education, see also: Inversion of control — Wikipedia, the free encyclopedia[^].

—SA