@DATABASE "EMPIC"
@AUTHOR "Bohdan Rau"
@(C) "1997"
@$VER: EMPICGuide V1.3b

@NODE MAIN "EMPIC Manual"

                                 @{b}EMPIC@{ub}
                               Version 1.3b

                      PIC 16C84/16F84 Programming System
                           for Amiga computers

                      © Copyright 1997 Bohdan Rau

                              04.04.1997



 @{" Introduction            " LINK Intro}  Some informations before you start
 @{" Overview                " LINK Overview}  What is EMPIC?
 @{" Installation            " LINK Installation}  How to install EMPIC
 @{" Requirements            " LINK Requirements}  System Requirement
 @{" Buttons                 " LINK Buttons} 
 @{" Assembler               " LINK Assembler}  EMASM Assembler
 @{" Disassembler            " LINK Disassembler}  EMPIC builtin disassembler
 @{" Editor                  " LINK Editor}  External editor
 @{" Programmer              " LINK Programmer}  EMPIC Programmer
 @{" Hardware                " LINK Hardware}  How to make hardware
 @{" Demo                    " LINK Demo}  My first program
 @{" Registration            " LINK Registration}  What for?
 @{" Copyright               " LINK Copyright}  Distribution
 @{" Bug reports             " LINK BugReports}  What bugs?
 @{" Credits                 " LINK Thanks}  The author wishes to thank...
 @{" The author              " LINK Author}  Author's address
 @{" Disclaimer              " LINK Disclaimer}  You should read it
 @{" Future                  " LINK Future}  What you should expect?

@ENDNODE
@NODE Intro "Introduction"

There is next release of EMPIC. Some features as added,
some bugs are fixed.

There is not only PIC assembler for Amiga. But I hope EMPIC
will be the best (in future, of course :-)

In some places I can read:
"There is my new programmer (or disassembler, or simulator etc...),
if you send me (three digits in DM) I will send you the assembler
when I will make it (in indefinite far future)".

OK.

Let them make it.

And now there is EMPIC!

*************************************************************************

                   And please forgive me my not quite good English,
                   but I think my English is better your Polish...	   

*************************************************************************

    I know this guide is not the best (in fact it is one of
    worst documents I saw) but I prefer to write two thousands
    lines of source code than two lines of guide...

@ENDNODE
@NODE Overview "Overview"

EMPIC contains two programs:


1) Assembler (EMASM)

    EMASM is a translator from source asm text into hex INHX8M code
    or into programmer memory.

2) Programmer (EMPIC)

    EMPIC allows the user to:
        Load hex files from disk;
	Load EMPIC IFF files from disk;
        Read value of PIC memory;
        Save hex files to disk;
	Write PIC memory;
	Disassemble and save memory as source asm file.

Both programs uses popular INHX8M hex format of disk files

@ENDNODE


@NODE Installation "Installation"


Copy EMASM file into your c: directory
Copy EMPIC and EMPIC.info files into any directory
on your harddisk



@ENDNODE
@NODE Requirements "Requirements"

EMASM requires DOS 2.0+.
EMPIC requires MUI version 3.6+
Both programs requires an Amiga...


@ENDNODE
@NODE Buttons "Buttons"
There are three panels:

- Programmer panel

Group "Fuses":

    Fuse configuration. Fuses are automatically set when loading
    IFF MPIC file or INHX8M file with fuse addressed.

Gadget "Oscillator"

    Oscillator type. It is automatically set when loading
    IFF MPIC file or INHX8M file with fuse addressed.

Gadget "Device"

    Device type. The 16C84 and 16F84 devices has the power-up timer
    bit reversed! It may be important.

Line "Program":

    Load      - Load INHX8M program file or IFF MPIC file from disk
    Save      - Write INHX8M program file to disk
    Read      - Read program from PIC
    Write     - Write program to PIC (configuration and data
                are cleared)
    Verify    - Verify program in PIC

Line "Data":

    Load      - Load INHX8M data file from disk
    Save      - Write INHX8M data file to disk
    Read      - Read data from PIC
    Write     - Write data to PIC
    Verify    - Verify data in PIC

