; For unknown homebrew systems we may as well use the "cpm" machine model. ; This gives us 64K of memory to play with, and a simple serial port. ; We also use the "raw" option to tell Zeus not to plant the default EPROM data. ; ; If you click on "Assemble then Emulate" Zeus will assemble this source-code ; and then emulate it. zeusemulate "cpm","raw" ; Tell Zeus to use simple hardware with no EPROM ; Start from location zero org 0 ; Rewind back to the start ; Just a simple bit of example code Start di ; Prevent interrupts ld sp,#0 ; Put the stack at the top of memory ld hl,szHello ; Point at a string call PrintStr ; Print it (if we had any output ahardware) ; Now, just read the keyboard and echo the characters EchoLp call ReadTerminal ; Get a character call PrintTerminal ; Show it jr EchoLp ; Loop ; Print a string pointed to by HL PrintStr ld a,(hl) ; Get the next character or a ; Hit a zero? ret z ; Yes, return call PrintTerminal ; Print this character inc hl ; Skip it jr PrintStr ; Loop ; The string szHello db "Hello!",$0D,$0A,0 ; An example string ; Print to Zeus's emulation of a serial port PrintTerminal push af ; Save the character PA_WaitLp in a,(0) ; Is the TX clear? Bit 1 bit 1,a ; jr nz PA_WaitLp ; No, loop pop af ; Restore out (1),a ; Send it ret ; Done ; Wait for a serial character from our virtual UART ReadTerminal in a,(0) ; Is there one ready? Bit 0 bit 0,a ; jr z ReadTerminal ; No, loop in a,(1) ; Get it ret ; Done ; Now, the rest of this is examples demonstrating a few of Zeus's possible output file formats. StartAddr equ 0 ; Save starting from zero FileLength equ *-Start ; Up to here... ; First, a simple raw binary file output_bin "rawbinary.bin",StartAddr,FileLength ; A binary file ; And some basic text hex files output_hex "rawhex_0_1.bin",StartAddr,FileLength,0,1 ; one byte perline (useful for exporting to FPGA) output_hex "rawhex_4_1.bin",StartAddr,FileLength,4,1 ; one byte perline with address output_hex "rawhex_0_16.bin",StartAddr,FileLength,0,16 ; sixteen bytes per line output_hex "rawhex_4_16.bin",StartAddr,FileLength,4,16 ; sixteen bytes per line with address output_hex "rawhex_wide.bin",StartAddr,FileLength,0,$10000 ; All on one line ; Now in Intel Hex format output_intel "intel.hex",StartAddr,FileLength ; As Intel hex ; Now in Motorola SREC format output_srec "srec.hex",StartAddr,FileLength ; As Moptorola S-records ; Now as a text file with db statements for inclusion in an assembler source output_db "Z80_db.asm",StartAddr,FileLength ; As "db ....." ; Now as a C array in a pre-built header file output_c "Z80_Data.h","Z80_Data","u8Z80_DataFile","/* Anything you like here */",StartAddr,FileLength ; Now as a Pascal data array in a pre-built unit file (Normally you'd make the filename and unit name the same) output_unit "Z80_U1.src","Z80_Data","u8Z80_DataFile","// Anything you like here...",StartAddr,FileLength ; Zeus can also write strings and bytes directly to files. ; This can be useful for building batch files, etc. output_text "zeus.txt","Hello there from Zeus",$0D,$0A,"... again",$21,$0D,$0A ; In addition to these Zeus can also output various machine-specific file formats, sometimes with ; a *lot* of options... for example, Zeus can build tape-loaders for the ZX Spectrum that can load ; 128K files automatically, and scatter-load them in sections across the memory blocks. If you don't ; know what that means, count yourself lucky... ; For the ZX Spectrum Zeus can output *.szx, *.tap, *.tzx and *.z80 files. (See the games sources) ; For CP/M Zeus can write directly to files inside the emulated CP/M disk drives. (See "cpm_app.zip")