Re: Ti Link


[Prev][Next][Index][Thread]

Re: Ti Link



Example code:

Written in asm and basic (only two languages I know, only two
languages you ever need to know.)

step 1: get the port.

asm [NASM syntax]:

mov ax, 0x0040
mov es, ax
mov bx, 8
mov dx, [es:bx]
;dx now contains the LPT1 port.

basic: [PB 3.0c, though it might work with qb].

dim PPort as WORD
def seg = &h0040
PPort = PEEKI(8)

step 2: sending.

asm [assuming dx holds port.]:

MOV AL, 0         ;00 = 0, 01 = 2, 10 = 1, 11 =3.
OUT DX, AL

basic [nice little sub, pb3.0c]:

SUB TILSend (ToSend AS BYTE) SHARED PRIVATE
 DIM PPort as WORD
SELECT CASE ToSend
 CASE 00
  OUT PPort, 0
 CASE 01
 OUT PPort, 2
 CASE 10
 OUT PPort, 1
 CASE 11
 OUT PPort, 3
 END SELECT
END SUB

step 3: recieving.

asm [assuming DX holds port.]

INC DX
IN AL, DX
DEC DX
AND AL,0x30
MOV CL, 4
SHR AL, CL
;al currently contains: 0 = 00, 1 = 10, 2 = 01, 3 = 11.

basic. [pb 3.0c]

FUNCTION TILGet () SHARED PRIVATE AS BYTE
DIM PPort as WORD
SELECT CASE (INP(PPort+1) AND &h30)
 CASE 0
  FUNCTION = 00
 CASE &h10
  FUNCTION = 10
 CASE &h20
 FUNCTION = 01
 CASE &h30
 FUNCTION = 11
END FUNCTION
END FUNCTION


That works for my LPT1 link, anyway. Haven't tested the asm, though it
should work. NB: asm is written in NASM syntax, the current best ibm
pc assembler, hands down. the basic is written in powerbasic, the
current best basic compiler, again hands down. actually beats some C
compilers in optimization. pretty cool.


References: