adac
This document describes the structure of the acquisition system programming interface. ADAC+ is used to compile the EVS program into a binary code that can be easily understood by the CAMAC driver. Every time a CAMAC module generates a LAM (Look-At-Me) signal an interruption is generated in the computer. This interruptions is processed by the CAMAC driver in the computer and the corresponding instructions are processed.This document is divided as follow:
- HOW TO ASSEMBLE A PROGRAM
- STRUCTURE OF THE PROGRAM
- BASIC INSTRUCTION LIST AND DEFINITIONS
- MACRO INSTRUCTION LIST AND DEFINITIONS
- REGISTERS and OPERATORS
- PRE-COMPILER DIRECTIVES
- DIRECTIVES TO THE ASSEMBLER ("EQUATE", LOOP, ENDLOOP)
- ASSEMBLY-TIME VARIABLES
- STATEMENT LABELS
- SYNTAX RULES
- PROGRAMMING EXAMPLE
How to assemble a program
The commands to assembler and disassemble a program are:- adac [FILE NAME] - to compile a program
- tadac4096 [FILE NAME] - the same as above
- [FILE NAME].EVO - The compiled program
Structure of the program
The data acquisition program is divided into two main sections:- configuration
- This section configures the CAMAC modules in order to make them ready for data acquisition.
- event loop
- When a LAM signal is generated in the CAMAC electronic and sent to the computer, the event is processed by this part of the program. The event loop section should read the CAMAC modules, process the information and send the data in the correct format to the output.
IMPORTANT NOTE: In general, the LAM signal is generated after the event is processed by the CAMAC module. If there are slower modules than the one used for the LAM generation it may be possible that the data in the slower modules can not be ready to be transferred to the computer, making, sometimes, the data unusable.
The configuration and event loop blocks are separated by the INIT statement. The INIT statement tells the computer where the event loop instructions begin. The END statements tells the computer where the event loop block finishes. A basic structure of a program is:
... ... CONFIGURATION INSTRUCTIONS ... ... INIT ... ... EVENT LOOP INSTRUCTIONS ... ... END
Basic instruction list and definitions
- NOP
- Do nothing
- BRU DEST
- Branch to Destination - DEST is a label or an absolute address in the code. I strongly suggest to use labels as destinations because it is very easy to miscalculate absolute addresses by hand
- SPB DEST
- STORE POSITION and BRANCH - Similar to CALL in Fortran. DEST is a label or absolute address in the same form as for BRU. The main difference between BRU and SPB is the fact that SPB tells the computer to remember its address. The system stores up to 100 nested SPB addresses. If more than 100 SPB are called, without the corresponding command BRUR, each subsequent SPB command will act like a simple BRU command
- BRUR
- Return from subroutine called by SPB. If there is no SPB address stored in the memory, nothing is done. BRUR returns to the NEXT instruction just after the last SPB command was called
- DLAY #
- Wait for #*(0.1 micro-sec) up to 409.6 micro-sec. The argument has to be a number or an assembly-time variable. Registers are not allowed in this command.
- INIT
- Set the startup of the event loop. Sets the point of return for the CAMAC configuration part of the program
- END
- Set the end of the event loop. Exits the loop or the CAMAC configuration, if called
- RTRN
- Exit the event loop or the CAMAC configuration, if called
- NAF N, A, F
- Do NAF - result is stored in register CA
- OUT [R]
- Output Register [R]. [R] can also be a number or an assembly-time variable.
- MERG [T], [R]
- Merge (AND) the 12-16 bits of the register [T] into register [R] and send [R] to the output. [T] can also be a number or an assembly-time variable. [R] has to be a valid register.
- MOV [T], [R]
- Move content of register [T] to register [R]. [T] can also be a number or an assembly-time variable. [R] has to be a valid register.
- SKIP [R].OP.[T]
- This command skips the next instruction if the logical operation defined by the operator .OP. between the registers [R] and [T] are satisfied. [R] has to be an valid register. [T] can also be a number or an assembly time variable.
Macro instruction list and definitions
- IF([R].OP.[T]) ADDR
- Go to ADDR if the logical operation defined by the operator .OP. between the registers [R] and [T] are satisfied. [R] has to be an valid register. [T] can also be a number or an assembly time variable. ADDR can be either a label in the code or an absolute address.
This command is expanded into the following basic instructions:SKIP [R].IO.[T] BRU ADDR
where .IO. is the inverse operator of .OP. For example, the inverse operator of .GT. is .LE.
- Go to ADDR if the logical operation defined by the operator .OP. between the registers [R] and [T] are satisfied. [R] has to be an valid register. [T] can also be a number or an assembly time variable. ADDR can be either a label in the code or an absolute address.
- ROUT N, A, F
- Similar to NAF but also sends the register to the output. See NAF for more details.
This command is expanded into the following basic instructions:NAF N, A, F
OUT
- Similar to NAF but also sends the register to the output. See NAF for more details.
Registers and operators
There are 3 main registers available. The main difference between the different registers is their size. The registers are ZEROED in the beginning of each run but they are NOT zeroed from one event to the other. The registers are:- PAT - 16 bits register. Often used to store CAMAC module bit patterns
- EX - 16 bits register. General use
- CA - 12 bits register. General use
The operators are FORTRAN style operators and are:
- [R].ANY.[T] - Compare
and bit a bit and the result is true if at least one of the bits match - [R].NONE.[T] - Compare
and bit a bit and the result is true if at none of the bits match - [R].GT.[T] - Returns true if
is greater than - [R].LT.[T] - Returns true if
is smaller than - [R].GE.[T] - Returns true if
is greater or equal than - [R].LE.[T] - Returns true if
is smaller or equal than - [R].EQ.[T] - Returns true if
is equal to - [R].NE.[T] - Returns true if
is different than - [R].NONE.[T] - Compare
Pre-compiler directives
Pre compiler directives are used to set some CAMAC parameters or label the compiled program. When running the acquisition system with the SPMRoot program there is no need for such directives. These directives are mainly used by the old SPM acquisition system. See the SPM documentation for more information.The main pre-compiler directives are:
- KAUX = #
- CSYS = #
- CREM = #
- CAUX = #
- NAUX = #
- NSHD = #
- PGM$
Directiver to the assembler ("EQUATE", LOOP, ENDLOOP)
- SYM = EXPRESSION
- Directs assembler to evaluate EXPRESSION and assign the resulting value to SYM. This performs a simple calculation. Multiple operations are performed always from left to right.
- LABL LOOP NLOOP
- Directs the assembler to "replicate" the set of statements bounded by the LOOP and ENDLOOP directives. Do it NLOOP times. LABL is a defined address label and it is optional.
- ENDL or ENDLOOP
- Defines the End-of-Loop.
Assembly-time variables
Symbols defined by the "Equate Directive" (SYM = EXPRESSION) are called assembly-time variables or just assembly variables. Such variables may be re-defined without restriction. The variable SYM is taken as an integer number.Note: These are not run-time variables! - THERE ARE NO RUN-TIME VARIABLES! Assembly variables must always be defined in terms of numbers and/or previously defined assembly variables.
Particular number formats as bit patterns are not allowed.
Statement labels
All statement labels, including those on the LOOP directive Are defined to all parts of the program and, therefore, must be unique.The configuration part of the program can not jump to the event loop part and vice versa. This may have severe consequences in the CAMAC driver stability if used.
Syntax rules
- Operators are defined in the FORTRAN style in order to distinguish them from numerical expressions.
- All statement labels must start in the first column.
- All instructions (Basic and Macro) must start after the first column. At least one blank must separate any statement label and the instruction field.
- At least one blank must separate the instruction and operand fields.
- Imbedded blanks are allowed in (but removed from) the IF-MACRO, expressions and operand fields of all types. I.e. you can type it any way you wish but I will re-format it to be the way I like it.
- All comment fields must be preceded by a semicolon.
- A completely blank line will show up as a blank line in the assembly listing and otherwise be ignored.
- All numbers are decimal by default.
- Hex numbers are specified by a trailing "H" (8000H for example) or starting with a "0x" (0x8000 for example). The "H" representation CAN NOT be used in expressions
- "Bit Expressions" are lists of bit-numbers enclosed in [ ]. Example:[16,1,2] produces 8003H. Bit lists can contain assembly time variables. Bit lists can not be used in expressions. The first bit id is 1.
Programming example
; Test program that read ADC values from a ; PHILIPS 7164 16 channels, 12 bits per channel ; ADC module PGM$ This is the tile of the program NA1=6 ; ADC 7164 location NLAM=6 ; LAM module NAF NA1,0,9 ; Clear Module NAF NLAM,0,26 ; ENABLE LAM MOV 0,CA ; PEDESTAL A=0 LOOP 16 NAF NA1,0,17 NAF NA1,A,20 A=A+1 ENDLOOP MOV 50,CA ; LLD A=0 LOOP 16 NAF NA1,1,17 NAF NA1,A,20 A=A+1 ENDLOOP MOV 4000,CA ; ULD A=0 LOOP 16 NAF NA1,2,17 NAF NA1,A,20 A=A+1 ENDLOOP MOV 15,CA NAF NA1,0,19 ; HABILITA PED., LLT, ULT INIT ; here the event loop starts NAF NA1,1,6 ; READ HIT REGISTER MOV CA,PAT IF(PAT.NONE.[1,2,3,4])NOEV IF(PAT.NONE.[2])LEV1 OUT 8001H ROUT NA1,0,0 ROUT NA1,1,0 LEV1 IF(PAT.NONE.[3])END OUT 8003H ROUT NA1,2,0 ROUT NA1,3,0 END OUT 0FFFFH NOEV NAF NA1,3,11 ; Clear Hit Register, LAM & Data Register RTRN END