• @[email protected]
    link
    fedilink
    213
    edit-2
    28 days ago

    This is x86 assembler. (Actually, looking at the register names, it’s probably x86_64. On old school x86, they were named something like al, ah (8 bit), ax (16 bit), or eax (32 bit).) Back in the old days, when you pressed a key on the keyboard, the keyboard controller would generate a hardware interrupt, which, unless masked, would immediately make the CPU jump to a registered interrupt handler, interrupting whatever else it was doing at the point. That interrupt handler would then usually save all registers on the stack, communicate with the keyboard controller to figure out what exactly happened, react to that, restore the old registers again and then jump back to where the CPU was before.

    In modern times, USB keyboards are periodically actively polled instead.

    • @[email protected]
      link
      fedilink
      English
      9
      edit-2
      28 days ago

      You’re right, but rax is amd64.

      I think there were a few early amd64 systems with genuine ps2, and I think you can still get one, but it wasn’t common, and honestly it’s probably usb->ps/2.

      To be a pedantic asshole: mov eax, ecx? Unless you’re commenting on the insanity of interrupt driven i/O in the modern age of high performance, deep-pipelined superscalar OOO cores.

    • @[email protected]
      link
      fedilink
      88
      edit-2
      28 days ago

      The virgin USB: hey, uh, when you get a chance, uh, if it’s not too much trouble, could you, uh, put an ‘e’ there? Whenever you get the chance is fine

      The chad PS/2: THE USER SAID E.

    • @[email protected]
      link
      fedilink
      7
      edit-2
      28 days ago

      Thanks for the explanation. Ironically this was the bit I didn’t know:

      In modern times, USB keyboards are periodically actively polled instead.

      I was thinking the implication was that some computer had faulty interrupt handling that would smash the status register or something.

      Honestly I think I’m just too old to understand memes.

    • @[email protected]
      link
      fedilink
      English
      3128 days ago

      does that mean though that if I connect a PS/2 keyboard or mouse to my relatively modern computer (a “gamer” motherboard made ~6 years ago) 's PS/2 port, that it’ll still trigger such an interrupt?

      • @[email protected]
        link
        fedilink
        627 days ago

        My guess would be yes, the whole point of including a legacy port like this would be compatibility. Laptops used (still use?) PS/2 long after desktops moved to USB keyboards because the lack of polling meant improved battery life, so it’d make sense for the hardware support to still be there.

      • @[email protected]
        link
        fedilink
        English
        1528 days ago

        I think there’s a USB device inside the mobo to handle dumb peripherals. So it would still trigger an interrupt, but it wouldn’t make it to the CPU. The USB keyboard controller would handle it and cache the strokes locally until polled by the CPU.

        • @[email protected]
          link
          fedilink
          1028 days ago

          I would expect that any motherboard that went to the trouble of including a PS/2 port would handle it with a real hardware interrupt, because the whole point of still having those things is to avoid the latency overhead of USB.

            • @[email protected]
              link
              fedilink
              2
              edit-2
              28 days ago

              But honestly, 1000 Hz polling is just for bigger numbers game. Even 300 ms are barely noticeable by humans, not to mention 10 ms of 100 Hz.

          • Pup Biru
            link
            fedilink
            English
            3
            edit-2
            28 days ago

            there are loads of things in the gamer space that are just branding BS… i could definitely see dodgy (or honestly even reputable) motherboard manufacturers adding PS/2 ports that are just basically a USB dongle built into the board and adding $40 for the dubious privilege

      • @[email protected]
        link
        fedilink
        English
        3128 days ago

        The other commenter is on the right track but the chip controls both USB and PS/2 as well as others;

        In the 90s and 2000s, for x86 machines, slower I/O was handled by a chip called the Southbridge which worked in conjunction with a chip called the Northbridge that handled faster I/O like IDE and PCI. Later these were integrated into a single chip and, as of recent processor generations, into the processor itself.

        AFAIK ghosting and key rollover are issues when using PS/2 but it can offer some milliseconds off latency when used in high cpu games.

        • @[email protected]
          link
          fedilink
          10
          edit-2
          28 days ago

          AFAIK ghosting and key rollover are issues when using PS/2

          I think it’s more of an issue for USB keyboards than PS/2 keyboards.

          • @[email protected]
            link
            fedilink
            1828 days ago

            They are wholly independent from the protocol or interface. Ghosting is an electrical issue that is a result of keyboards being a bunch of switches arranged in a matrix. It makes the keyboard’s controller register an extra keypress in certain conditions. Nothing to do with how the thing communicates with the host computer.

            Key rollover issues can be related to ghosting. The limit for it is once again the keyboard’s design at the circuit level, not its communication protocol.

            Really they’re both related to how cheaply built the keyboard is. That’s the only thing.

      • @[email protected]
        link
        fedilink
        English
        1428 days ago

        Oh, you’re right! I completely forgot that was a thing. But I do remember the “keyboard not found, press f1” message.

    • @[email protected]
      link
      fedilink
      1228 days ago

      I had to write a mini os and it handled keyboard interrupts. Certainly made it make a lot more since after writing it for my uni course