Skip to content

Is there a way to read and write X86 ports? #1184

Answered by chschnell
parkertomatoes asked this question in Q&A
Discussion options

You must be logged in to vote

Something like this should work:

YourApplication.Prototype.start_v86 = function()
{
    this.vm = new V86({ ... });

    // Example: Fictional I/O port 0x28
    let port_0x28 = undefined;

    this.vm.bus.register('emulator-started', () => {
        if(port_0x28 === undefined) {      // make sure to register our 0x28 I/O handler only once
            const io = this.vm.v86.cpu.io; // instance of class IO
            port_0x28 = 0;                 // set initial port value

            io.register_read(0x28, this, function() {
                // handle read-access (inp) to port 0x28
                console.log(`inp 0x28: ${port_0x28}`);
                return port_0x28;
            });

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@parkertomatoes
Comment options

Answer selected by parkertomatoes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants