MemIn Function

Returns the status of the specified memory I/O port. Each port contains 8 memory bits.

Syntax
MemIn(portNumber)

Parameters

portNumber
Specify bytes of the memory I/O.

Return Values
Returns an integer value between 0 and 255. The return value is 8 bits, with each bit corresponding to 1 memory I/O bit.

Description
MemIn provides the ability to look at the value of 8 memory I/O bits at the same time. The MemIn instruction can be used to store the 8 memory I/O bit status into a variable or it can be used with the Wait instruction to Wait until a specific condition which involves more than 1 memory I/O bit is met.

Since 8 bits are retrieved at a time, the return value ranges from 0 and 255. Please review the chart below to see how the integer return values correspond to individual memory I/O bits.

Memory I/O Bit Result (Using Port #0)

Return Values 7 6 5 4 3 2 1 0
1 Off Off Off Off Off Off Off On
5 Off Off Off Off Off On Off On
15 Off Off Off Off On On On On
255 On On On On On On On On

Memory I/O Bit Result (Using Port #31)

Return Values 255 254 253 252 251 250 249 248
3 Off Off Off Off Off Off On On
7 Off Off Off Off Off On On On
32 Off Off On Off Off Off Off Off
255 On On On On On On On On

Note


  • Difference Between MemIn and MemSw

    The MemSw instruction allows the user to read the value of 1 memory I/O bit. The return value from MemSw is either a 1 or a 0 which indicates that the memory I/O bit is either On or Off. MemSw can check each of the memory I/O bits individually. The MemIn instruction is very similar to the MemSw instruction in that it also is used to check the status of the memory I/O bits. However there is 1 distinct difference. The MemIn instruction checks 8 memory I/O bits at a time vs. the single bit checking functionality of the MemSw instruction. MemIn returns a value between 0 and 255 which tells the user which of the 8 I/O bits are On and which are Off.


See Also
In, InBCD, Off, MemOff, On, MemOn, OpBCD, Oport, Out, MemOut, Sw, MemSw, Wait

MemIn Function Example
The program example below gets the current value of the first 8 memory I/O bits and then makes sure that all 8 I/O are currently set to “0” before proceeding. If they are not “0” an error message is given to the operator and the task is stopped.

Function main
    Integer var1

    var1 = MemIn(0)  'Get the 1st 8 memory I/O bit value
    If var1 = 0 Then
        Go P1
        Go P2
    Else
        Print "Error in initialization!"
        Print "First 8 memory I/O bits were not all set to 0"
    EndIf
Fend

Other simple examples from the Command window are as follows:

> memout 0, 1
> print MemIn(0)
1
> memon 1
> print MemIn(0)
3
> memout 31,3
> print MemIn(31)
3
> memoff 249
> print MemIn(31)
1
>