home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols200 / vol223 / wysefk21.asm < prev   
Encoding:
Assembly Source File  |  1994-07-13  |  8.4 KB  |  288 lines

  1.     
  2. *************************************************************************
  3. *                                    *
  4. *  FK.ASM   Version 2.1        Function Key programmer            *
  5. *  2 August 1984                            *
  6. *                                    *
  7. *  by: Charlie Hoffman                            *
  8. *                                    *
  9. *  modifications by Joe Griffith                    *
  10. *  16 August 1984                            *
  11. *  - Added parameter passing so that multiple sets of commands could    *
  12. *    be programmed into the function keys                *
  13. *  - Changed output routine to use BDOS function 2 to enable $        *
  14. *  - Reformatted program to make room for 16 function key entries    *
  15. *  - Set F16 to 'F' for use with resident command package        *
  16. *                                    *
  17. *     The purpose of this program is to provide initialization for    *
  18. * the WYSE 50 HOST MESSAGE LINE and to program the FUNCTION KEYS as    *
  19. * well as the FUNCTION KEY LINE.  IT also sets the atributes of these    *
  20. * lines as well as the LOCAL MESSAGE FIELD to dim.            *
  21. *                                    *
  22. *************************************************************************
  23.  
  24. ; -- Equates --
  25.  
  26. bdos    equ    5        ;CP/M BDOS jump address
  27. tpa    equ    100h        ;CP/M transient program area address
  28. conout    equ    2        ;CP/M bdos print character function
  29. param    equ    80h        ;location of parameter from command line
  30. numsets    equ    5        ;total number of function key sets 
  31.  
  32. cr    equ    0Dh        ;carriage return
  33. lf    equ    0Ah        ;line feed
  34. bell    equ    7        ;ascii bell
  35. esc    equ    1Bh        ;escape
  36. del    equ    7Fh        ;delete
  37.  
  38. ;------------------------------------------------------------------
  39.  
  40.     org    tpa        ;standard CP/M location
  41.  
  42. start:    lxi    h,0        ;save CP/M's stack by adding it
  43.     dad    sp        ;to the stack pointer and
  44.     shld    cpmstk        ;storing it in a safe place
  45.     lxi    sp,stack+100    ;to generate a new stack for use
  46.                 ;by this program
  47.  
  48. ;------------------------------------------------------------------
  49.  
  50.     mvi    a,numsets+1    ;store the total number of sets in
  51.     sta    sets        ;a convenient place (inc'd for logic)c
  52.  
  53. ;------------------------------------------------------------------ 
  54.  
  55.     lxi    h,msg0        ;get address of initialization msg
  56.     call    print        ;send it
  57.  
  58. ;-----------------------------------------------------------------
  59.  
  60.     lda    param        ;get size of parameter
  61.     ora    a        ;check the flag and see if there even
  62.     jz    default        ;is a parameter
  63.     dcr    a        ;get size of parameter
  64.     jz    default        ;must have been a space only
  65.  
  66. which:    lda    sets        ;get number of sets left to check
  67.     dcr    a        ;countdown for real number
  68.     jz    error        ;parameter is not a legal one
  69.     sta    sets        ;store remaining number of sets
  70.     add    a        ;multiply by 2 for wordoffset
  71.     mov    e,a        ;put offset in e for pointer
  72.     mvi    d,0        ;zero out the rest of the pointer
  73.     lxi    h,setbl        ;get address of table
  74.       dad    d        ;add the offset to it.
  75.     mov    e,m        ;move low order byte of setname
  76.     inx    h        ;bumb the pointer for the high order byte
  77.     mov    d,m        ;DE now points to correct name. 
  78.     xchg            ;put it all in the 'M' pointer
  79.     lxi    b,param+2    ;get address of first char of parameter
  80.  
  81. compar:    ldax    b        ;get character of parameter
  82.     ora    a        ;check for end of parameter and 
  83.     jz    match        ;if match then go for it, else
  84.     mov    e,m        ;get character of setname
  85.     cmp    e        ;do they match?
  86.     jnz    which        ;no, then try next set
  87.     inx    h        ;else bump the pointers
  88.     inx    b        ;to the next character
  89.     jmp    compar        ;and try again
  90.  
  91. match:    lda    sets        ;get number of set that matched
  92.     add    a        ;multiply it by two
  93.     mov    e,a        ;store it as the offset in the DE
  94.     mvi    d,0        ;register
  95.     lxi    h,msgtbl    ;get the address of the message table
  96.     dad    d        ;add the offset and we're ready to print
  97.     mov    e,m        ;move low order byte of message address
  98.     inx    h        ;bump the pointer for the high byte
  99.     mov    d,m        ;get the other half of the address
  100.     xchg            ;put the address of the message in HL
  101.  
  102. cont:    call    print
  103.  
  104.  
  105. theend:    lhld    cpmstk        ;get the old stack back
  106.     sphl            ;switch it into the stack pointer
  107.     ret            ;return to CP/M
  108.  
  109. ;-----------------------------------------------------------------------
  110.  
  111. print:    push    h        ;and save it.
  112.     mov    a,m        ;get the next character
  113.     ani    80h        ;check for most significant bit set
  114.     jnz    print1        ;if so then you are done
  115.     mov    e,m        ;else get ready to print it
  116.     mvi    c,conout    ;load bdos function
  117.     call    bdos        ;print the message
  118.     pop    h        ;restore message pointer
  119.     inx    h        ;move to next character and
  120.     jmp    print        ;repeat
  121.  
  122. print1    pop    h        ;fix the stack
  123.     ret
  124.  
  125. ;-------------------------------------------------------------------
  126.  
  127. default    lxi    h,msg1        ;get address of standard message
  128.     jmp    cont
  129.  
  130. ;-------------------------------------------------------------------
  131.  
  132. error:    lxi    h,errmsg    ;get address of error message
  133.     jmp    cont        ;print it and done
  134.  
  135. errmsg:    db    'Invalid Parameter'
  136.     db    80h
  137.  
  138. ;------------------------------------------------------------------
  139.  
  140. setbl:    dw    0        ;dummy address
  141.     dw    set1
  142.     dw    set2
  143.     dw    set3
  144.     dw    set4
  145.     dw    set5        ;etc for more sets
  146.  
  147. ;-------------------------------------------------------------------
  148.  
  149. msgtbl:    dw    0        ;dummy address
  150.     dw    msg1
  151.     dw    msg2
  152.     dw    msg3
  153.     dw    msg4
  154.     dw    msg5        ;etc for more sets
  155.  
  156. ;-------------------------------------------------------------------
  157.  
  158. cpmstk:    dw    0        ;storage of CP/M stack
  159. sets:    ds    1        ;storage of number of sets in system
  160.  
  161. ;-------------------------------------------------------------------
  162.  
  163. msg0:    DB    ESC,'A1p',CR        ;SET FUNCTION KEY LINE TO DIM
  164.     DB    ESC,'A2p',CR        ;SET LOCAL MESSAGE LINE TO DIM
  165.     DB    ESC,'A3p',CR        ;SET HOST MESSAGE LINE TO DIM
  166.  
  167.     DB    ESC,'F'            ;ENTERS MESSAGE INTO THE HOST
  168. ;    DB    'ZCPR3 version  1.0 '    ;MESSAGE FIELD 
  169. ;    DB    'dated July 20',2CH,' 1984'
  170.     DB    CR,LF,80h
  171.  
  172. ;--------------------------------------------------------------------
  173.  
  174. set1:    db    'SYS',0            ;name of first set
  175.  
  176. msg1:    db    ESC,'z01=MBASIC',CR    ;label for 1
  177.     db    ESC,'z@MBASIC',CR,DEL    ;code for 1
  178.  
  179.     db    ESC,'z12=MEX',CR    ;label for 2
  180.     db    ESC,'zAMEX',CR,DEL    ;code for 2
  181.  
  182.     db    ESC,'z23=NS',CR        ;label for 3
  183.     db    ESC,'zBNS',CR,DEL    ;code for 3
  184.  
  185.     db    ESC,'z34=SYSTEM',CR    ;label for 4
  186.     db    ESC,'zCSYSTEM',CR,DEL    ;code for 4
  187.  
  188.     db    ESC,'z45=WS',CR        ;label for 5
  189.     db    ESC,'zDWS',CR,DEL    ;code for 5
  190.  
  191.     db    ESC,'z56=SD $A',CR    ;label for 6
  192.     db    ESC,'zESD $A',CR,DEL    ;code for 6
  193.  
  194.     db    ESC,'z67=$PZ SZ',CR    ;label for 7
  195.     db    ESC,'zF $PZ SZ',CR,DEL    ;code for 7
  196.  
  197.     db    ESC,'z78=*.*',CR    ;Label for 8
  198.     db    ESC,'zG*.*',CR,DEL    ;code for 8
  199.  
  200.     db    ESC,'zH',0Ah,'1',DEL    ;code for 9
  201.     db    ESC,'zI',0Ah,'2',DEL    ;code for 10
  202.     db    ESC,'zJ',0Ah,'3',DEL    ;code for 11
  203.     db    ESC,'zK',0Ah,'E',DEL    ;code for 12
  204.     db    ESC,'zL',0Ah,'S',DEL    ;code for 13
  205.     db    ESC,'zM',0Ah,'U',DEL    ;code for 14
  206.     db    ESC,'zN',0Ah,'T',DEL    ;code for 15
  207.     db    ESC,'zOF',CR,DEL    ;code for 16
  208.  
  209.     db    80h            ;end of the line (1)
  210.  
  211. ;--------------------------------------------------------------------
  212.  
  213. set2:    db    'WS',0            ;name of second set
  214.  
  215. msg2:    db    ESC,'z01=Begin',CR    ;lable for 1
  216.     db    ESC,'z@',0Bh,'B',DEL    ;code for 1
  217.  
  218.     db    ESC,'z12=End',CR    ;lable for 2
  219.     db    ESC,'zA',0Bh,'K',DEL    ;code for 2
  220.  
  221.     db    ESC,'z23=Move',CR    ;lable for 3
  222.     db    ESC,'zB',0Bh,'V',DEL    ;code for 3
  223.  
  224.     db    ESC,'z34=Hide',CR    ;label for 4
  225.     db    ESC,'zC',0Bh,'H',DEL    ;code for 4
  226.  
  227.     db    ESC,'z45=      ',CR    ;label for 5
  228.     db    ESC,'zD',DEL        ;code for 5
  229.  
  230.     db    ESC,'z56=      ',CR    ;label for 6
  231.     db    ESC,'zE',DEL        ;code for 6
  232.  
  233.     db    ESC,'z67=      ',CR    ;label for 7
  234.     db    ESC,'zF',DEL        ;code for 7
  235.  
  236.     db    ESC,'z78=      ',CR    ;label for 8
  237.     db    ESC,'zG',DEL        ;code for 8
  238.  
  239.     db    ESC,'zH',DEL        ;code for 9
  240.     db    ESC,'zI',DEL        ;code for 10
  241.     db    ESC,'zJ',DEL        ;code for 11
  242.     db    ESC,'zK',DEL        ;code for 12
  243.     db    ESC,'zL',DEL        ;code for 13
  244.     db    ESC,'zM',DEL        ;code for 14
  245.     db    ESC,'zN',DEL        ;code for 15
  246.     db    ESC,'zO',DEL        ;code for 16
  247.  
  248.     db    80h            ;end of the line (2)
  249.  
  250. ;--------------------------------------------------------------------
  251.  
  252. set3:    db    'NAME3',0        ;name of third set
  253.  
  254. msg3:    db    ESC,'z01=THREE',CR    ;label for 1
  255.     db    ESC,'z@THREE',CR,DEL    ;code for 1
  256.  
  257.     db    80h
  258.  
  259. ;-------------------------------------------------------------------
  260.  
  261. set4:    db    'NAME4',0        ;name of fourth set
  262.  
  263. msg4:    db    ESC,'z01=FOUR',CR    ;label for 1
  264.     db    ESC,'z@FOUR',CR,DEL    ;code for 1
  265.  
  266.     db    80h
  267.  
  268. ;--------------------------------------------------------------------
  269.  
  270. set5:    db    '//',0            ;name of fifth set
  271.  
  272. msg5:    db    'Wyse-50 Function Key Initialization',CR,LF,CR,LF
  273.     db    'Format:  FK          no parameters defaults to set 1.',CR,LF
  274.     db    '         FK WS       uses set labeled "WS".',CR,LF
  275.     db    '         FK #o6S     invalid parameter prints error msg.',CR,LF
  276.     db    '         FK //       prints this message.',CR,LF
  277.  
  278.     db    80h
  279.  
  280. ;---------------------------------------------------------------------
  281.  
  282. stack:    ds    100        ;memory is cheap
  283.  
  284.     end
  285.  
  286. ;**********************************************************************
  287.  
  288.