Close

My CP/M Simulator

A project log for My CP/M Single Board Computer

A simple computer based on the CP/M OS and flash chips for disk drives

agp.cooperagp.cooper 10/14/2019 at 05:122 Comments

My CP/M Simulator

8080 Emulator Code

Downloaded a public domain 8080 emu from https://www.reddit.com/r/C_Programming/comments/8loz4p/heres_a_cycleaccurate_intel_8080_emulator_i_wrote/

The arrangement of the code suits what I need. It counts cycles so I can make the emulator run in real time.

I have to add the code for TRAP/RST7.5/RST65./RST5.5, SIM/RIM and SID/SOD.

Non-blocking getchar()

Next I found some code for getch() and getche() which will work under linux (conin.h is a windows only library).

Serial Input/Output

I have coded the Serial Input but Serial Output need a bit of thought.

HEX Import

Just finished write an I8HEX import routine.

New 8080 Emulator

I has swapped the 8080 emulator to https://github.com/superzazu/8080.

The reason is that is emulator has a test suite to demonstrate the "correctness" of the emulator. The previous emulator code does have some minor coding errors.

I have made some cosmetic changes to the new emulator to remove the compiler warnings, and started coded the missing 8085 hardware and instructions.

Not that it is really important, I note that the "superzazu" interrupt code, only allows for a single byte interrupt opcode. A real 8080 can handle one, two and three byte interrupt opcodes.

I also simplified the function in a structure method.

Uploaded the initial test code to my file area.

Update

Tested the i8080 part of the emulator with "myBoot.HEX" and it works fine. One error in myBoot.asm (I incorrectly swapped the source and destination registers).

Just the serial out code to do.

Update 2

As pointed out by Ken Yap the multi-OpCode Interrupt issue is an 8085 "undocumented" feature.

Got the echo code working this morning. Many assembler coding errors (I don't know 8085 assemble code very well yet), and a baud timing calculation error. I did not allow for some overheads.

I really need to upgrade"superzazu"'s debug code. Otherwise the 8085 instruction I have added (i.e. SIM, RIM and interrupts TRAP, RST7.5, RST6.5 and RST5.5 seem to work, at least SIM, RIM and RST6.5 which I use.

I think the way forward is to write assembler for a boot disk with only the boot sector and bios (i.e. less ccp and fdos), and test my bios functions. The jump to ccp will be my test program.

In any case my "sight" understanding of the 8085 OpCodes is getting better.

Alan

Discussions

agp.cooper wrote 10/16/2019 at 09:45 point

Hi Ken,

Yes, I went back to review the page where I picked it up and the Intel 8080/8085 manual. And I realised that it had to be an 8080 versus 8085 issue. The Intel 8080/8085 manual states one byte opcodes without qualification.

I am currently getting my serial echo code working on the CP/M simulator. Hopefully by tomorrow. If I can get that working then I am going to claim the CP/M simulator is 50% complete! It is tricky because there could be errors in the assembler code, the simulator code, or the 8085 emulator code that I added.

I don't know about you but I am rather impressed by CP/M's capability given the size of the code (~6.5kb). Plus my favourite programming language of all time (TurboPascal V3) is available for CP/M!

AlanX

  Are you sure? yes | no

Ken Yap wrote 10/16/2019 at 05:41 point

Those extra instructions only exist on the 8085. CP/M stuck to 8080 subset, not even using the Z80 superset, for the sake of compatibility. Some application programs did come in Z80 versions for speed.

  Are you sure? yes | no