YJDoc2 / 8086-emulator-web

Repository for 8086 emulator web implementation
Apache License 2.0
222 stars 26 forks source link

Fix 0x21 0x0A "buffer overflow" #29

Closed FrancoisCapon closed 1 year ago

FrancoisCapon commented 1 year ago

Hello it's me again

While trying INTs available, I discovered a "buffer overflow" on the 0x21 0x0A:

buffer: DB 0x08 ; maximum characters buffer can hold DB 0X00 ; number of chars readed DW 0xFFFF ; padding DW 0xFFFF ; padding DW 0xFFFF ; padding DW 0xFFFF ; padding

DB 0x55 ; upper border

; 44 | 08 | 00 | ff | ff | ff | ff | ff | ff | ff | ff | 55

start: ; http://spike.scu.edu.au/~barry/interrupts.html ; DOS 0x21 0x0A ; Buffered Keyboard Input mov dx, OFFSET buffer mov ah, 0x0A int 0x21

; input 1234567890 ; expected ; 44 | 08 | 08 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 55 | 00 ; got ; 44 | 08 | 08 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 30


I think there is the same issue on the CLI version:

```rust
interrupts.rs
...
        // store the characters
        for (ctr, i) in input.bytes().enumerate() {
            vm.mem[start + 2 + ctr] = i;
        }