Line "Config:"

    Write     - Write configuration (fuses and oscillator
                type) to PIC. You @{b}must@{ub} use this button
                when "write program" was used! In other case
                the watchdog timer will be still enabled and
                your program will restart periodically...
    Write all - Clear all PIC data, write program, data (if loaded)
                and configuration to PIC

Speed         - set programming speed (delay in msec). You
                may experiment with different values.
 
- Assembler panel:

    File             - set name of source file
    Assembly         - invoke @{"Assembler" link Assembler}
    Edit             - invoke @{"Editor" link Editor"}
    Clear            - clear error list
    Save as #?.mpic  - saves generated code as IFF MPIC file

- Disasembler panel:

Line "Edit":

    Label     - Create/delete label of current line.
    Operand   - Create/delete label used in operand field.
    Bit       - Create/delete label used in bit field.

Line "Find"

    Label     - find labelled line
    Label ref - find goto/call instruction with specified operand
    Variable  - find line with specified register operand
    Literal   - find line with specified literal operand
    Bit       - find line with specified literal in bit field

Lower line:

    Save as #?.mpic - saves code as IFF MPIC file. All names are
                      also saved
    Save as MPASM   - if you have poor friend with little Pentium
                      you should use this option
    Save as #?.asm  - saves disassembled text as assembler source.


@ENDNODE
@NODE Assembler "Assembler"


Assembler must be invoked from CLI with single parameter
(*.asm file name). Default extension is .asm
Assembler produces files from name.asm:

    name.lst      - list file
    name.err      - error file
    name.hex      - program in INHX8M format
    name.data.hex - program in INHX8M format

    #commands           @{"Commands    " LINK AsmCommands}
    Declarations        @{"Declarations" LINK AsmDeclarations}
    Predeclared values  @{"Predeclared " LINK AsmPredeclared}
    Options file        @{"Options     " LINK AsmOptions}
    Error numbers       @{"Errors      " LINK AsmErrors}
    Expressions         @{"Expressions " LINK AsmExpressions}

Assembler may be also invoked from EMPIC by pressing
"Assembly" button on Assembler panel of EMPIC. When invoked
from EMPIC output code is placed directly into EMPIC
buffers, output files are not produced.

@ENDNODE
@NODE AsmExpressions "Assembler expressions"

Expresion in operand may be constructed using simple
constans and any combination of operators and parenthesis.

Operators are:

   << - shift left
   >> - shift right
   &  - bit and
   |  - bit or
   ^  - bit exclusive or
   *  - multiply
   /  - divide
   %  - quotient
   +  - add
   -  - subtract.

Constans are:

    h'ABCD' - hexadecimal digit
    0xABCD  - hexadecimal digit
    .9999   - decimal digit
    9999    - decimal digit
    name    - value of label
    "c"     - character (for future compatibility only, do not use at now)
     *      - address of this instruction


Examples:
	movlw  (alfa&beta)<<2
	movf   gamma+3
@ENDNODE

@NODE AsmCommands "# Commands"


EMASM Assembler commands:

#include "filename" - you should know what it means...
#define name text   - defines 'name'.
    In every cases when 'name' will be in mnemonic field,
    the operand field will be ignored and text will be
    treated as the rest of line.

Example:

#define OUTBIT bsf  PORTA,0

Line:
	OUTBIT
will be treated as
	bsf PORTA,0

#ifdef/#ifndef/#else/#endif

You really don't know?

#macro/#endm

Command allows the user to create macrocommand.

Example:

#macro	bne
        btfss   STATUS,Z
        goto    \1
#endm
#macro	xcall
        bne     !1
        call    \1
	boto    !2
!1	call    \2
!2
#endm

Macro calls may me nested.
Maximum number of macro parameters is 8
Local labels are possible
@ENDNODE
@NODE AsmDeclarations "Declarations"

Assembler declarations:

dfb
    - declares bytes in data EEPROM

Example:	
Digits   dfb    0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37



ee2
   - declares workspace in data EEPROM

Example:
Space   ee2    5

ram
   - declares workspace in RAM

Example:

wordctl  ram   2 ; allocates 2 bytes
variable ram   1 ; allocates 1 byte

equ
   - declares constans

Example:
ControlBit  equ 3

org
   - declares base address for assembling.

Multiple org declarations are possible.

device
   - declares processor type.

Examples:

        device 16C84
        device 16f84

'device' declaration also defines name 16C84 or 16F84
for checking with #ifdef/#ifndef.

fuse
   - declares fuse configuration.
Possible values are:
   pwrte_on     - power-up timer enabled
   pwrte_off    - power-up timer disabled
   wdt_on       - watchdog timer enabled
   wdt_off      - watchdog timer disabled
   cp_on        - code protection
   cp_off       - no code protection

Example:
   fuse cp_on pwrte_on wdt_off

osc
   - declares oscillator type.
Possible values are:

   hx - high speed crystal
   lp - low power crystal
   xt - standard crystal
   rc - RC circuit

Example:
        osc rc

end
   - marks end of current file
@ENDNODE
@NODE AsmPredeclared "Predeclared"

Some values in assembler are predeclared - you shouldn't use
special include files containing processor specific names.
There are:


INDF         equ   0
TMR0         equ   1
PCL          equ   2
STATUS       equ   3
FSR          equ   4
PORTA        equ   5
PORTB        equ   6
EEDATA       equ   8
EEADR        equ   9
PCLATH       equ   10
INTCON       equ   11
OPTION_REG   equ   0x81
TRISA        equ   0x85
TRISB        equ   0x86
EECON1       equ   0x88
EECON2       equ   0x89
IRP          equ   7
RP1          equ   6
RP0          equ   5
NOT_TO       equ   4
NOT_PD       equ   3
Z            equ   2
DC           equ   1
C            equ   0
GIE          equ   7
IEIE         equ   6
T0IE         equ   5
INTE         equ   4
RBIE         equ   3
T0IF         equ   2
INTF         equ   1
RBIF         equ   0
NOT_RBPU     equ   7
INTEDG       equ   6
T0CS         equ   5
T0SE         equ   4
PSA          equ   3
PS2          equ   2
PS1          equ   1
PS0          equ   0
EEIF         equ   4
WRERR        equ   3
WREN         equ   2
WR           equ   1
RD           equ   0
@ENDNODE
@NODE AsmOptions "Options"

Calling from EMPIC:

Assembler options are set using "Option" button
on assembler panel.

Calling from CLI:

Assembler options are stored in MpaOptions file.
File may contain lines:

LIST               produce *.lst file
NOLIST             do not produce *.lst file
ERRORFILE          produce *.err file
NOERRORFILE        do not produce *.err file
ERRORCONSOLE       print errors to stdout
NOERRORCONSOLE     do not pront errors to stdout
VERBOSE            print program title line
NOVERBOSE          do not print program title line
SUPPRESS <nr>      do not display message nr <nr>
ERRORREXX          send error messages to SAS scmsg browser
NOERRORREXX        do not send error messages to scmsg

Actually only 24 and 25 messages may be suppressed.

Example of options file (author's file)

NOLIST
ERRORREXX
ERRORCONSOLE
NOERRORFILE
SUPPRESS 24

@ENDNODE
@NODE AsmErrors "Errors"

Assembler Error messages:

 0: Illegal character
 1: Illegal # directive
 2: Redefined symbol
 3: Symbol name %s too long
 4: Division by zero
 5: Character expected
 6: String not terminated
 7: Extra character in string
 8: Extra characters
 9: Label not found
10: Duplicated label
11: Statement must have label   
12: Statement must not have label
13: Illegal instruction name
14: File not found
15: Internal error
16: Macros nested
17: Redefined macro
18: #ENDM not found
19: Extra operand,
20: Value out of address range
21: Value out of byte range
22: Value out of bit range
23: Value out of range
24: Register in operand not in bank
25: This instruction is not recommended to use
26: Unimplemented memory area
27: Out of RAM space
28: Out of EEPROM space
29: 'END' found in macro body
30: Out of program memory
31: Program memory overlap
32: Missing operand
33: File write error
34: Processor type already set
35: Unknown processor type
36: #endif not found
37: Redeclared fuses
38: Redeclared oscillator type
39: Unknown oscillator type
40: Unknown fuse type

When called from EMPIC, all error messages are sent
to EMPIC ARexx port and displayed on listview on
assembler panel. Doubleclick on error message
invokes @{"editor" link Editor}.

@ENDNODE
@NODE Disassembler "Disassembler"

Disassembler allows you to analyze some programs got from
PICs or from hex file distribution.

I hope all disassembler functions are self-explanatory.

@ENDNODE
@NODE Editor "Editor"
You must use external editor for source files.
If you use CED, copy "fixle.ced" file into your
REXX:CED directory. For other editors you must
configure some lines using "Presets/Editor" menu.

Line "ARexx port name" - name of editor's ARexx port
Line "Editor command"  - editor invocation line. %s will be
                         replaced by file name
Line "Goto file"       - skip to file command (usually ARexx program)
Line "Goto line"       - skip to specified line

@ENDNODE
@NODE Programmer "Programmer"


All EMASM functions should be self-explanatory.
If you don't understand something, you should not
use this program!

One exception:

Writing to PIC you should write the program at first. Writing
program memory erases both data and configuration.


Writing to PIC is asynchronous. During all PIC operations
(read, write, verify) all floppy drives are locked, so
you should wait for drive motors to stop before writing
to PIC.

@ENDNODE
@NODE Hardware "Hardware"

Biggest problem with other programmers was locking the parallel port.
EMPIC is connected only to external floppy port, so you can use printer,
sampler or other hardware without conflicts with EMPIC.
Only if you have floppy drive DF3 (I don't think so), you must disconnect
it, because EMPIC uses registers of disk 3.

Schematic diagram of EMPIC hardware (by Lars Malmborg) is included in file
Schematic.iff. There is no PCB project (If you really want to write
programs for PICs, you can make PCB as you want), and project
of interface is only suggestion (of course this suggestion works!)

EMPIC uses floppy signals as described below:

   ~SEL3  -   PIC program mode
   ~MOTOR -   PIC reset
   STEP   -   PIC programming clock
   SIDE   -   data output to PIC
   WPROT  -   data input from PIC.

Parts used in EMPIC programmer:

a) IC 74LS07   x 1
b) IC 74LS125  x 1
c) Transistor (any p-n-p, I used BC313, but only because it was first
transistor I found in my drawer) x 1
d) Resistors 1k x 8
e) Resistor 330 ohm x 1 
f) Resistor 4k7 x 1
g) Diode (any)  x 1
h) LED x 1

