home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / mumps / zctest.asm < prev    next >
Assembly Source File  |  1996-07-22  |  5KB  |  209 lines

  1. retf    macro        ;this source code has been assembled with Microsoft
  2.     db    0cbh    ;Macro assembler ver 3 which does not support a far
  3.     endm        ;return instruction. So use this macro to provide the
  4.             ;required instruction.
  5.  
  6. code    segment    byte public 'code'
  7.     assume  cs:code, ds:code, es:code, ss:code
  8.  
  9.     jmp    my_code
  10. cback    dd    0
  11. bsiz    dw    offset stk_siz - $ - 5
  12. t_len    dw    0
  13. cnt    db    0
  14. buf    DB    80H DUP(0)
  15. stk_siz    dw    0
  16. pntr    dw    0
  17. pbuf    DB    80h DUP(0)
  18. noparam    db    'none',0dh,0ah,'$'
  19. newl    db    0dh,0ah,'$'
  20. pos    db    13,10,9,9,9,9,'$'
  21. anull    db    'null parameter',0dh,0ah,'$'
  22. SIGNON    DB    0dh,0ah,0ah
  23.     db    9,'--- assembly routine to test call-back functions ---',13,10
  24.     db    'passed parameters:',13,10,'$'
  25. scrn1    db    13,10,10,'Call-Back Options:',9,'<ESC> to quit',13,10
  26.     db    9,9,9,'<0> set glvn or settable function',13,10
  27.     db    9,9,9,'<1> fetch glvn or dollar function',13,10
  28.     DB    9,9,9,'<2> kill glvn',13,10,10
  29.     db    9,9,9,'    choice ? $'
  30. name_buf DB    256 DUP(0)
  31. value_buf DB    256 DUP(0)
  32. kill_q    db    13,10,10,'kill which cariable NAME ? $'
  33. fetch_q db    13,10,10,'fetch what variable NAME ? $'
  34. name_q     db    13,10,10,'NAME of variable to set: $'
  35. value_q     db    13,10,'VALUE for this variable: $'
  36. badnm    db    7,'illegal variable name',13,10,'$'
  37. notfnd    db    'var not found',13,10,'$'
  38. my_code:
  39.     mov    ah,9
  40.     lea    dx,signon
  41.     int    21h
  42.     cmp    cnt,0        ;any parameters ?
  43.     jz    none        ;no
  44.     lea    bx,buf        ;move to length byte of first param
  45.     mov    pntr,bx        ;pntr always points to length byte of a param
  46. loop:    cmp    cnt,0        ;is count down to 0 ?
  47.     jz    pdone        ;yes
  48.     mov    bx,pntr        ;no, get pointer to size byte 
  49.     mov    cl,[bx]        ;get size
  50.     mov    ch,0        ;extend to 16 bits
  51.     cmp    cx,0        ;is it null?
  52.     jnz    LP1        ;yes    
  53.     jmp    null
  54. LP1:    mov    si,bx
  55.     inc    si        ;source
  56.     add    bx,cx        ;point to next size field
  57.     inc    bx
  58.     mov    pntr,bx        ;  & save
  59.     mov    di, offset pbuf
  60.     rep    movsb
  61.     mov    byte ptr [di],'$'
  62.     mov    ah,9
  63.     mov    dx, offset pbuf
  64.     int    21h
  65.     call    crlf    
  66.     dec    cnt
  67.     jmp    loop
  68. none:    mov    ah,9
  69.     lea    dx,noparam
  70.     int    21h
  71. pdone:    jmp    menu
  72. ;
  73. menu:    mov    ah,9
  74.     lea    dx, scrn1
  75.     int    21h
  76. menulp:    mov    ah,6
  77.     mov    dl,0ffh
  78.     int    21h        ;get one char reply    
  79.     cmp    al,0
  80.     jz    menulp
  81.     cmp    al,'2'        ;call back 'kill'
  82.     jz    kill
  83.     cmp    al,'1'        
  84.     jz    fetch        ;call back 'fetch'
  85.     cmp    al,'0'
  86.     jnz    m1
  87.     jmp    set        ;call back 'set'
  88. m1:    cmp    al,1bh        ;esc?
  89.     jnz    menulp        ;no
  90.     retf            ;yes, back to mumps
  91.  
  92. kill:    mov    ah,9
  93.     lea    dx,kill_q
  94.     int    21h        ;'what var?' prompt
  95.     mov    ah,10
  96.     lea    dx,name_buf
  97.     mov    di,dx
  98.     mov    byte ptr [di],255    ;buf size
  99.     int    21h        ;get reply
  100.     lea    dx,name_buf    
  101.     inc    dx        ;look at size of reply
  102.     mov    di,dx
  103.     cmp    byte ptr[di],0    
  104.     jz    menu        ;no reply
  105.     mov    cl,2        ;call_back 'kill' fucn #
  106.     call dword ptr cs:cback
  107.     cmp    al,0        ;was mumps successful ?
  108.     jz    menu        ;yes
  109.     mov    ah,9        ;no, tell someone
  110.     lea    dx,badnm
  111.     int    21h
  112.     jmp     menu
  113.  
  114.  
  115. fetch:    mov    ah,9
  116.     lea    dx,fetch_q
  117.     int    21h        ;'what var?' prompt
  118.     mov    ah,10
  119.     lea    dx,name_buf
  120.     mov    di,dx
  121.     mov    byte ptr [di],255    ;buf size
  122.     int    21h        ;get reply
  123.     lea    dx,name_buf    
  124.     inc    dx        ;look at size of reply
  125.     mov    di,dx
  126.     cmp    byte ptr[di],0    
  127.     jnz    f1        ;no reply
  128.     jmp    menu
  129. f1:    mov    cl,1        ;call_back 'fetch' fucn #
  130.     call dword ptr cs:cback
  131.     cmp    al,0        ;was mumps successful ?
  132.     jz    good_fetch        ;yes
  133.     cmp    al,0feh        ;no, was error 'bad name'
  134.     jnz    fetch1 
  135.     call     tab
  136.     mov    ah,9
  137.     lea    dx,badnm
  138.     int    21h
  139.     jmp     menu
  140. fetch1: call    tab
  141.     mov    ah,9
  142.     lea    dx,notfnd
  143.     int    21h
  144.     jmp    menu
  145. good_fetch:    ;byte length + string is in buffer. Put '$' @end & print it
  146.     call    tab
  147.     lea    di,buf        ;point to length
  148.     mov    ch,0
  149.     mov    cl,[di]        ;get length
  150.     inc    di        ;1st string byte
  151.     mov    dx,di        ;start printing here
  152.     add    di,cx
  153.     mov    byte ptr[di],'$';mark end
  154.     mov    ah,9
  155.     int    21h
  156.     call    crlf
  157.     jmp    menu
  158. ;
  159. set:    ;set a mumps glvn or settable function
  160.     mov    ah,9
  161.     lea    dx, name_q
  162.     int    21h
  163.     mov    ah,10
  164.     lea    dx,name_buf
  165.     mov    di,dx
  166.     mov    byte ptr [di],255    ;buffer size
  167.     int    21h        ;input name of variable
  168.     lea    dx,name_buf    
  169.     inc    dx        ;look at size
  170.     mov    di,dx
  171.     cmp    byte ptr[di],0    
  172.     jz    set_quit    ;null string, quit
  173.     mov    ah,9
  174.     lea    dx, value_q
  175.     int    21h
  176.     mov    ah,10
  177.     lea    dx,value_buf
  178.     mov    di,dx
  179.     mov    byte ptr [di],255    ;buffer size
  180.     int    21h        ;input the value for the variable
  181.     lea    dx, name_buf+1
  182.     lea    bx, value_buf+1
  183.     mov    cl,0        ;set function
  184.     call dword ptr cs:cback
  185.     jmp    menu
  186. set_quit:
  187.     mov    ax,0
  188.     retf
  189. ;
  190. ;
  191. tab:    mov    ah,9
  192.     lea    dx,pos
  193.     int    21h
  194.     ret
  195. crlf:    mov    ah,9
  196.     mov    dx, offset newl
  197.     int    21h
  198.     ret
  199. null:    inc    pntr    ;next byte is also a size byte cause this one null
  200.     dec    cnt
  201.     mov    ah,9
  202.     mov    dx, offset anull
  203.     int    21h
  204.     jmp    loop
  205.  
  206. code    ends
  207. end
  208. OBJ CQ[ HgCONFIG  SYS `Ç¥
  209. └RECT    ASM K