<< Prev        Next >>

ID : 312

DefIO

Function

To declare a local variable of I/O type.

Syntax

DefIO variable name = data size, port address[, mask information]

Guaranteed entry

Variable name
Designate a variable name. Each name must be designated in accordance with the Naming convention. Each name must be unique within the valid range. In addition, array declaration is also possible.
Data size
Designate the data size of I/O Type data. Possible data sizes are "Bit," "Byte," "Word," "Short," "Integer" and "Single."
Port address
Designate a start number of I/O port. Designate by Integer Type data. An error occurs when a number not existing in the I/O port or the data size cannot be fit into the I/O port.
Mask information
Designate mask information by Integer Type data.
In case of input port, a result of And calculation of input data and mask information is obtained.
In case of output port, And of output data and mask information is extracted but the output status of bits for which mask is not set remains unchanged. If the data size is Single, you cannot designate mask information.

Description

A local variable of I/O type is declared.

About declaration in an array

Declaration in an array is possible when you want to use continuous I/O ports in a batch for remote register, etc.

'Example of declaring 16 Rwdin variables by word data from I/O port 4096
DefIO Rwdin(15) = Word, 4096
'Example of declaring 16 Rwdout variables by word data from I/O port 4608
DefIO Rwdout(15) = Word, 4608

Related Terms

Declaration Statement

 

Attention

 

Example

'!TITLE "Declaration of I/O Variable Corresponding to I/O Port"
' Declare I/O variable by Bit type, Byte type, Word type, Integer type and Single type
Sub Sample_DefIO 

' Declare a variable IO_OFFSET as 256
#Define IO_OFFSET 256

  ' Declare aaa as Bit type I/O variable starting from the port 1
  DefIO aaa = Bit, 1

  ' Declare bbb with mask information of Byte type I/O variable starting from the port 10
  DefIO bbb = Byte, 10, &B00001111


  ' Declare ccc as Word type I/O variable starting from the port 15
  DefIO ccc = Word, 15

  ' Declare ddd as Integer type I/O variable starting from the port 1
  DefIO ddd = Integer, 1

  ' Declare eee as Byte type I/O variable starting from the port calculation result port
  DefIO eee = Byte, IO_OFFSET + 10

  ' Declare fff as Single type I/O variable starting from the port 128
  DefIO fff = Single, 128

  ' Declare ggg as an array of Byte type I/O variable starting from the port 128
  DefIO ggg(4) = Byte, 128

  ' Store 1 in the port 128 and 0 in the ports 129 through 135
  ggg(0) = 1

  ' Store 0 in the ports 136 through 142 and 1 in the port 143
  ggg(1) = &H80


End Sub

ID : 312

<< Prev        Next >>