Two gates of LS07 are unused, so you may connect two extra LEDs
(for example to control DATA and CLOCK lines).

If you have more experience with electronics, you can create
you own better project. If you want to, remember:

a) During READ cycle data pin is on high level. It makes possibility
   to use simple open-collector gate for writing to PIC.
b) 12V programming voltage is connected to PIC MCLR line only
   when SEL3 pin is low. When SEL3 pin is high, all outputs of
   PIC programming unit must be in high-impedance state!

@ENDNODE
@NODE Demo "Demo"

Demo program "demo.asm" by Lars Malmborg is provided to check hardware.
There is very simple program (flashing two leds), which you can
translate and write into PIC.

Schematic diagram (is it really needed?) is included in file "demo.iff"
in "demo" directory.

@ENDNODE
@NODE Registration "Registration"

Question:

Register? What for! I have this beautiful program and I won't
pay any money!

Answer:

Of course, you can use this program without any costs.

If you will use this program only for make single chip
(for example for connecting PC keyboard to your Amiga)
I would like to get e-mail from you, but no money!

But:

If you want to make some money using my program, don't you think
I would like to make some money too?

I hope you will write the beautiful program for PIC and nobody
will pay for it...

Please remember:
 - This program is still under developing!
 - Some features are accessible only for registered users!

 - EMPIC should be not only for 16x84 microcontrollers, but I must
   have some money for buying the chips for experiments...

