Moving text mode cursor not working

后端 未结 2 969
故里飘歌
故里飘歌 2021-01-16 13:35

I have been working on moving the text mode cursor in the operating system I am currently developing. I am having trouble getting it to show up at all. Here is the code that

相关标签:
2条回答
  • 2021-01-16 14:08

    Your outb function has port and value in the wrong places. Instead of:

    asm volatile ( "outb %0, %1" : : "a"(value), "Nd"(port) );
    

    Try:

    asm volatile ("outb %1, %0" : : "dN" (port), "a" (value));
    

    Hope it helps :)

    0 讨论(0)
  • 2021-01-16 14:24

    You select wrong VGA registers. You have to use 0x0F for low and 0x0E for high (you have 0x0A for both).

    Edit: In case your cursor is disabled, this is how to enable it:

    void enable_cursor() {
        outb(0x3D4, 0x0A);
        char curstart = inb(0x3D5) & 0x1F; // get cursor scanline start
    
        outb(0x3D4, 0x0A);
        outb(0x3D5, curstart | 0x20); // set enable bit
    }
    

    Also check this link for list of register numbers and usages.

    Edit2: Your cursor location variable is not wide enough to store the cursor location. unsigned char cursor_loc should be unsigned short cursor_loc.

    0 讨论(0)
提交回复
热议问题