home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / ASM / GRDBDL17.ZIP / ENTRY.ASM < prev    next >
Encoding:
Assembly Source File  |  1998-10-26  |  3.8 KB  |  207 lines

  1. ;
  2. ; GRDP
  3. ;
  4. ; Copyright(c) LADsoft
  5. ;
  6. ; David Lindauer, camille@bluegrass.net
  7. ;
  8. ;
  9. ; Entry.asm
  10. ;
  11. ; Function: handle hex data entry
  12. ;
  13.     ;MASM MODE
  14.     .model small
  15.     .386
  16.  
  17.  
  18. include  eprints.inc 
  19. include  einput.inc 
  20. include  emtrap.inc 
  21. include eoptions.inc
  22.  
  23.     PUBLIC    entry
  24.  
  25.     .data
  26. InsideQuote    db    0    ;flag if we're inside a quote
  27.  
  28.     .code
  29. ;
  30. ; Input function for a number
  31. ;
  32. InputNumber    PROC    
  33.     mov    [InsideQuote],0
  34.     push    dx
  35.     push    cx
  36.     push    bx
  37.     sub    cx,cx         ; Number of digits = 0
  38.     sub    bx,bx            ; Data = 0
  39. lp:
  40.     call    GetKey
  41.     mov    ah,al            ; AH = data
  42.     cmp    al,' '            ; Space, data is complete
  43.     jz    space        ;
  44.     cmp    al,13            ;
  45.     jz    isenter        ; ENTER = quit entering data
  46.     cmp    al,8            ; BACKSPACE or RUBOUT, handle it
  47.     jz    bckspc        ;
  48.     cmp    al,7fh            ;
  49.     jz    bckspc        ;
  50.     cmp    al,'"'
  51.     jz    quote
  52.     cmp    al,"'"
  53.     jz    quote
  54.     test    [InsideQuote],1
  55.     jnz    isquote
  56.     cmp    al,60h
  57.     jc    notlower
  58.     and    al,NOT 20h
  59. notlower:
  60.     sub    al,'0'            ; Convert to binary, ignore if not valid
  61.     jc    lp            ;
  62.     cmp    al,10            ;
  63.     jc    gotdigit        ;
  64.     sub    al,7            ;
  65.     cmp    al,10            ;
  66.     jc    lp            ;
  67.     cmp    al,16            ;
  68.     jnc    lp            ;
  69. gotdigit:
  70.     cmp    cl,2            ; If got two digits don't accept
  71.     jz    lp
  72.     shl    bl,4            ; Add in the digit
  73.     or    bl,al            ;
  74. writechar:
  75.     mov    dl,ah            ;
  76.     call    PutChar
  77.     inc    ecx            ; Inc digit count
  78.     jmp    lp            ; Next digit
  79. isquote:
  80.     cmp    cl,2
  81.     jz    lp
  82.     mov    bl,al
  83.     jmp    writechar
  84. bckspc:
  85.     or    cx,cx            ; Get next digit if nothing in buffer
  86.     jz    lp            ;
  87.     test    [InsideQuote],1
  88.     jz    delnoquote
  89.     cmp    cl,2
  90.     jz    delnoquote
  91.     xor    [InsideQuote],1
  92. delnoquote:
  93.     shr    bl,4
  94.     mov    dl,8            ; Erase echoed char
  95.     call    PutChar
  96.     mov    dl,' '            ;
  97.     call    PutChar
  98.     mov    dl,8            ; Point at next echo space
  99.     call    PutChar
  100.     dec    cx            ; Dec digit count
  101.     jmp    lp
  102. isenter:
  103.     or    cx,cx            ; Enter key, set carry and get out
  104.     stc                ;
  105.     jmp    getout
  106. quote:
  107.     test    [InsideQuote],1
  108.     jnz    lp
  109.     xor    [InsideQuote],1
  110.     jmp    writechar
  111. space:
  112.     or    cl,cl            ; Space key, clear carry and get out
  113. getout:
  114.     pushf
  115.     mov    al,3            ; Space to line up in columns
  116.     sub    al,cl            ;
  117.     mov    cl,al            ;
  118. pslp:            
  119.     call    printspace        ;
  120.     loop    pslp            ;
  121.     popf                ;
  122.     mov    ax,bx            ; AX = number input
  123.     pop    bx
  124.     pop    cx
  125.     pop    dx
  126.     ret
  127. InputNumber    ENDP    
  128. ;
  129. ; Number entry with prompt
  130. ;
  131. entry    PROC    
  132.     call    WadeSpace        ; Wade through commad spaces
  133.     jz    enterr
  134.     call    ReadAddress        ; Read the address
  135.     jc    enterr            ; Bad address ,error
  136.     test    [optdwordcommand],0ffh
  137.     jnz    oklarge
  138.     movzx    ebx,bx
  139. oklarge:
  140.     call    defDS            ; get DS
  141.     mov    fs,dx
  142.     mov    edi,ebx
  143.     mov    cx,-1            ;
  144.     call    WadeSpace        ; Wade through spaces
  145.     jz    promptx        ; Go do prompt version
  146. readlp:
  147.     call    ReadNumber        ; Else read number off command line
  148.     jc    enterr2            ; Quit if error
  149.     mov    fs:[edi],al        ; Save value
  150.     inc    edi            ; Point to next input pos
  151.     call    WadeSpace        ; Wade through spaces
  152.     jz    retok        ;
  153.     jmp    readlp            ; Else get next value
  154. promptx:
  155.     call    crlf
  156.     mov    ax,dx            ; Print segment
  157.     call    PrintWord        ;
  158.     push    dx            ;
  159.     mov    dl,':'            ; Print ':'
  160.     call    PutChar
  161.     pop    dx            ;
  162.     mov    eax,ebx                 ;
  163.     test    [optdwordcommand],0ffh
  164.     jz    adrword
  165.     call    PrintdWord    ; Print address
  166.     jmp    adrcmb
  167. adrword:
  168.     call    PrintWord
  169. adrcmb:
  170. elp:
  171.     call    printspace        ; Space over two spaces
  172.     call    printspace        ;
  173.     mov    al,fs:[edi]        ; Print current value
  174.     call    printbyte        ;
  175.     push    dx            ;
  176.     mov    dl,'.'            ; Print '.'
  177.     call    PutChar
  178.     pop    dx            ;
  179.     push    cx
  180.     call    InputNumber        ; Get a number
  181.     pop    cx
  182.     jz    nextitem        ; No number, go do next
  183.     mov    fs:[edi],al        ; Save value
  184. nextitem:
  185.     jc    retok        ; Quit if ENTER key pressed
  186.     dec    cx            ; Quit if end of segment
  187.     jz    retok        ;
  188.     inc    edi            ; Point at next value
  189.     inc    ebx            ; Next address
  190.     test    [optdwordcommand],0ffh
  191.     jnz    cont
  192.     cmp    ebx,10000h
  193.     jz    retok
  194. cont:
  195.     test    ebx,7            ; If address mod 7 = 0
  196.     jz    promptx            ; Do another prompt
  197.     jmp    elp
  198. retok:
  199.     clc                ; No errors
  200.     ret
  201. enterr2:
  202. enterr:        
  203.     stc                 ; Errors
  204. dudone:
  205.     ret
  206. entry    ENDP    
  207. END