And (last but not least):

My program is not very expensive...

If you want to register, please:

a) Fill in the file "Order form", print it and sign
    or
a') if you haven't printer use typewriter.
Please, do not write manually...

b) Send the sheet together with the registration fee to me.
   Please, send money only.

c) Be patient and wait. When the next version will be complete,
   you will get it together with personal key file.

You can select between two possibilities: I can send you
disk with new version of EMPIC together with personalized
key file or I can send you only personalized key file
via e-mail (you must download EMPIC from Aminet).

Registration fee is (at now) not very big. This is:

a) 15 USD or 20 DEM
b) Polish users only - Tylko dla uûytkowników w Polsce: 20 zî.
   UWAGA! Waûne tylko do 13 kwietnia 1997!

@ENDNODE
@NODE Copyright "Copyright"

Programs EMPIC 1.3 and EMASM 1.3 may be freely distributed only
with this guide document (or authorized translation) included.
EMPIC 1.3 and EMASM 1.3 may be distributed in Poland only
via Aminet.

@{b}EMPIC 1.x and EMASM 1.x nie mogâ byê rozpowszechniane w Polsce
poprzez ûadne úródîa z wyjâtkiem Aminetu.@{ub}

No profit must be made by distributing EMPIC and EMASM.

@ENDNODE
@NODE BugReports "Bug reports"

