Coder Social home page Coder Social logo

adriancable / 8086tiny Goto Github PK

View Code? Open in Web Editor NEW
922.0 65.0 177.0 1.65 MB

Official repository for 8086tiny: a tiny PC emulator/virtual machine

Home Page: www.megalith.co.uk/8086tiny

License: MIT License

C 25.65% Assembly 71.15% CSS 3.06% Shell 0.14%

8086tiny's Introduction

8086tiny

8086tiny is a completely free (MIT License) open source PC XT-compatible emulator/virtual machine written in C. It is, we believe, the smallest of its kind (the fully-commented source is under 25K). Despite its size, 8086tiny provides a highly accurate 8086 CPU emulation, together with support for PC peripherals including XT-style keyboard, floppy/hard disk, clock, audio, and Hercules/CGA graphics. 8086tiny is powerful enough to run software like AutoCAD, Windows 3.0, and legacy PC games: the 8086tiny distribution includes Alley Cat, the author's favorite PC game of all time.

8086tiny is highly portable and runs on practically any little endian machine, from simple 32-bit MCUs upwards. 8086tiny has successfully been deployed on 32-bit/64-bit Intel machines (Windows, Mac OS X and Linux), Nexus 4/ARM (Android), iPad 3 and iPhone 5S (iOS), and Raspberry Pi (Linux).

The philosophy of 8086tiny is to keep the code base as small as possible, and through the open source license encourage individual developers to tune and extend it as per their specific requirements, adding support, for example, for more complex instruction sets (e.g. Pentium) or peripherals (e.g. mouse). Forking this repository is highly encouraged!

Any questions, comments or suggestions are very welcome in our forum at 8086tiny.freeforums.net.

8086tiny's People

Contributors

adriancable avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

8086tiny's Issues

Signed overflow in DIV_MACRO

Post macro-expansion, the code in

i_w ? DIV_MACRO(unsigned short, unsigned, regs16) : DIV_MACRO(unsigned char, unsigned short, regs8)
becomes

(scratch_int = *(unsigned short *)&mem[rm_addr]) &&
        !(scratch2_uint = (unsigned)(scratch_uint = (regs16[i_w + 1] << 16) + regs16[0]) / scratch_int,
          scratch2_uint - (unsigned short)scratch2_uint)
    ? regs16[i_w + 1] = scratch_uint - scratch_int * (*regs16 = scratch2_uint)

The type of scratch_int * (*regs16 = scratch2_uint) is int due to the LHS being an int and the RHS being an unsigned short. It is promoted to unsigned int before the subtraction. A counterexample generated by CBMC was -
scratch_int = 33793, scratch_uint = 2181038080, scratch2_uint (division result) = 64541. scratch_int * scratch2_uint = 2181034013 does not fit inside a 4-byte int.

Detected using Frama-C (eva) and CBMC while doing a project for the Software Verification and Analysis course under Prof @mksrivas at CMI

Linux ELKS issue

Hello, I'm trying to boot linux ELKS via 8086tiny but the boot stops like this:
ELKS.......................................................................................................................................................... ELKS Setup ....L0831C3AH00S0A t02D0 f0FC6 d12BA Direct console, scan kbd 80x25 emulating ANSI (3 virtual consoles)
At this point it just hangs.
Is there a way to get the boot log or something to figure out what has gone wrong?
Thanks in advance!

A Few Questions

Q1: In bios.asm, how can I save a value (number, string, etc.) such as the content of biosstr (string) in a memory area of the emulator, and then read and print that memory area from 8086tiny.c?

Q2: Same question as Q1 but in reverse, storing a variable in 8086tiny.c, and then reading and printing that value from bios.asm.

Q3: In FreeDOS kernel, how can I save a value (number, string, etc.) in a memory area of the emulator, and then read and print that memory area from 8086tiny.c or from bios.asm?

Q4: Same question as Q3 but in reverse, storing a variable in 8086tiny.c or bios.asm, and then reading and printing that value from FreeDOS kernel.

Q5: I have same question: https://8086tiny.freeforums.net/thread/82/starting-exe-files-command-line

Q6: I have same question: https://8086tiny.freeforums.net/thread/62/local-drive-access

regards,
Danny.

Unaligned access

The CAST macro is used to generate unaligned accesses. This breaks compatibility on architectures which don't support unaligned access, like ARM.

I'm looking into this issue and it seems that I would have to rewrite the CAST macro to be an inline function that uses byte loads.

LEA bug

I think your LEA implementation is wrong.

When I want to execute, for example, lea sp, ... the c variable op_from_addr is 0xf0008 which points inside mem to ES instead to SP. This is because you calculate

op_from_addr = REGS_BASE + i_reg * 2;

for your LEA implementation instead of just

op_from_addr = REGS_BASE + i_reg;

(without * 2).

fatal error: SDL.h: No such file or directory

What version the 8086tiny need? i have SDL2

When i run 'make' the output is this:

cc 8086tiny.c sdl-config --cflags --libs -O3 -fsigned-char -std=c99 -o 8086tiny
/bin/sh: 1: sdl-config: not found
8086tiny.c:18:10: fatal error: SDL.h: No such file or directory
_ 18 | #include "SDL.h"
___ | ^~~~~~~
compilation terminated.
make: *** [Makefile:16: 8086tiny] Error 1

Setting AL in extended_read_disk is senseless?

Look at this block in the bios:

mov	ah, 0
cpu	186
shl	ax, 9
extended_read_disk
shr	ax, 9
cpu	8086
mov	ah, 0x02	; Put read code back

cmp	al, 0
je	rd_error

The extended_read_disk instruction writes the error to AL. But right after the read we shift AX back 9 bits to right (shr ax, 9) which overrides AL. So what's even the point of cmp al, 0 and setting AL in extended_read_disk?

And even when you fix the bios, the read function in 8086tiny.c is still wrong. You use AX as length to read. But read() returns, for example 512, which is 0 inside AL because of the overflow. So even if we don't shift bits after the read AL indicates "error".

emscripten

have a freelancer working on this port currently.

emcc 8086tiny.c -DNO_GRAPHICS -o 8086tiny.html -fsigned-char -O1 --embed-file bios --embed-file fd.img

node 8086tiny.js bios fd.img

keyboard , sound and graphics not working.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.