This wiki is being migrated to http://www.github.com/z88dk/z88dk/wiki

User Tools

Site Tools


platform:cpm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

platform:cpm [2017/04/27 11:32] (current)
Line 1: Line 1:
 +======= CP/M Hints And Tools =======
 +
 +{{platform:cpm.jpg|}}
 +
 +
 +The CP/M platform is a surprisingly useful port when used in combination with [[http://www.seasip.demon.co.uk/Unix/Zxcc/|ZXCC]], the two together can easily test whether an algorithm works, or whether there's an issue in the compiled output code.
 +
 +ZXCC is trivial to extend, and you can easily permit access to serial ports, host system calls, advanced paging techniques etc testing out many areas of your code.
 +
 +===== Quick Start ======
 +
 +<code>
 +zcc +cpm -lm -o adventure.com adv_a.c
 +</code>
 +
 +Without specifying a ''-o'' option, a file called ''a.com'' is produced, this can be run with zxcc as follows:
 +
 +<code>
 +zxcc a.com
 +</code>
 +
 +
 +===== Library Support =====
 +
 +Besides the standard library routines, the **''bdos(int func,int arg)''** and the the **''bios(int func,int arg,int arg2)''** function calls allows direct access to the bios of the system.
 +
 +===== Optimization =====
 +
 +There are a couple of #pragma commands which might be used to cut down the size of the resultant executable:
 +
 +**#pragma output nostreams**      - No stdio disc files
 +
 +**#pragma output nofileio**       - No fileio at all
 +
 +**#pragma output noprotectmsdos** - strip the [[platform:cpm#program_boot_protection|MS-DOS protection header]]
 +
 +**#pragma output noredir**        - do not insert the file redirection option while parsing the command line arguments (useless if "nostreams" is set)
 +
 +**#pragma output nogfxglobals**   - No global variables for graphics (required to make the graphics library work on the TIKI-100)
 +
 +===== Hardware specific extensions =====
 +
 +Some hardware specific functions have been adapted to run on both native platorm and generic CP/M environment (the 'gfx' prefix is used for library modules including graphics extensions only).
 +
 +
 +      * **-laussie** ([[platform:aussie|Aussie Byte]])
 +      * **-lcpccpm** ([[platform:amstradcpc|Amstrad CPC]])
 +      * **-lc128cpm**, **-lgfx128**, **-lgfx128hr**, **-lgfx128hr480** ([[platform:c128|Commodore 128]])
 +      * **-leinstein** ([[platform:einstein|Tatung Einstein]])
 +      * **-lpx4** ([[platform:px4|Epson PX4 (HC-40)]])
 +      * **-lmicrobee** ([[platform:microbee|MicroBEE]])
 +      * **-lnbcpm** ([[platform:newbrain|Grundy NewBrain]])
 +      * **-ltiki100**, -startup=2 ([[platform:tiki100|Tiki-100 (formerly Kon-Tiki)]])
 +      * **-ltrs80cpm**, **-lgfxtrs80**, **-lgfxeg2000** ([[platform:trs80|Tandy Radio Shack 80 and clones]])
 +      * **-startup=3 -lzxcpm** ([[platform:zx|Sinclair ZX Spectrum]])
 +      * **-lgfxzcn** ([[platform:amstradnc|Amstrad NC-100/NC-200 480x64 graphics on ZCN]])
 +      * (untested) **-lgfxep**, **-lgfxephr** ([[platform:enterprise|Enterprise 64 / 128]])
 +      * (untested) **-lgfx9001**, **-lgfx9001krt** ([[platform:z9001|Robotron Z9001, KC85/1, KC87]])
 +
 +
 +NOTE: for [[platform:msx|MSXDOS]], use the specific target instructions.
 +
 +===== Program boot protection =====
 +
 +The code generated for CP/M based computers is protecting by default the MS-DOS environment.
 +
 +In a similar way we can extend the protection to the 8080 based systems (which would crash otherwise).
 +
 +"{z88dk}/lib/cpm_crt0.asm" needs to be modified as follows:
 +
 +
 + start:
 + IF !DEFINED_noprotectmsdos
 + defb $eb,$04 ;DOS protection... JMPS LABE
 + ex de,hl
 + jp ckz80-start+$100
 + defb $b4,$09 ;DOS protection... MOV AH,9
 + defb $ba
 + defw dosmessage ;DOS protection... MOV DX,OFFSET dosmessage
 + defb $cd,$21 ;DOS protection... INT 21h.
 + defb $cd,$20 ;DOS protection... INT 20h.
 +
 + dosmessage:
 + defm "This program is for a CP/M system."
 + defb 13,10,'$'
 +
 + ckz80:
 + ld a,$7F ; 01111111 into accumulator
 + inc a ; make it overflow ie. 10000000
 + jp pe,begin-start+$100 ; only 8080 resets for odd parity here
 + ld de,z80message ; output "Needs Z80" message
 + ld c,9
 + jp 5 ; BDOS
 +
 + z80message:
 + defm "Z80 CPU required."
 + defb 13,10,'$'
 +
 + begin:
 + ENDIF
 +
 +
 +===== CP/M related Links =====
 +
 +http://www.seasip.info/Cpm/index.html
 +
 +http://zxvgs.yarek.com/en-index.html   (ZXVGS is also natively supported)
 +
  
platform/cpm.txt ยท Last modified: 2017/04/27 11:32 (external edit)