home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / LUA.ZIP / LUA / LUA_M / LUASAMPM.ASM < prev    next >
Assembly Source File  |  1991-09-10  |  40KB  |  789 lines

  1. ;******************************************************************************
  2. ;*                                                                            *
  3. ;*   MODULE NAME      : LUASAMP.ASM                                           *
  4. ;*                                                                            *
  5. ;*   DESCRIPTIVE NAME : LUA MASM/2 SAMPLE PROGRAM FOR IBM EXTENDED SERVICES   *
  6. ;*                      FOR OS/2                                              *
  7. ;*                                                                            *
  8. ;*   COPYRIGHT        : (C) COPYRIGHT IBM CORP. 1989, 1990, 1991              *
  9. ;*                      LICENSED MATERIAL - PROGRAM PROPERTY OF IBM           *
  10. ;*                      ALL RIGHTS RESERVED                                   *
  11. ;*                                                                            *
  12. ;*   FUNCTION         : This program                                          *
  13. ;*                      - Issues an SLI_OPEN to establish an LU_LU session.   *
  14. ;*                      - Issues an SLI_SEND to transmit data to the host.    *
  15. ;*                      - Issues an SLI_RECEIVE to get data from the host.    *
  16. ;*                      - Issues an SLI_SEND to transmit a response.          *
  17. ;*                      - Issues an SLI_CLOSE to end the LU_LU session.       *
  18. ;*                                                                            *
  19. ;*   GENERAL SERVICE                                                          *
  20. ;*     VERBS USED     : CONVERT - Translates data between ASCII and EBCDIC.   *
  21. ;*                                                                            *
  22. ;*   MODULE TYPE      : IBM Personal Computer Macro Assembler/2 Version 1.00  *
  23. ;*                                                                            *
  24. ;******************************************************************************
  25. INCLUDE DOSCALLS.INC                             ; Include Doscall Macros
  26. INCLUDE SUBCALLS.INC                             ; Include OS/2 Call Macros
  27. INCLUDE  LUA_M.INC                               ; The LUA MASM/2 includes
  28. INCLUDE  ACSSVCA.INC                             ; Adv. Comm. Gen. Serv. include
  29. TITLE   luasamp.asm
  30. .286p                                            ; Enable protected mode assembly
  31. .287                                             ; Enable 80287 floating point
  32.  
  33. EXTRN   ACSSVC:FAR                               ; APPC service verb entry point
  34. EXTRN   SLI:FAR                                  ; LUA SLI verb enrty point
  35.  
  36. ClearVerbRecord  MACRO   Record,Size             ; Define Macro to clear a
  37.                  mov     di,OFFSET Record        ; verb record.
  38.                  mov     cx,Size
  39.                  mov     ax,ds
  40.                  mov     es,ax
  41.                  sub     ax,ax
  42.                  rep     stosb
  43.                  ENDM
  44.                                                  ; Define DGROUP
  45. DGROUP  GROUP  DATA
  46.                                                  ; Create 4k Stack
  47. STACK  SEGMENT  WORD stack 'STACK'
  48.        dw  4000  dup(0)
  49. STACK  ENDS
  50.  
  51. DATA   SEGMENT  WORD PUBLIC 'DATA'
  52. ;******************************************************************************
  53. ; Declare storage for the verb records, data transactions, posting semaphore,
  54. ; and storage variables.
  55. ;******************************************************************************
  56.  
  57. LuaVerb             lua_common <>                ; Declare LuaVerb record
  58. LuaVerbSize         EQU   $-LuaVerb              ; Equate for size of LuaVerb.
  59. LuaVerb_Open        lua_open <>                  ; using the structures provided
  60.                     ORG    LuaVerb_Open          ; in LUA_M.INC.
  61. LuaVerb_Bid         lua_bid <>
  62.                     ORG    LuaVerb_Open
  63. LuaVerb_Send        lua_send <>
  64.                     ORG    LuaVerb
  65. LuaVerb_VR          DB 198 dup (0)               ; Initialize LuaVerb to zero.
  66.  
  67. ConvertVerb         CONVERT <>                   ; Declare ConvertVerb record
  68.                                                  ; using the structures provided
  69.                                                  ; in ACSSVCA.INC.
  70.  
  71. InitSelfRU          DB      01H                  ; Define 25 byte structure
  72.                     DB      06H                  ; for the INITSELF command RU.
  73.                     DB      081H
  74.                     DB      00H
  75.    IS_ModeName      DB      'LUA768RU'           ; This field needs to be
  76.    ModenameSize     EQU     $-IS_ModeName        ; to EBCDIC.
  77.                     DB      0f3H
  78.                     DB      08H
  79.    IS_PluName       DB      'VTAMPGM '           ; This field needs to be
  80.    PlunameSize      EQU     $-IS_PluName         ; to EBCDIC.
  81.                     DB      00H
  82.                     DB      00H
  83.                     DB      00H
  84.                     ORG     $+1
  85.  
  86. TestData            DB  'TEST#SENDING#DATA#TO#HOST' ; SLI_SEND data.
  87. TestDataSize        EQU $-TestData
  88. DataBuffer          DB      00H                  ; Declare a 256 byte data
  89.                     DB      255 DUP(0)           ; buffer for SLI_RECEIVE.
  90. DataBufferSize      EQU $-DataBuffer
  91.  
  92. UserRamSem          DD      00H                  ; Allocate a RAM semaphore.
  93. UserRamSemAddr      DD      UserRamSem           ; Set address of semaphore.
  94. SemTimeout          DD      -1                   ; Sem timeout to wait forever.
  95. LU_SessionID        DW      00H,00H              ; Save lua_sid value returned
  96.                                                  ; by SLI_OPEN.
  97. LU_Name             DB      'LUA1    '           ; LU to create session for.
  98. LU_NameSize         EQU     $-LU_Name
  99. SavedSeqNum         DB      00H,00H              ; Save Sequence # for responses.
  100.  
  101. DigitTable          DB      '0123456789ABCDEF'   ; table and buffer
  102. HexBuffer           DB  8  dup(' ')              ; for PRTHEX procedure
  103. HexBufferFilledSize DW  ?
  104.  
  105.  
  106. ;******************************************************************************
  107. ; Declare all the message strings and their sizes.
  108. ;******************************************************************************
  109.  
  110. OpenMessage         DB  0dH,0aH,'Opening communication with SLI interface...'
  111. OpenMessageSize     EQU $-OpenMessage
  112. InitSelfMessage     DB  0dH,0aH,'SLI session opened and INITSELF sent to host.'
  113. InitSelfMessageSize EQU $-InitSelfMessage
  114. DataMessage         DB  0dH,0aH,'Test data sent to host. Waiting for host data.'
  115. DataMessageSize     EQU $-DataMessage
  116. ResponseMessage     DB  0dH,0aH,'Host data received. Responding to host.'
  117. ResponseMessageSize EQU $-ResponseMessage
  118. CloseMessage        DB  0dH,0aH,'Response sent.  Preparing to close sesssion.'
  119. CloseMessageSize    EQU $-CloseMessage
  120. OK_Message          DB  0dH,0aH,'SLI interface closed with no errors.'
  121. OK_MessageSize      EQU $-OK_Message
  122. Error1_Message      DB  0dH,  0aH, 'Ab-ended LUA conversation due to error. '
  123. Error1_MessageSize  EQU $-Error1_Message
  124. Error2_Message      DB  0dH,0aH,'An error occurred during the conversion. '
  125. Error2_MessageSize  EQU $-Error2_Message
  126. Error3_Message      DB  0dH,0aH,'An error occurred with SLI API. Verb opcode: '
  127. Error3_MessageSize  EQU $-Error3_Message
  128. Error4_Message      DB  0dH,0aH,'The LU_LU session has failed due to an error.'
  129. Error4_MessageSize  EQU $-Error4_Message
  130. PrimRC_Message      DB  0dH,0aH,'The primary return code is: '
  131. PrimRC_MessageSize  EQU $-PrimRC_Message
  132. SecRC_Message       DB  0dH,0aH,'The secondary return code is: '
  133. SecRC_MessageSize   EQU $-SecRC_Message
  134.  
  135. DATA      ENDS
  136.  
  137.  
  138. CODE    SEGMENT  WORD PUBLIC 'CODE'
  139.         ASSUME  CS: CODE, DS: DGROUP
  140.         PUBLIC  main
  141. main    PROC FAR
  142.  
  143.         @VIOWRTTTY  OpenMessage,OpenMessageSize,0
  144.  
  145.         call    NEAR PTR SLI_OPEN                ; Open communication with local
  146.                                                  ; LU.
  147.         cmp     ax,0                             ; Check procedure return code,
  148.         je      MainSessOpen                     ; if zero then session opened.
  149.         jmp     MainExitError                    ; if not zero then end program.
  150.  
  151. MainSessOpen:
  152.         @VIOWRTTTY  InitSelfMessage,InitSelfMessageSize,0
  153.  
  154.         call    NEAR PTR SLI_SEND_DATA           ; Send trans-id and user data
  155.                                                  ; to the host.
  156.         cmp     ax,0                             ; Check procedure return code,
  157.         jne     MainAbend                        ; if not zero then Ab-end.
  158.  
  159.         @VIOWRTTTY  DataMessage,DataMessageSize,0
  160.  
  161.         call    NEAR PTR SLI_RECEIVE             ; Receive Data and response
  162.                                                  ; from the host.
  163.         cmp     ax,0                             ; Check procedure return code,
  164.         jne     MainAbend                        ; if not zero then Ab-end.
  165.  
  166.         @VIOWRTTTY  ResponseMessage,ResponseMessageSize,0
  167.  
  168.         call    NEAR PTR SLI_SEND_RESPONSE       ; Send response for data to
  169.                                                  ; the host.
  170.         cmp     ax,0                             ; Check procedure return code,
  171.         jne     MainAbend                        ; if not zero then Ab-end.
  172.  
  173.         @VIOWRTTTY  CloseMessage,CloseMessageSize,0
  174.  
  175.         push    0                                ; Indicate normal SLI_CLOSE.
  176.         call    NEAR PTR SLI_CLOSE               ; Close communcation with local
  177.                                                  ; LU.
  178.         cmp     ax,0                             ; Check procedure return code,
  179.         je      MainExitNoError                  ; if zero, then session closed
  180.                                                  ; successfully.
  181.  
  182. MainAbend:
  183.         cmp     ax,LUA_SESSION_FAILURE           ; If session failed,
  184.         je      MainSessFail                     ; display session failure message.
  185.         push    LUA_FLAG1_CLOSE_ABEND            ; Indicate Abnormal SLI_CLOSE.
  186.         call    NEAR PTR SLI_CLOSE               ; Close communication in ab-end
  187.  
  188. MainExitError:
  189.         @VIOWRTTTY  Error1_Message,Error1_MessageSize,0
  190.         jmp     MainDosExit
  191.  
  192. MainSessFail:
  193.         @VIOWRTTTY  Error4_Message,Error4_MessageSize,0
  194.         jmp     MainDosExit
  195.  
  196. MainExitNoError:
  197.         @VIOWRTTTY  OK_Message,OK_MessageSize,0
  198.  
  199. MainDosExit:
  200.  
  201.         @DosExit 0,0                             ; Return to Operating System
  202.  
  203. main    ENDP
  204.  
  205. ;****************************************************************************
  206. ;*  PROCEDURE NAME: SLI_OPEN                                                *
  207. ;*  FUNCTION      : Issue an SLI_OPEN of type secondary initself, using     *
  208. ;*                  the InitSelfRU as the SNA INITSELF command.             *
  209. ;*                  Preform the necessary translation of the Modename and   *
  210. ;*                  Pluname in the InitSelfRU.                              *
  211. ;*  RETURNS       : Any error is returned in the ax register.               *
  212. ;****************************************************************************
  213. SLI_OPEN        PROC NEAR
  214.  
  215.         ClearVerbRecord  LuaVerb,LuaVerbSize+4            ; Clear Verb Record.
  216.                                                           ; NOTE: No extension
  217.                                                           ; list fields are used.
  218.  
  219.         mov     LuaVerb.lua_verb,LUA_VERB_SLI             ; set verb = '5200'x.
  220.         mov     LuaVerb.lua_verb_length,68                ; set verb length.
  221.         mov     LuaVerb.lua_opcode,LUA_OPCODE_SLI_OPEN    ; set opcode.
  222.  
  223.         mov     di,OFFSET LuaVerb.lua_luname              ; set luname.
  224.         mov     si,OFFSET LU_Name
  225.         mov     cx,LU_NameSize
  226.         rep     movsb
  227.  
  228.         mov     LuaVerb.lua_data_length,25                ; set data length.
  229.         mov     LuaVerb.lua_data_ptr,OFFSET InitSelfRU    ; set data pointer.
  230.         mov     LuaVerb.lua_data_ptr+2,SEG  InitSelfRU
  231.  
  232.         mov     LuaVerb.lua_post_handle,OFFSET UserRamSem ; set posting
  233.         mov     LuaVerb.lua_post_handle+2,SEG  UserRamSem ; semaphore.
  234.  
  235.         mov     LuaVerb_Open.lua_init_type,LUA_INIT_TYPE_SEC_IS ; Set init type
  236.                                                                 ; to InitSelf.
  237.  
  238.         push    SEG    IS_PluName                         ; translate Pluname
  239.         push    OFFSET IS_PluName                         ; from ASCII to EBCDIC.
  240.         push    PluNameSize
  241.         call    NEAR PTR ASCII_EBCDIC
  242.         cmp     ax,0                                      ; Exit SLI_OPEN if
  243.         jne     DoOpenExit                                ; conversion error.
  244.  
  245.         push    SEG    IS_ModeName                        ; translate Modename
  246.         push    OFFSET IS_ModeName                        ; from ASCII to EBCDIC.
  247.         push    ModeNameSize
  248.         call    NEAR PTR ASCII_EBCDIC
  249.         cmp     ax,0                                      ; Exit SLI_OPEN if
  250. DoOpenExit:
  251.         jne     OpenExit                                  ; conversion error.
  252.  
  253.         push    SEG    LuaVerb                            ; Push address of
  254.         push    OFFSET LuaVerb                            ; LuaVerb.
  255.         call    SLI                                       ; Call SLI API.
  256.  
  257.         cmp     LuaVerb.lua_prim_rc,LUA_IN_PROGRESS       ; Check primary rc,
  258.         jne     OpenComplete                              ; if complete don't
  259.                                                           ; wait on semaphore;
  260.  
  261.         @DOSSEMWAIT   UserRamSemAddr,SemTimeout           ; otherwise wait for
  262.                                                           ; completion.
  263.  
  264. OpenComplete:
  265.         cmp     LuaVerb.lua_prim_rc,LUA_OK                ; If successful,
  266.         je      OpenSetSessionID                          ; save session ID;
  267.  
  268.         push    LuaVerb.lua_prim_rc                       ; otherwise, display
  269.         push    LuaVerb.lua_sec_rc+2                      ; error to screen.
  270.         push    LuaVerb.lua_sec_rc
  271.         push    LuaVerb.lua_opcode
  272.         call    NEAR PTR ERROR2
  273.         jmp     OpenSetRC                                 ; and set ax to
  274.                                                           ; error primary rc.
  275.  
  276. OpenSetSessionID:
  277.         mov     ax,LuaVerb.lua_sid                        ; Nove lua_sid into
  278.         mov     dx,LuaVerb.lua_sid+2                      ; local storage for
  279.         mov     LU_SessionID,ax                           ; use by other verbs
  280.         mov     LU_SessionID+2,dx                         ; on this session.
  281.  
  282. OpenSetRC:
  283.         mov     ax,LuaVerb.lua_prim_rc                    ; Set ax to reflect
  284.                                                           ; SLI_OPEN completion.
  285.  
  286. OpenExit:
  287.         ret                                               ; return.
  288.  
  289. SLI_OPEN ENDP
  290.  
  291. ;****************************************************************************
  292. ;*  PROCEDURE NAME: SLI_SEND_DATA                                           *
  293. ;*  FUNCTION      : Send data to the host on LU Normal flow.  Translate the *
  294. ;*                  data to EBCDIC.                                         *
  295. ;*  RETURNS       : Any error is returned in the ax register.               *
  296. ;****************************************************************************
  297. SLI_SEND_DATA   PROC NEAR
  298.  
  299.         ClearVerbRecord  LuaVerb,LuaVerbSize+2            ; Clear Verb Record.
  300.  
  301.         mov     LuaVerb.lua_verb,LUA_VERB_SLI             ; set verb = '5200'x.
  302.         mov     LuaVerb.lua_verb_length,66                ; set verb length.
  303.         mov     LuaVerb.lua_opcode,LUA_OPCODE_SLI_SEND    ; set opcode.
  304.  
  305.         mov     ax,LU_SessionID                           ; set lua_sid with
  306.         mov     dx,LU_SessionID+2                         ; the session ID
  307.         mov     LuaVerb.lua_sid,ax                        ; returned by
  308.         mov     LuaVerb.lua_sid+2,dx                      ; SLI_OPEN.
  309.  
  310.         mov     LuaVerb.lua_data_length,TestDataSize      ; set data length.
  311.         mov     LuaVerb.lua_data_ptr,OFFSET  TestData     ; set data pointer.
  312.         mov     LuaVerb.lua_data_ptr+2,SEG   TestData
  313.  
  314.         mov     LuaVerb.lua_post_handle,OFFSET UserRamSem ; set posting
  315.         mov     LuaVerb.lua_post_handle+2,SEG  UserRamSem ; semaphore.
  316.  
  317.         or      LuaVerb.lua_rh_2,LUA_RH_DR1I              ; set definite rsp.
  318.         or      LuaVerb.lua_rh_2,LUA_RH_RI                ; set exception rsp.
  319.         or      LuaVerb.lua_rh_3,LUA_RH_BBI               ; set begin bracket.
  320.         or      LuaVerb.lua_rh_3,LUA_RH_CDI               ; set change direction.
  321.                                                           ; SLI sets the other
  322.                                                           ; required RH bits.
  323.  
  324.         mov     LuaVerb.lua_message_type,LUA_MESSAGE_TYPE_LU_DATA ; set message
  325.                                                                   ; type.
  326.  
  327.         push    LuaVerb.lua_data_ptr+2                    ; translate data
  328.         push    LuaVerb.lua_data_ptr                      ; from ASCII to EBCDIC.
  329.         push    LuaVerb.lua_data_length
  330.         call    NEAR PTR ASCII_EBCDIC
  331.         cmp     ax,0                                      ; Exit SLI_SEND_DATA
  332.         jne     SendDataExit                              ; if conversion error.
  333.  
  334.         push    SEG    LuaVerb                            ; Push address of
  335.         push    OFFSET LuaVerb                            ; LuaVerb.
  336.         call    SLI                                       ; Call SLI API.
  337.  
  338.         cmp     LuaVerb.lua_prim_rc,LUA_IN_PROGRESS       ; Check primary rc,
  339.         jne     SendDataComplete                          ; if complete don't
  340.                                                           ; wait on semaphore;
  341.  
  342.         @DOSSEMWAIT   UserRamSemAddr,SemTimeout           ; otherwise wait for
  343.                                                           ; completion.
  344. SendDataComplete:
  345.         cmp     LuaVerb.lua_prim_rc,LUA_OK                ; If successful
  346.         je      SendDataSetRC                             ; set procedure rc;
  347.  
  348.         push    LuaVerb.lua_prim_rc                       ; otherwise, display
  349.         push    LuaVerb.lua_sec_rc+2                      ; error to screen
  350.         push    LuaVerb.lua_sec_rc
  351.         push    LuaVerb.lua_opcode
  352.         call    NEAR PTR ERROR2
  353.  
  354. SendDataSetRC:
  355.         mov     ax,LuaVerb.lua_prim_rc                 ; set ax to the SLI_SEND
  356.                                                        ; primary return code.
  357.  
  358. SendDataExit:
  359.         ret
  360.  
  361. SLI_SEND_DATA   ENDP
  362.  
  363. ;****************************************************************************
  364. ;*  PROCEDURE NAME: SLI_RECEIVE                                             *
  365. ;*  FUNCTION      : Receive a message from the host on LU Normal flow into  *
  366. ;*                  DataBuffer. Translate the data from EBCDIC to ASCII.    *
  367. ;*  RETURNS       : Any error is returned in the ax register.               *
  368. ;****************************************************************************
  369. SLI_RECEIVE     PROC NEAR
  370.  
  371.         ClearVerbRecord  LuaVerb,LuaVerbSize              ; Clear Verb Record.
  372.  
  373.         mov     LuaVerb.lua_verb,LUA_VERB_SLI             ; set verb = '5200'x.
  374.         mov     LuaVerb.lua_verb_length,64                ; set verb length.
  375.         mov     LuaVerb.lua_opcode,LUA_OPCODE_SLI_RECEIVE ; set opcode.
  376.  
  377.         mov     ax,LU_SessionID                           ; set lua_sid with
  378.         mov     dx,LU_SessionID+2                         ; the session ID
  379.         mov     LuaVerb.lua_sid,ax                        ; returned by
  380.         mov     LuaVerb.lua_sid+2,dx                      ; SLI_OPEN.
  381.  
  382.         mov     LuaVerb.lua_max_length,DataBufferSize     ; set max receive
  383.                                                           ; length.
  384.         mov     LuaVerb.lua_data_ptr,OFFSET DataBuffer    ; set data pointer.
  385.         mov     luaVerb.lua_data_ptr+2,SEG  DataBuffer
  386.  
  387.         mov     LuaVerb.lua_post_handle,OFFSET UserRamSem ; set posting
  388.         mov     LuaVerb.lua_post_handle+2,SEG  UserRamSem ; semaphore
  389.  
  390.         or      LuaVerb.lua_flag1,LUA_FLAG1_LU_NORM       ; set flow to receive on.
  391.  
  392.         push    SEG    LuaVerb                            ; Push address of
  393.         push    OFFSET LuaVerb                            ; LuaVerb.
  394.         call    SLI                                       ; Call SLI API.
  395.  
  396.         cmp     LuaVerb.lua_prim_rc,LUA_IN_PROGRESS       ; Check primary rc,
  397.         jne     ReceiveComplete                           ; if complete don't
  398.                                                           ; wait on semaphore;
  399.  
  400.         @DOSSEMWAIT   UserRamSemAddr,SemTimeout           ; otherwise wait for
  401.                                                           ; completion.
  402.  
  403. ReceiveComplete:
  404.         cmp     LuaVerb.lua_prim_rc,LUA_OK                ; If successful
  405.         je      ReceiveData                               ; receive data;
  406.  
  407.         push    LuaVerb.lua_prim_rc                       ; otherwise, display
  408.         push    LuaVerb.lua_sec_rc+2                      ; error to screen
  409.         push    LuaVerb.lua_sec_rc
  410.         push    LuaVerb.lua_opcode
  411.         call    NEAR PTR ERROR2
  412.         jmp     ReceiveSetRC                              ; set ax to the SLI_SEND
  413.                                                           ; primary return code.
  414.  
  415. ReceiveData:
  416.         mov     al,LuaVerb.lua_th_snf                     ; save the sequence
  417.         mov     SavedSeqNum,al                            ; number from the
  418.         mov     al,LuaVerb.lua_th_snf+1                   ; request TH for
  419.         mov     SavedSeqNum+1,al                          ; use in the response.
  420.  
  421.         push    LuaVerb.lua_data_ptr+2                    ; convert the data to
  422.         push    LuaVerb.lua_data_ptr                      ; ASCII.
  423.         push    LuaVerb.lua_data_length
  424.         call    NEAR PTR EBCDIC_ASCII
  425.         cmp     ax,0                                      ; exit SLI_RECEIVE
  426.         jne     ReceiveExit                               ; if conversion error.
  427.  
  428. ReceiveSetRC:
  429.         mov     ax,LuaVerb.lua_prim_rc                 ; set ax to the SLI_RECEIVE
  430.                                                        ; primary return code.
  431.  
  432. ReceiveExit:
  433.         ret
  434.  
  435. SLI_RECEIVE     ENDP
  436.  
  437. ;****************************************************************************
  438. ;*  PROCEDURE NAME: SLI_SEND_RESPONSE                                       *
  439. ;*  FUNCTION      : Send positive data response to the host for the LU      *
  440. ;*                  Normal data received.                                   *
  441. ;*  RETURNS       : Any error is returned in the ax register.               *
  442. ;****************************************************************************
  443. SLI_SEND_RESPONSE       PROC NEAR
  444.  
  445.         ClearVerbRecord  LuaVerb,LuaVerbSize+2            ; Clear Verb Record.
  446.  
  447.         mov     LuaVerb.lua_verb,LUA_VERB_SLI             ; set verb = '5200'x.
  448.         mov     LuaVerb.lua_verb_length,66                ; set verb length.
  449.         mov     LuaVerb.lua_opcode,LUA_OPCODE_SLI_SEND    ; set opcode.
  450.  
  451.         mov     ax,LU_SessionID                           ; set lua_sid with
  452.         mov     dx,LU_SessionID+2                         ; the session ID
  453.         mov     LuaVerb.lua_sid,ax                        ; returned by
  454.         mov     LuaVerb.lua_sid+2,dx                      ; SLI_OPEN.
  455.  
  456.         mov     LuaVerb.lua_post_handle,OFFSET UserRamSem ; set posting
  457.         mov     LuaVerb.lua_post_handle+2,SEG  UserRamSem ; semaphore
  458.  
  459.         mov     al,SavedSeqNum                            ; set sequence number
  460.         mov     LuaVerb.lua_th_snf,al                     ; to indicate which
  461.         mov     al, SavedSeqNum+1                         ; message is being
  462.         mov     LuaVerb.lua_th_snf+1,al                   ; responded to.
  463.  
  464.         or      LuaVerb.lua_rh_2,LUA_RH_DR1I              ; set definite response
  465.  
  466.         or      LuaVerb.lua_flag1,LUA_FLAG1_LU_NORM       ; set flow to send
  467.  
  468.         mov     LuaVerb.lua_message_type,LUA_MESSAGE_TYPE_RSP ; set message type
  469.                                                               ; to indicate rsp
  470.  
  471.         push    SEG    LuaVerb                            ; Push address of
  472.         push    OFFSET LuaVerb                            ; LuaVerb.
  473.         call    SLI                                       ; Call SLI API.
  474.  
  475.         cmp     LuaVerb.lua_prim_rc,LUA_IN_PROGRESS       ; Check primary rc,
  476.         jne     SendResponseComplete                      ; if complete don't
  477.                                                           ; wait on semaphore;
  478.  
  479.         @DOSSEMWAIT   UserRamSemAddr,SemTimeout           ; otherwise wait for
  480.                                                           ; completion.
  481.  
  482. SendResponseComplete:
  483.         cmp     LuaVerb.lua_prim_rc,LUA_OK                 ; If successful
  484.         je      SendResponseSetRC                          ; set procedure rc;
  485.  
  486.         push    LuaVerb.lua_prim_rc                        ; otherwise, display
  487.         push    LuaVerb.lua_sec_rc+2                       ; error to screen
  488.         push    LuaVerb.lua_sec_rc
  489.         push    LuaVerb.lua_opcode
  490.         call    NEAR PTR ERROR2
  491.  
  492. SendResponseSetRC:
  493.         mov     ax,LuaVerb.lua_prim_rc                  ; set ax to the SLI_SEND
  494.                                                         ; primary return code.
  495.         ret
  496.  
  497. SLI_SEND_RESPONSE       ENDP
  498.  
  499. ;****************************************************************************
  500. ;*  PROCEDURE NAME: SLI_CLOSE                                               *
  501. ;*  FUNCTION      : Close the session for the LU.  Issue a normal or abend  *
  502. ;*                  close depending upon the passed parameter.              *
  503. ;*  RETURNS       : Any error is returned in the ax register.               *
  504. ;*  PARAMETERS    : The passed indicator will be at [bp+4]                  *
  505. ;****************************************************************************
  506. SLI_CLOSE       PROC NEAR
  507.         enter    0,0                                       ; set bp for stack
  508.                                                            ; referencing.
  509.  
  510.         ClearVerbRecord  LuaVerb,LuaVerbSize               ; Clear Verb Record.
  511.  
  512.         mov     LuaVerb.lua_verb,LUA_VERB_SLI              ; set verb = '5200'x.
  513.         mov     LuaVerb.lua_verb_length,64                 ; set verb length.
  514.         mov     LuaVerb.lua_opcode,LUA_OPCODE_SLI_CLOSE    ; set opcode.
  515.  
  516.         mov     ax,LU_SessionID                            ; set lua_sid with
  517.         mov     dx,LU_SessionID+2                          ; the session ID
  518.         mov     LuaVerb.lua_sid,ax                         ; returned by
  519.         mov     LuaVerb.lua_sid+2,dx                       ; SLI_OPEN.
  520.  
  521.         mov     LuaVerb.lua_post_handle,OFFSET UserRamSem  ; set posting
  522.         mov     LuaVerb.lua_post_handle+2,SEG  UserRamSem  ; semaphore.
  523.  
  524.         mov     al,BYTE PTR [bp+4]                         ; set lua_flag1
  525.         or      LuaVerb.lua_flag1,al                       ; with the passed
  526.                                                            ; indicator.
  527.  
  528.         push    SEG    LuaVerb                             ; Push address of
  529.         push    OFFSET LuaVerb                             ; LuaVerb.
  530.         call    SLI                                        ; Call SLI API.
  531.  
  532.         cmp     LuaVerb.lua_prim_rc,LUA_IN_PROGRESS        ; Check primary rc,
  533.         jne     CloseComplete                              ; if complete don't
  534.                                                            ; wait on semaphore;
  535.  
  536.         @DOSSEMWAIT   UserRamSemAddr,SemTimeout            ; otherwise wait for
  537.                                                            ; completion.
  538. CloseComplete:
  539.         cmp     LuaVerb.lua_prim_rc,LUA_OK                 ; If successful
  540.         je      CloseSetRC                                 ; set procedure rc;
  541.  
  542.         push    LuaVerb.lua_prim_rc                        ; otherwise, display
  543.         push    LuaVerb.lua_sec_rc+2                       ; error to screen
  544.         push    LuaVerb.lua_sec_rc
  545.         push    LuaVerb.lua_opcode
  546.         call    NEAR PTR ERROR2
  547.  
  548. CloseSetRC:
  549.         mov     ax,WORD PTR LuaVerb.lua_prim_rc          ; set ax to the SLI_CLOSE
  550.                                                          ; primary return code.
  551.         leave
  552.         ret     2
  553.  
  554. SLI_CLOSE       ENDP
  555.  
  556. ;****************************************************************************
  557. ;*  PROCEDURE NAME: ASCII_EBCDIC                                            *
  558. ;*  FUNCTION      : Use the Convert service verb to convert selected data   *
  559. ;*                  from ASCII to EBCDIC.                                   *                                        *
  560. ;*  RETURNS       : Any error is returned in the ax register.               *
  561. ;*  PARAMETERS    : The data length will be at [bp+4].                      *
  562. ;*                : The data pointer will be at [bp+6].                     *
  563. ;****************************************************************************
  564. ASCII_EBCDIC    PROC NEAR
  565.         enter      0,0                                       ; set bp for stack
  566.                                                              ; referencing.
  567.  
  568.         mov     ConvertVerb.opcode_cvt,SV_CONVERT            ; set opcode.
  569.         mov     ConvertVerb.direction_cvt,SV_ASCII_TO_EBCDIC ; set direction.
  570.         mov     ConvertVerb.char_set_cvt,SV_AE               ; set char sets.
  571.  
  572.         mov     ax,[bp+4]      ;len
  573.         mov     ConvertVerb.len_cvt,ax                       ; set data length.
  574.  
  575.         mov     ax,[bp+6]      ;ptr                          ; set source
  576.         mov     dx,[bp+8]                                    ; pointer.
  577.         mov     WORD PTR ConvertVerb.src_ptr_cvt,ax
  578.         mov     WORD PTR ConvertVerb.src_ptr_cvt+2,dx
  579.  
  580.         mov     WORD PTR ConvertVerb.targ_ptr_cvt,ax         ; set destination
  581.         mov     WORD PTR ConvertVerb.targ_ptr_cvt+2,dx       ; pointer.
  582.  
  583.         push    SEG    ConvertVerb                           ; issue the
  584.         push    OFFSET ConvertVerb                           ; convert verb.
  585.         call    FAR PTR ACSSVC
  586.  
  587.         cmp     ConvertVerb.primary_rc_cvt,0                 ; check primary rc
  588.         je      AsciiEbcdicExit                              ; exit if ok
  589.  
  590.         push    ConvertVerb.primary_rc_cvt                   ; otherwise
  591.         push    WORD PTR ConvertVerb.secondary_rc_cvt+2      ; call error
  592.         push    WORD PTR ConvertVerb.secondary_rc_cvt        ; routine
  593.         call    NEAR PTR ERROR1
  594.  
  595. AsciiEbcdicExit:
  596.         mov     ax,WORD PTR ConvertVerb.primary_rc_cvt       ; set ax
  597.         leave
  598.         ret     6
  599.  
  600. ASCII_EBCDIC    ENDP
  601.  
  602. ;****************************************************************************
  603. ;*  PROCEDURE NAME: EBCDIC_ASCII                                            *
  604. ;*  FUNCTION      : Use the Convert service verb to convert selected data   *
  605. ;*                  from EBCDIC to ASCII.                                   *                                        *
  606. ;*  RETURNS       : Any error is returned in the ax register.               *
  607. ;*  PARAMETERS    : The data length will be at [bp+4].                      *
  608. ;*                : The data pointer will be at [bp+6].                     *
  609. ;****************************************************************************
  610. EBCDIC_ASCII    PROC NEAR
  611.         enter     0,0                                        ; set bp for stack
  612.                                                              ; referencing.
  613.  
  614.         mov     ConvertVerb.opcode_cvt,SV_CONVERT            ; set opcode.
  615.         mov     ConvertVerb.direction_cvt,SV_EBCDIC_TO_ASCII ; set direction.
  616.         mov     ConvertVerb.char_set_cvt,SV_AE               ; set char sets.
  617.  
  618.         mov     ax,[bp+4]      ;len
  619.         mov     ConvertVerb.len_cvt,ax                       ; set data length.
  620.  
  621.         mov     ax,[bp+6]      ;ptr                          ; set source
  622.         mov     dx,[bp+8]                                    ; pointer.
  623.         mov     WORD PTR ConvertVerb.src_ptr_cvt,ax
  624.         mov     WORD PTR ConvertVerb.src_ptr_cvt+2,dx
  625.  
  626.         mov     WORD PTR ConvertVerb.targ_ptr_cvt,ax         ; set destination
  627.         mov     WORD PTR ConvertVerb.targ_ptr_cvt+2,dx       ; pointer.
  628.  
  629.         push    SEG    ConvertVerb                           ; issue the
  630.         push    OFFSET ConvertVerb                           ; convert verb.
  631.         call    FAR PTR ACSSVC
  632.  
  633.         cmp     ConvertVerb.primary_rc_cvt,0                 ; check primary rc
  634.         je      EbcdicAsciiExit                              ; exit if ok
  635.  
  636.         push    ConvertVerb.primary_rc_cvt                   ; otherwise
  637.         push    WORD PTR ConvertVerb.secondary_rc_cvt+2      ; call error
  638.         push    WORD PTR ConvertVerb.secondary_rc_cvt        ; routine
  639.         call    NEAR PTR ERROR1
  640.  
  641. EbcdicAsciiExit:
  642.         mov     ax,WORD PTR ConvertVerb.primary_rc_cvt       ; set ax
  643.         leave
  644.         ret     6
  645.  
  646. EBCDIC_ASCII    ENDP
  647.  
  648. ;****************************************************************************
  649. ;*  PROCEDURE NAME: ERROR1                                                  *
  650. ;*  FUNCTION      : Display return codes for conversion errors.             *
  651. ;*  PARAMETERS    : The secondary return code will be at [bp+4].            *
  652. ;*                : The primary return code will be at [bp+8].              *
  653. ;****************************************************************************
  654. ERROR1  PROC NEAR
  655.         enter     0,0                                     ; set bp for stack
  656.                                                           ; referencing.
  657.         @VIOWRTTTY  Error2_Message,Error2_MessageSize,0
  658.  
  659.         @VIOWRTTTY  PrimRC_Message,PrimRC_MessageSize,0
  660.  
  661.         lea     ax,WORD PTR [bp+8]                        ; Call PRTHEX to
  662.         push    ss                                        ; display the primary
  663.         push    ax                                        ; return code.
  664.         push    2
  665.         call    NEAR PTR PRTHEX
  666.  
  667.         @VIOWRTTTY  SecRC_Message,SecRC_MessageSize,0
  668.  
  669.         lea     ax,WORD PTR [bp+4]                        ; Call PRTHEX to
  670.         push    ss                                        ; display the secondary
  671.         push    ax                                        ; return code.
  672.         push    4
  673.         call    NEAR PTR PRTHEX
  674.  
  675.         leave
  676.         ret     6
  677.  
  678. ERROR1  ENDP
  679.  
  680. ;****************************************************************************
  681. ;*  PROCEDURE NAME: ERROR2                                                  *
  682. ;*  FUNCTION      : Display return codes for unsuccessful SLI API calls.    *
  683. ;*  PARAMETERS    : The verb opcode will be at [bp+4].                      *
  684. ;*                : The secondary return code will be at [bp+6].            *
  685. ;*                : The primary return code will be at [bp+10].             *
  686. ;****************************************************************************
  687. ERROR2  PROC NEAR
  688.         enter     0,0                                     ; set bp for stack
  689.                                                           ; referencing.
  690.         @VIOWRTTTY  Error3_Message,Error3_MessageSize,0
  691.  
  692.         lea     ax,WORD PTR [bp+4]                        ; Call PRTHEX to
  693.         push    ss                                        ; display the opcode.
  694.         push    ax
  695.         push    2
  696.         call    NEAR PTR PRTHEX
  697.  
  698.         @VIOWRTTTY  PrimRC_Message,PrimRC_MessageSize,0
  699.  
  700.         lea     ax,WORD PTR [bp+10]                       ; Call PRTHEX to
  701.         push    ss                                        ; display the primary
  702.         push    ax                                        ; return code.
  703.         push    2
  704.         call    NEAR PTR PRTHEX
  705.  
  706.         @VIOWRTTTY  SecRC_Message,SecRC_MessageSize,0
  707.  
  708.         lea     ax,WORD PTR [bp+6]                        ; Call PRTHEX to
  709.         push    ss                                        ; display the secondary
  710.         push    ax                                        ; return code.
  711.         push    4
  712.         call    NEAR PTR PRTHEX
  713.  
  714.         leave
  715.         ret     8
  716.  
  717. ERROR2  ENDP
  718.  
  719. ;****************************************************************************
  720. ;*  PROCEDURE NAME: PRTHEX                                                  *
  721. ;*  FUNCTION      : Convert Hex to string and output it to the screen.      *
  722. ;*  PARAMETERS    : The hex length will be at [bp+4].                       *
  723. ;*                : The hex data pointer will be at [bp+6].                 *
  724. ;****************************************************************************
  725. PRTHEX  PROC NEAR
  726.         enter     0,0                                     ; set bp for stack
  727.                                                           ; referencing.
  728.         push    ds                                        ; Save segment
  729.         push    es                                        ; registers.
  730.         cld                                               ; Clear direction flag.
  731.  
  732.         mov     si,WORD PTR [bp+6]                        ; Set ds:si to source
  733.         mov     ax,WORD PTR [bp+8]                        ; hex data.
  734.         mov     ds,ax
  735.  
  736.         mov     di,OFFSET HexBuffer                       ; Set es:di to string
  737.         mov     ax,SEG    HexBuffer                       ; output buffer.
  738.         mov     es,ax
  739.  
  740.         mov     cx,[bp+4]                                 ; Set loop counter.
  741.         mov     HexBufferFilledSize,cx                    ; Set string length
  742.         shl     HexBufferFilledSize,1                     ; to double hex data
  743.                                                           ; size.
  744.  
  745.         mov     dx,SEG     DigitTable                     ; Get pointer to
  746.         mov     bx,OFFSET  DigitTable                     ; translation table
  747.  
  748. TopOfLoop:
  749.         lodsb                                             ; Load next byte.
  750.         push    cx
  751.         push    ax
  752.         and     al,0F0h                                   ; Get high order digit.
  753.         mov     cl,4
  754.         shr     al,cl
  755.         push    bx
  756.         add     bx,ax                                     ; Set table offset
  757.         push    ds
  758.         mov     ds,dx
  759.         mov     al,[bx]                                   ; Move character to ax
  760.         pop     ds
  761.         pop     bx
  762.         stosb                                             ; Store character in
  763.                                                           ; string
  764.                                                           ; Load next byte.
  765.         pop     ax                                        ; Get low order digit.
  766.         and     al,0Fh
  767.         push    bx
  768.         add     bx,ax                                     ; Set table offset.
  769.         push    ds
  770.         mov     ds,dx
  771.         mov     al,[bx]                                   ; Move character to ax.
  772.         pop     ds
  773.         pop     bx
  774.         stosb                                             ; Store character in
  775.                                                           ; string.
  776.         pop     cx
  777.         loop    TopOfLoop                                 ; Loop
  778.  
  779.         @VIOWRTTTY  HexBuffer,HexBufferFilledSize,0       ; Display HexBuffer
  780.  
  781.         pop     es                                        ; Restore registers
  782.         pop     ds
  783.         leave
  784.         ret     6
  785.  
  786. PRTHEX  ENDP
  787. CODE            ENDS
  788.                 END  main
  789.