What is Memory Mapped I/O? (16-Bit VM in JavaScript 005)

Sdílet
Vložit
  • čas přidán 22. 07. 2024
  • This this episode we implement memory mapped I/O, where the address space is utilised as common bus for components to communicate.
    =[ ℹ About ℹ ]=
    This series is all about building a powerful virtual machine in JavaScript with the following features:
    - A flexible, extensible, register-based virtual machine
    - Support for signed, unsigned and floating point operations
    - A call stack
    - Interrupt capabilities
    - Ability to do memory mapping for IO
    - An assembly language with macro and module support
    - A higher level, C like language. We'll use and expand the library from the parser combinators from scratch series
    - And finally, to be able to take the whole thing into the browser and exend it to create a sort of fantasy console - an emulator for a machine that never existed
    =[ 🔗 Links 🔗 ]=
    - ⭐️ Patreon: / lowleveljavascript
    - 💌 Updates to your inbox: tinyletter.com/lowleveljavasc...
    - Series Playlist: • 16-Bit Virtual Machine
    - Github Repo: github.com/LowLevelJavaScript...
    - Memory Mapped IO: en.wikipedia.org/wiki/Memory-...
    - Address Space: en.wikipedia.org/wiki/Address...

Komentáře • 33

  • @garrettbates2639
    @garrettbates2639 Před 6 měsíci +2

    A few years ago i was working on a toy PS1 emulator. I had to stop working on it after a while because it got to be too much to come home from working as a software engineer, to work on software engineering projects. It just made me start to hate my hobby that I've loved since i was a teen.
    Anyhow, I just stumbled on this playlist earlier this year and finally sat down to watch it tonight, and I'm really happy to see that my approach to handling devices and memory mapping wasn't completely insane.
    Granted, I was writing my VM in C11, so maybe it was still a little insane. But still, I feel slightly vindicated.
    Awesome work, and thanks for sharing.

  • @eebilu
    @eebilu Před 4 lety +12

    I'm taking a senior class where we are implementing a VM and I chose javascript (node) as my language. This series has helped me get my head around where to start, keep it up!

  • @mladjo2505
    @mladjo2505 Před 4 lety +8

    Love it, can't wait for the ASM to be done so we can get on with writing a game

  • @theitatit
    @theitatit Před 4 lety +8

    Love your content!

  • @giuxbr222
    @giuxbr222 Před 2 lety +1

    I was having so much trouble understanding what was actually going on with the code... Especially for debugging. Now I ended up using VSCode's debugger and it helped me tremendously. Great videos! thanks a lot for them

    • @LowByteProductions
      @LowByteProductions  Před 2 lety

      You're welcome, and I'm glad the debugger served you well! I can't live without it these days

  • @nikolaiarsenov1595
    @nikolaiarsenov1595 Před 2 lety

    Great stuff!!!

  • @EvilFlipTV
    @EvilFlipTV Před rokem

    Huh, this will take me some time to process this video and I think after finishing VM I'll re-watch all videos from first to make sure that I really got the idea behind it. Also, idea of visualization looks so handy, that I think I'll try to do it on my own

  • @meekmtck5917
    @meekmtck5917 Před 3 lety

    dude... your channel is really flippin' cool. you mentoring anyone?

  • @frankeke8541
    @frankeke8541 Před 4 lety +2

    Ok, why i didn't discover this channel earlier ?

  • @HarshitBujarBaruah
    @HarshitBujarBaruah Před 3 lety

    Cool

  • @8-P
    @8-P Před 4 lety +4

    How would multithreading be implemented in the vm? Just by starting up a new Cpu class instance?
    Looking forward to the next episodes :)

    • @LowByteProductions
      @LowByteProductions  Před 4 lety +3

      That's a tricky one - and to be honest I don't think it will ever be a goal of this VM because that would add a lot of complexity.
      You could indeed set up two CPU classes, implement some synchronization mechanisms, and add communication through memory mapping, but I wouldn't really call that multithreading. I think that would be more like a coprocessor setup. There is also the concept of cooperative multitasking - which can be implemented in various ways, but I would consider that more of a software concept than a hardware concept.

    • @8-P
      @8-P Před 4 lety +2

      @@LowByteProductions Thank you very much for your reply :-) I am still learning and your Series is the first one on register based VMs so far (on YT). I googled before on the actual difference between stack based and register based VMs, and now I think I finally got it, thanks to your videos! I guess I was confused as 'a stack' is used in both.
      I have a few questions, but I guess I just watch the playlist again and ask on the actual video :)

  • @hecatonecles4334
    @hecatonecles4334 Před 4 lety +1

    nice series i like it. :)
    but a question, in your createScreenDevice class the methode setUint16 uses modular and div for the x and y coordinates. is it not a bit inefficient, i think for a 16x16 screen an and and a bit shifting is a bether idea. like so ''' int x = (addr & 0xf0) >> 8; int y = (addr & 0x0f); . what do you think about it? idk to much about java but for me its a bit clearer to understand what it makes and i think it is a bit faster.

    • @LowByteProductions
      @LowByteProductions  Před 4 lety +1

      Thanks! That could also work - though I'm not sure about performance. It's always best to actually measure first. In this case I don't think it would have too significant an effect. The best would just be to build a lookup table, which would be O(1) and cost a little memory.

  • @carnivionhan6825
    @carnivionhan6825 Před rokem

    Great contents! But one question, while migrate to MM, the setUint8 method -- which is overridden by screen device -- updates the view only, how is the data written back to memory? Thank you again!

    • @LowByteProductions
      @LowByteProductions  Před rokem +1

      Thats the trick here - there is no actual memory backing this address! It only exists as a control interface to an "external device".
      A close analogy is the idea of "everything is a file" in Unix terms. Some things are real files that exist on a hard disk, and some things appear as files, but actually represent something else in the system. For example, /dev/urandom is a file-like thing you can read from, but the data you get isn't stored somewhere.

  • @frankeke8541
    @frankeke8541 Před 4 lety

    Are you alive ? Can't wait for the next episode

    • @LowByteProductions
      @LowByteProductions  Před 4 lety

      I am! I'm on a long planned travelling sabbatical for a couple of months - hence the absence of new videos. There is a video coming out next week however!

    • @frankeke8541
      @frankeke8541 Před 4 lety

      @@LowByteProductions great!

  • @jordixboy
    @jordixboy Před rokem +1

    the memory mapper is in charge of communicating with different devices like gpu, keyboard, mouse, hard drive... right? In case of a hard drive, how would that work? imagine you have a 1gb ram, and your hard drive is 100gb, how would you be able to map 100gb addresses into the 1gb ram?

  • @ErikShestopal
    @ErikShestopal Před 4 lety +1

    Would it be possible to bump up the code font size for better readability? Love your content!

    • @LowByteProductions
      @LowByteProductions  Před 4 lety +1

      I'll look into it! I'm trying to find the balance between having enough context on screen against making sure everything is very visible.
      Can I ask what kind of device you're watching on? That way I can do some experimentation.

    • @8-P
      @8-P Před 4 lety

      @@LowByteProductions Love your content! I am watching on my phone and code along on a laptop. Your slides and animation font size is perfect, but the code when doing side by side windows on a laptop is too small for me, i have to resize the YT video quite a bit

  • @tomster12
    @tomster12 Před 4 lety

    There's no link to escape codes in the description as you mentioned around 10:30

    • @LowByteProductions
      @LowByteProductions  Před 4 lety

      Thanks for the heads up - fixed! Here's the link anyway: github.com/75lb/ansi-escape-sequences/blob/master/index.mjs

  • @devhonking721
    @devhonking721 Před 4 lety +1

    Someone tried this in Java, i don't understand this episode.

    • @LowByteProductions
      @LowByteProductions  Před 4 lety +2

      The machine is 16 bits, which means if it were a real computer, there would be a few different groups of 16 wires going from the CPU to the RAM - one group to carry addresses and one group to carry values. You need 16 wires to represent the 16 bits of the numbers (1 or 0, electrical high or electrical low).
      So you could imagine putting a chip between the CPU and the RAM - which could take the 16 wires that make up and address, and saying that if certain wires are set, instead of sending the output of those wires to the RAM, it instead sent them to some other device, like a screen, or a graphics card, or an audio interface - or any other piece of hardware you could think of! Those devices would also have groups of 16 wires for addresses and values, meaning they could communicate things back into memory, or to other pieces of hardware.
      The idea is the "address bus" can be used to communicate with more than just RAM. It makes sense if you think about it - addresses in the real world can be houses, but they can also be golf courses, restaurants, airports, whatever.

    • @devhonking721
      @devhonking721 Před 4 lety +1

      Ok, thanks !