Programming Index > TAP Code templates.
TAP code templates.
from Ricardo Lopes.
Used with your favourite text editor, TASM assembler, and EightOne we think these templates can simplify the development process. We recommend the Notepad++, ConTEXT and UltraEdit text editors.
The TASM assembler has an useful directive to calculate checksums '.CHK'. It gave me the idea of creating file templates to compile directly to TAP file format.
There are two template files:
'acedict.asm'   - Template to develop "Dict" type files to be LOADed.
'acebyte.asm'  - Template to develop "Byte" type files to be BLOADed.
There are also two include files:
'ace.inc'          - EQUates for system variables, ROM routines, macros, etc.
'aceforth.inc'  - EQUates of ROM FORTH words Code Fields. Useful when creating words using AceFORTH.
See here for the latest include files
These four file should be placed in the same directory as the TASM assember. In the TAP template zip is an example code which you can compile into a tap file with:-
TASM -80 -b -l example.asm example.tap
TAP file called example
This will result in a TAP file called example. Which can be loaded with LOAD example in the EightyOne emulator with the TAPE Manager.
new TAP file
In the above window shot you can see the new TAP file called example.tap, .inc files, .asm file and TASM files. Please note the icons might be different on your system. it depends if the file extensions have been associated the an application. In this case the TAP file is associated with a ZX Spectrum emulator which uses this type of icon for a TAP file.
Once loaded you will find two new WORDs in the Aces dictionary BELL and HEX.

BELL is a simple machine code word that just plays a short note. HEX is a listable (using VLIST) FORTH word that changes the numeric base to hexadecimal.
Click here to download the TAP templates.
Below is the listing for the example.asm code.
; example.asm
; Example on how to use acedict.asm template file.
; Defines two dictionary words:
;  BELL - ASM code to produce a beep from speaker
;  HEX  - FORTH code to set Hex mode. This word can be listed.

; 2009, January - The Jupiter Ace Archive Team -> www.jupiter-ace.co.uk

; Compile using TASM assembler:
;   TASM -80 -b -l example.asm example.tap

#define FILENAME  .TEXT  "example   "        ; <-- SET FILENAME HERE
;                        |----------| Keep it exactly 10 chars long!

#include "ace.inc"
#include "aceforth.inc"

STARTADR:  .EQU     $3C51                    ; Start address for dict files
           .ORG     STARTADR - 30            ; Make room for the file header
           .WORD    26                       ; TAP 1st chunck size
HEADERBLK: .BYTE    00                       ; File Type = dict
           FILENAME                          ; Filename (10 bytes)
           .WORD    DATABLKEND - DATABLK     ; File Lenght
           .WORD    STARTADR                 ; Start Address
           .WORD    HEXLNK                   ; current word link <--- SET LINK HERE
           .WORD    $3C4C                    ; CURRENT
           .WORD    $3C4C                    ; CONTEXT
           .WORD    $3C4F                    ; VOCLNK
           .WORD    DATABLKEND               ; STKBOT
           .CHK     HEADERBLK                ; Header Block CheckSum
           .WORD    DATABLKEND - DATABLK + 1 ; TAP 2nd chunck size
DATABLK:                                     ; Data Block Start


; DING -----------------------
; FORTH dictionary word header
BELLNAME: .BYTE  "BEL",'L' | INVERSE  ; Word Name (last letter inverse)
          .WORD  HEXLNK - BELLLNK     ; Word Lenght Field
          .WORD  $3C49                ; Link Field
BELLLNK:  .BYTE  $ - BELLNAME - 4     ; Name Lenght Field
          .WORD  $ + 2                ; Code Field Address
; --- BELL code ---
          DI                   ; Avoid interrupt during sound play
          LD     C,96          ; Number of cycles to play
BellLoop: LD     B,61          ; 1st Half cycle delay factor
          DJNZ   $             ; 1st Half cycle delay
          PullSpeaker          ; Pull in the speaker diaphragm
          LD     B,60          ; 2nd Half cycle delay factor
          DJNZ   $             ; 2nd Half cycle delay
          PushSpeaker          ; Push out the speaker diaphragm
          DEC    C             ; Count number of cycles
          JR     NZ,BellLoop   ; Loop back if not done
          EI                   ; Restore interrupt
          AsmEnd               ; End of word

; HEX ------------------------
; FORTH dictionary word header
HEXNAME:  .BYTE  "HE",'X' | INVERSE  ; Word Name (last letter inverse)
          .WORD  HEXEND - $          ; Word Lenght Field
          .WORD  BELLLNK             ; Link Field
HEXLNK:   .BYTE  $ - HEXNAME - 4     ; Name Lenght Field
          .WORD  CF_DOCOLON          ; Code Field Address
; --- HEX word ---
          .WORD  F_STK_WORD          ; Push 16 on data stack
          .WORD  16
          .WORD  F_BASE              ; BASE
          .WORD  F_CSTORE            ; C!
          .WORD  F_FORTHEND          ; End of word definition


DATABLKEND:  .CHK    DATABLK               ; Data Block Checksum

; Show code statistics when compiling
    .ECHO "Start Address: "
    .ECHO " , Lenght: "
   	.ECHO " bytes\n"