Of course there is no bugs in my program :-)
I fixed all.

                                               but...

Any bug reports, misfeatures, ideas and what you want please
send to @{"author" LINK Author}.



@ENDNODE
@NODE Author "Author"

Author of EMPIC packet:

    Bohdan R. Rau
    ul. Poleska 25/1
    15-476 Bialystok
    Poland
    tel +48-85-761285
    e-mail ethanak@free.polbox.pl

@ENDNODE
@NODE Thanks "Credits"

Thanks to:

Stephen Marsden with his EPic1.2.lha with EPic and IBMKEY25

Stefan Stuntz for his great @{"MUI" LINK MUI}

Klaus Melchior for @{"Busy class" LINK MCC_BUSY}

Adam Wladyczanski for his PICs, PC keyboard and for soldering
some wires inside my Amiga.

Lars Malmborg for demo program, modification of hardware
project and some good ideas.

@ENDNODE
@NODE MCC_BUSY "Busy class"

    mcc_Busy and mcp_Busy are copyright by Klaus Melchior
    For more informations see MUI preferences program
@ENDNODE
@NODE MUI "MUI"
                          This application uses


                        MUI - MagicUserInterface

                (c) Copyright 1993-96 by Stefan Stuntz


MUI is a system to generate and maintain graphical user interfaces. With
the  aid  of  a  preferences program, the user of an application has the
ability to customize the outfit according to his personal taste.

MUI is distributed as shareware. To obtain a complete package containing
lots of examples and more information about registration please look for
a  file  called  "muiXXusr.lha"  (XX means the latest version number) on
your local bulletin boards or on public domain disks.

          If you want to register directly, feel free to send


                         DM 30.-  or  US$ 20.-

                                  to

                             Stefan Stuntz
                        Eduard-Spranger-Straße 7
                             80935 München
                                GERMANY



             Support and online registration is available at

                          http://www.sasg.com/


@ENDNODE
@NODE Disclaimer "Disclaimer"

                              Disclaimer


  These programs are provided "as is" without warranty of any kind.
All risks involved using these programs are entirely yours.  The
author assumes no responsibility or liability whatsoever for any
damage or dataloss caused by using this package.  Although everything
has been done to make sure the program is fully functional, the author
cannot guarantee this for a 100%.

@ENDNODE
@NODE Future "Future"

What will be in next versions:


Near future:

a) Some more features

b) EMBASIC compiler (it seems to work now, but there is very far way
   to distribution)

c) EMSIM simulator (before EMBASIC, because I need some simulator
   to test EMBASIC output codes)

Next:

d) 16C5x support


e) If you have an idea for letters d..z, please send the mail
to the @{"Author" LINK Author}.

@ENDNODE
