IL Instruction Overview E
IL Instruction Overview E
ends
gs
gs
r
r
eter
eter
n
n
c Fla
c Fla
the
the
mete
mete
uctio
uctio
De p
De p
a ram
a ram
lters
lters
tate
tate
meti
meti
ution
ution
x
x
Us
Us
Inde
Inde
rA
rA
Para
Para
Instr
Instr
FB P
FB P
Arith
Arith
on, o
on, o
Exec
Exec
ACC
ACC
6050 Read S-Bus PGU mode
6060 Read S-Bus PGU port number
6070 Read S-Bus level Status
Special Instructions 6080 Read current PGU owner
6100 Read modem status
NOP NO Operation 6500 Read modem type string
R 6510 Read modem reset string
RTIME READ Time. = 6520 Read modem initialisation string
Uses register R and the following one. 7000 Read system counter
WTIME R Write Time E = 7050 Second
7051 Minute
PID R PID Control algorithm E = 7052 Hour
7053 Minute and second
Uses register R and the 12 following
7054 Hour and minute
ones 7055 Hour, minute and second
TEST Testnumber TEST HARDWARE D/A E 7060 Day
(unconditional Value Bit number Test Description 7061 Month
test ) or 7062 Year
11 11
7063 Month and day
400 10 Public Memory Loss
7064 Year and month
200 9 Memory Extention Corruption
7065 Year, month and day
HLPNZE & the 100 8 System RAM Memory
7070 Day of week
7 7
Test-number 40 6 System Firmware Checksum
7071 Week of year
7072 Week of year and day of week
20 5 Serial Channels
7081 Time and date (on two register)
10 4 Real Time Clock
7090 Seconds elapsed since 1970
3 3
4 2 User Program/Text Checksum SYSWR RK SYStem WRite E =
2 1 User Program/Text RAM RK 1000 System Watchdog (PCD1 only)
1 0 Public RAM (F, T, C, R, Mailbox) 2000 Write EEPRom Register 0
DIAG R Read XOB DIAGnostic 2001 Register 1
2002 Register 2
Uses register R and the 11 following 2003 Register 3
ones. 2004 Register 4
SYSRD RK SYStemRead E = 4000 Set XOB overflow
R (result) 4005 Enable/disable XOB 5
Code Function description 4013 Enable/disable XOB 13
4014 Install XOB 14
2000 Read User EEPROM Register 0 4015 Install XOB 15
Value contained in the EEPROM 4017 Execute XOB 17
2001 Register 1
4018 Execute XOB 18
2002 Register 2 4019 Execute XOB 19
2003 Register 3 6000 Write S-Bus station number
2004 Register 4
7000 Convert FFP to IEEE format.
5000 Read Device type in ASCII 7001 Convert IEEE to FFP format.
5010 in decimal 7050 Second
5100 Read own CPU type in ASCII 7051 Minute
5110 in decimal 7052 Hour
5200 Read own Firmware version in ASCII 7053 Minute and second
5210 in decimal 7054 Hour and minute
5400 Read User program name in ASCII 7055 Hour, minute and second
6000 Read S-Bus station number
7060 Day
6010 Read S-Bus PGU TN delay 7061 Month
6020 Read S-Bus PGU TS delay 7062 Year (<100)
6030 Read S-Bus PGU timeout 7063 Month and day
6040 Read S-Bus PGU baudrate
7064 Year and month
8 9
ends
ends
gs
gs
r
r
eter
eter
n
n
c Fla
c Fla
the
the
mete
mete
uctio
uctio
De p
De p
a ram
a ram
lters
lters
tate
tate
meti
meti
ution
ution
x
x
Us
Us
Inde
Inde
rA
rA
Para
Para
Instr
Instr
FB P
FB P
Arith
Arith
on, o
on, o
Exec
Exec
ACC
ACC
7065 Year, month and day R (1) i
7081 Time and date (on two registers) FMUL Floating point MULtiplication ZPN =
R (2) -- R(3)=R(1)*R(2)
SYCMP R SYStem CoMPare A = R (3) i E
KR Compares the sum of the two Register R1+R2 R (1) i
to System Counter and set ACCU accordingly FDIV Floating point DIVision ZPN =
R (2) -- R(3)=R(1)/R(2)
R (3) i E
FSQR R Floating point SQuare Root ZPN =
R
E
FCMP R i Floating point CoMPare ZPN =
R --
E
FSIN R i Floating point SINe ZPN =
R i
FCOS R i Floating point COSine ZPN =
R i
FATAN R i Floating point Arc TANgent ZPN =
R i
FEXP R i Floating point EXPonential ZPN =
R i
E
FLN R i Floating point Logarithm ZPN =
R i
E
FABS R i Floating point ABSolute value Z =
R i
10 7
ends
gs
Control instructions
eter
n
c Fla
the
mete
uctio
De p
a ram
lters
tate
meti
JR HLPNZE- Jump Relative Can depend
ution
x
Us
Inde
rA
Para
Instr
& Label or
FB P
Arith
to a label or a fix number of lines. on the state
on, o
Exec
ACC
a constant Example: off the
R i LABLE: NOP ACCU or
ROTL ROTate register Left A = JR Z LABLE
1..32 -- the state of
ROTR R i ROTate register Right A = an
1..32 -- or
JR Z -2 arithmetic
( jumps backwards two lines when Z- flag
flag=1 )
JPD HLPNEZ- JumP Direct Can depend
and a to the line-number x off this block on the state
INTEGER Arithmetic constant Example: off the
ADD R K (1) i ADD registers ZP = JPD 10
R K (2) -- ACCU or
R(3)=R(1)+R(2) NE the state of
R (3) i ( jumps unconditional to the 10th line
R K (1) i SUBstract registers ZP an
SUB R K (2) --
= of this block)
arithmetic
R(3)=R(1)-R(2) NE
R (3) i flag
MUL R K (1) i MULtiply registers ZP = HLPNEZ- Can depend
R K (2) -- JPI JumP Indirect
R(3)=R(1)*R(2) NE and a to the linenumber x off this block. The on the state
R (3) i Register- linenumber is in the R. off the
DIV R K (1) i DIVide registers ZP = number Example: ACCU or
R K (2) i R(3)=R(1)/R(2)
R (3) -- NE JPI L 33
the state of
R(4)=remainder
R (4) i an
( jumps on ACCU=0 to the line-
SQR R Square ZP = arithmetic
number which is stored in the register
R
NE R33 ) flag
RK i CoMPare registers ZPN = HALT HLPNZE HALT the CPU Depends on the
CMP RK -- state off the
↓ ↓ ↓
ACCU or the
Example: CMP Symbol_X Symbol_X = Symbol_Y HHL
Symbol_Y Symbol_X > Symbol_Y state of an
LHL arithmetic flag
Symbol_X < Symbol_Y
LLH
LOCK 0..99 LOCK semaphore
UNLOCK 0..99 UNLOCK semaphore
FLOATING POINT Arithmetic
IFP R i Integer to Floating point E =
-20..+18 (10^X) --
FPI R i Floating point to integer E =
-20..+18 (10^X) --
FADD R (1) i Floating point ADD ZPN =
R (2) -- R(3)=R(1)+R(2)
R (3) i E
FSUB R (1) i Floating point SUBtraction ZPN =
R (2) -- R(3)=R(1)-R(2)
R (3) i E
6
-11-
ends
gs
r
eter
n
c Fla
the
mete
uctio
De p
Program blocks
a ram
lters
tate
meti
ution
x
Us
Inde
rA
Para
0…15 Cyclic ACCU is set at
Instr
COB
FB P
Arith
on, o
Exec
ACC
Supervisiontime ( 0 . .100000 x 10ms) organisation beginning and
blocks restored at the
ECOB end
0..999 Function blocks ACCU is set at READ/WRITE BCD Instructions
FB beginning and O..9 --
DIGI DIGit In ZP =
restored at the IOF --
end R i N
EFB
HLEZPN & Number 0…999 Call Function Depends on DIGIR 0..9 -- DIGit In Reversed ZP =
CFB IOF --
Parameter1 block ACCU or Flags
R i N
…..
Parameter128 DIGO 0..9 -- DIGit Out E =
R i
PB 0…299 Program blocks ACCU is set at
beginning and OF --
restored at the DIGOR 0..9 -- DIGit Out Reversed E =
R i
EPB end
OF --
CPB HLEZNP & Number 0…299 Call Program block Depends on
ACCU or Flags
CPBI HLEZNP & Number 0…299 Call Program block Depends on
indirect ACCU or Flags
LOGIC Word Instructions
0 Power problem in the main rack Exception blocks ACCU is set at AND R i AND registers ZP =
XOB 1 Power problem in extension rack PCD 6. beginning R --
2 Battery low R i NE
4 Parity error on the I/O bus (PCD6) OR R i OR registers ZP =
EXOB 5 No response on a module I/O (PCD4/6) R --
6 External error R i NE
7 Over load of the system due to multiple EXOR R i EXOR registers ZP =
events. R --
8 Instruction non valid R i NE
9 To many active tasks (Graftec) NOT R i Complement register ZP =
10 To many PB/FB levels R i
11 Watch dog COB NE
12 Index registers overflow
13 Error Flag
14 Cyclic XOB
15 Cyclic XOB SHIFT and ROTATE Instructions
16 Cold start SHIU R SHIft registers Up =
17 S-Bus telegram R
18 S-Bus telegram R SHIft registers Down =
19 S-Bus telegram
SHID R
20 Interrupt input INB1 R ROTate registers Up
25 Interrupt input INB2
ROTU R
=
30 No connection with RIO R ROTate registers Down
0…31 Sequential blocks
ROTD R
=
SB
SHIL R i SHIft register Left A =
ESB 1..32 --
CSB HLZNPE & SBNumber ( 0…31 ) Call Sequential Depends on R i Shift register Right A
block ACCU or Flags
SHIR 1..32 --
=
12 5
ends
gs
r
eter
n
c Fla
the
mete
uctio
De p
Comunication
a ram
lters
tate
meti
ution
x
Us
Inde
rA
Para Portnumber Assign Serial Interface E =
Instr
SASI
FB P
Arith
on, o
Exec
ACC
Textnumber
READ/WRITE Binary
BITI 1..32 -- BIT In ZP =
IOFTC --
R i N
BITIR 1..32 -- BIT In Reversed ZP =
IOFTC --
R i N
BITO 1..32 -- BIT Out =
R i
OFTC --
BITOR 1..32 -- BIT Out Reversed =
R i
OFTC --
4 13
ends
gs
r
eter
n
c Fla
the
mete
uctio
SASI TEXTS:
De p
a ram
lters
tate
meti
ution
x
Us
General structure:
Inde
rA
Para
Instr
FB P
Arith
on, o
Exec
ACC
TEXT xxxx "<uart_def>; <mode_def>; <diag_def>;<rx_buf>;<tx_buf>;"
where xxxx is the text number (0..3999). SASI Texts are case sensitive!!!
Gateway
Master GM,R
Gateway
Slave GS2
INDEX REGISTER Instruction
Deactivate OFF
SEI R K (13Bit) SEt Index register =
INI R K (13Bit) Increment Index register A =
Diagnostic Flags
The Output or Flag address following the DIAG definition of the SASI texts is the base address R K (13Bit)
of 8 consecutive Outputs or Flags, used as follows: DEI Decrement Index register A =
xxxx RBSY Receiver busy
STI R Store Index register =
xxxx+1 RFUL Receive buffer full
xxxx+2 RDIA Receiver diagnostic RSI R ReStore Index register =
xxxx+3 TBSY Transmitter busy
xxxx+4 TFUL Transmit buffer full
xxxx+5 TDIA Transmitter diagnostic
xxxx+6 XBSY Text busy
xxxx+7 NEXE Not executed
14 3
ends
gs
r
eter
n
c Fla
the
mete
uctio
De p
a ram
lters
tate
$ Directives
meti
ution
x
Us
Inde
rA
Para
Instr
FB P
Arith
on, o
Exec
ACC
Directives direct the assembler to do something special when the source module is assembled.
All directives consist of a $ immediately followed by the directive name.
No space can appear between the $ and the name. Directives are processed at assembly time, they are
never executed by the PCD.
A complete list of all $Directives can be found in the online help
BINARY Instructions
HLNPEZC $INCLUDE Includes another IL file. Example:
ACC ACCUmulator operations A NP $Include "C:\temp folder\testfile.src"
1. The ACCU can be set & reset EZ
unconditionally: $Ifxxxx Conditional Assembly Directives $IF conditional_expression
ACCU H = set or ACCU L = reset $ENDIF If the result of conditional_expression is
2. The ACCU can be set and reset according Not
The conditional assembly non-zero (true).
to the sate of one of the arithmetic flags. true directives allow code to be
Example: conditionally included or excluded $IFN conditional_expression
ACCU E ( The ACCU is set if at assembly time. They are If not: if the result of
the Error flag is high ) evaluated when the program is conditional_expression is zero (false).
3. ACCU can be inverted ( ACC C = assembled, NOT when it is
complement) executed $IFDEF symbol
STH IOFTC i Start high A = Conditional directives are typically If the symbol name is DEFined, EQUated,
IOFTC i used to produce different versions declared EXTN, or is a label declared in the
STL Start Low A = of a program where most of the current block.
ANH IOFTC i AND high A/D = code is the same for each version,
IOFTC i or to include special code during $IFNDEF symbol
ANL AND low A/D = the debug phase of a program. If the symbol is not DEFined, EQUated,
ORH IOFTC i OR high A/D = declared EXTN, or a label.
$IFB If blank.
$IFNB If not blank.
$IFE If equal.
$IFNE If not equal.
2 15
$SASI, The texts between $SASI and Example: BINARY INSTRUCTIONS .................................................................................................................. 2
$ENDSASI $ENDSASI are fully checked by $SASI
the assembler and invalid texts are TEXT 20 LOAD ELEMENTS .............................................................................................................................. 3
detected "UART:4800,8,N,1;MODE;MC2;DIAG:
INCREMENT/DECREMENT ELEMENTS ...................................................................................... 3
If $SASI..$ENDSASI are not F0,R100; RBUF:25; TBUF: 30;"
used, it is possible to enter an ... INDEX REGISTER INSTRUCTION................................................................................................. 3
invalid text which may cause $ENDSASI
incorrect initialization of the serial COPY ELEMENTS............................................................................................................................... 4
port.
$SKIP, All statements between the $SKIP Format: READ/WRITE BINARY ...................................................................................................................... 4
$ENDSKIP and $ENDSKIP directives, or all $SKIP READ/WRITE BCD INSTRUCTIONS ............................................................................................. 5
statements after $SKIP until the statements_to_be_skipped
end of the file, are totally ignored ... LOGIC WORD INSTRUCTIONS....................................................................................................... 5
by the assembler $ENDSKIP
$ERROR Displays the user-defined Example: SHIFT AND ROTATE INSTRUCTIONS ......................................................................................... 5
and error_message and warnings, and
INTEGER ARITHMETIC ................................................................................................................... 6
$WARNING increments the error/warning IF Axis > 4
count. This is often used inside a FLOATING POINT ARITHMETIC..................................................................................................6
$IF..$ENDIF statement, which can $ERROR "Axis" is out of range: @Axis@
be used to detect the error, i.e. if a $ENDIF SPECIAL INSTRUCTIONS................................................................................................................. 8
user-defined constant was out of
CONTROL INSTRUCTIONS............................................................................................................ 11
range. If an error is generated, then If Axis is greater than 4 (e.g. 10), the
no object file is produced and an assembler generates an error message: PROGRAM BLOCKS ........................................................................................................................ 12
error value is returned to the Error 165: AXIS.SRC: Line 45: "Axis" is
Project Manager. out of range: 10 COMUNICATION ............................................................................................................................... 13
Warnings don't stop the assembly.
SASI TEXTS ........................................................................................................................................ 14
$ DIRECTIVES .................................................................................................................................... 15
$COBSEG The code between Format: SPECIAL CHARACTERS WHICH CAN BE USED INSIDE TEXTS ................................... 17
$ENDCOBSEG $COBSEG..$ENDCOBSEG is put
into a COB, $XOBSEG xob_number
r
cy
n
and code between ...
metic
and
mete
mete
uctio
nde n
$XOBSEG..$ENDXOBSEG is put
s
$XOBSEG into an XOB. $ENDXOBSEG
Inde
Para
Para
Arith
ACC
Instr
Flag
d epe
$ENDXOBSEG
FB
$CPU and The downloader will not allow the Format:
$STATION program to be downloaded into $CPU destination_CPU_number I Input 0..8191 P Positive
"X"can be D=
FB parameters
E Error
correct firmware. Positive, the state of High if an instruction cannot
the
Negative, instruction is the ACCU be executed or on Overflow,
Error, Underflow and Conversion)
Zero
named
COPYX
16 -1-
Special characters which can be used inside texts
Control characters can be entered in DCE or as Mnemonic. They arealways in bracets <>
Example: The "LINE FEED" comand can be written like this: <LF> or like this <10>.
Texts can also contain variables such as the clock value, the status of an input, the content of a register, ...
There are two characters which have a special meaning for the PCD: $ and @.
$ = DIRECT ADDRESSING
@ = INDIRECT ADDRESSING
18 Edition 26/786E1