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

  1. ;
  2. ; GRDB
  3. ;
  4. ; Copyright(c) LADsoft
  5. ;
  6. ; David Lindauer, camille@bluegrass.net
  7. ;
  8. ;
  9. ; help.asm
  10. ;
  11. ; Function: Handle help and most of the status screens
  12. ;
  13. ;   Handles numbers
  14. ;   Handles segments
  15. ;   Handles trapping page faults
  16. ;   Handles command input
  17. ;
  18.     ;MASM MODE
  19.     .model small
  20.     .386
  21.  
  22. include  iversion.inc
  23. include  eprints.inc 
  24. include  emtrap.inc 
  25. include  eenv.inc
  26. include  eloader.inc
  27. include  einput.inc
  28. include edos.inc
  29. include eoptions.inc
  30. include eints.inc
  31.  
  32.     extrn cpumodel : byte
  33.     PUBLIC  help
  34.  
  35.     .data
  36. memx    dw    0    ; used to filter non-program stuff in arena dump (?m)
  37. none    db    "none",0
  38. cputypes db    "386",0,"486",0,"Pentium",0
  39.     db    "Pentium Pro",0,"786",0,"886",0,"986",0
  40.  
  41.     .code
  42. ;
  43. ; help command entry point
  44. ;
  45. Help    PROC
  46. ;    call    PrintFollowingMessage
  47. ;    db    13,10,"Get Real Debugger Version "
  48. ;    db    30h + verid/10,'.',30h + verid MOD 10,9
  49. ;    db    "Copyright (c) LADsoft",13,10
  50. ;    db    0
  51.     call    WadeSpace
  52.     jnz    help2
  53.     call    PrintFollowingMessage
  54.     db    13,10
  55.     db    "a  [address]             - assemble",13,10
  56.     db    "b  [d][#]             - Show breakpoint(s)",13,10
  57.     db    "b  [d][-]#,addr[,r/w/x[,len]]    - set or clear a breakpoint",13,10
  58.     db    "d  [start [,end]]        - dump memory",13,10
  59.     db    "e  start [,list]         - examine memory",13,10
  60.     db    "g  [=start] [,break]        - run from start (or pos) to break",13,10
  61.     db    "h  val1 [+-*/] val2        - hex arithmetic",13,10
  62.     db    "i[bwd]  port             - read from port",13,10
  63.     db    "l  [@] [-] [name[ command]]    - read from file",13,10
  64.     db    "n  [s]                - show fp regs/status",13,10
  65.     db    "n  #, val            - set value in an FP reg",13,10
  66.     db    "o[bwd]  port,val        - write to port",13,10
  67.     db    "p  [r]                - step through",13,10
  68.     db    "q                - quit",13,10
  69.     db    "r  [reg[:val]]            - show/modify regs",13,10
  70.     db    "t  [count]            - step into",13,10
  71.     db    "u  [start [,end]]        - unassemble",13,10
  72.     db    "w  [@addr] [name] [,len]    - write to file",13,10
  73.     db    "?                - this help",13,10
  74.     db    "??                - help for extended commands"
  75.     db    0
  76.     clc
  77.     ret    
  78. help2:
  79.     cmp    al,'?'
  80.     jnz    status
  81.     inc    si
  82.     call    wadespace
  83.     jnz    herr
  84.     call    PrintFollowingMessage
  85.     db    13,10
  86.     db    "c  start,end,start2        - compare memory",13,10
  87.     db    "f  start,end [,val]        - fill memory",13,10
  88.     db    "m  source,end,dest        - move memory",13,10
  89.     db    "s  start,end [,list]        - search for a byte pattern",13,10
  90.     db    "xr drive: addr,start [,len]    - read logical disk sector",13,10
  91.     db    "xw drive: addr,start [,len]    - write logical disk sector",13,10
  92.     db    "y  pfa,reg[,val]               - read/[write] PCI reg",13,10
  93.     db    "y? bus, dev, func            - get PFA from bus:dev:func",13,10
  94.     db    "@  [a] [logfile]        - start/stop logging to a file",13,10
  95.     db    "?i                - view interrupt info",13,10
  96.     db    "?m [x]                - view arena tags",13,10
  97.     db    "?o [+-option]            - view/set options",13,10
  98.     db    "?p                - view program status"
  99.     db    0
  100.     clc
  101.     ret    
  102. ;
  103. ; program & processor info
  104. ;
  105. status:
  106.     cmp    al,'p'
  107.     jnz    hmem
  108.     inc    si
  109.     call    WadeSpace
  110.     jnz    herr
  111.     PRINT_MESSAGE    <13,10,"Dos version: ">
  112.     mov    al,byte ptr [dosver + 1]
  113.     call    printbyte
  114.     mov    dl,'.'
  115.     call    putchar
  116.     mov    al,byte ptr [dosver]
  117.     call    printbyte
  118.     PRINT_MESSAGE    <13,10,"CPU type: ">
  119.     mov    di,offset cputypes ; calculate CPU type message pos
  120.     movzx    cx,[cpumodel]        ; program needs a 386+ :)
  121.     sub    cx,3
  122.     jcxz    gotcpu
  123.     sub    al,al
  124. cpulp:
  125.     push    cx
  126.     mov     cx,-1
  127.     repne    scasb
  128.     pop    cx
  129.     loop    cpulp
  130.  
  131. gotcpu:
  132.     mov    bx,di         ; put out CPU type
  133.     call    dgroupMessage     
  134.  
  135.     call    crlf
  136.  
  137.     mov    si,offset loadfile    ; calc loadfile and command
  138.     mov    di,offset loadcommand
  139.     test    [filelen],-1
  140.     jnz    okprog
  141.     mov    si,offset none
  142.     mov    di,si
  143. okprog:
  144.     test    byte ptr [di],-1
  145.     jnz    okgotdi
  146.     mov    di,offset none
  147. okgotdi:
  148.     test    byte ptr [si],-1
  149.     jnz    okgotsi
  150.     mov    si,offset none
  151. okgotsi:
  152.     PRINT_MESSAGE    <13,10,"Program:   ">
  153.     mov    bx,si
  154.     call    DgroupMessage
  155.     PRINT_MESSAGE    <13,10,"Arguments: ">
  156.     mov    bx,di
  157.     call    DgroupMessage
  158.     call    ExeStats            ; put out EXE file stats
  159.     call    crlf
  160.  
  161.     PRINT_MESSAGE    <13,10,"Psp at ">
  162.     mov    ax,[userbasepsp]
  163.     call    PrintWord
  164.     mov    ax,[userpsp]
  165.     cmp    ax,[userbasepsp]
  166.     jz    normpsp
  167.     push    ax                      ; display if they have changed it
  168.     call    printspace
  169.     mov    dl,'('
  170.     call    PutChar
  171.     pop    ax
  172.     call    PrintWord
  173.     mov    dl,')'
  174.     call    PutChar
  175.     call    printspace
  176. normpsp:
  177.     PRINT_MESSAGE    <" with length ">
  178.     mov    ax,[userbasepsp]
  179.     dec    ax
  180.     mov    fs,ax
  181.     mov    ax,fs:[3]
  182.     call    PrintWord
  183.     PRINT_MESSAGE    <13,10,"Environment at ">
  184.     mov    ax,[TgtPgmEnvSeg]
  185.     call    PrintWord
  186.     PRINT_MESSAGE    <" with ">
  187.     mov    ax,[TgtPgmEnvSpaceUsed]
  188.     call    Printword
  189.     PRINT_MESSAGE    <" bytes used of ">
  190.     mov    ax,[TgtPgmEnvLen]
  191.     call    PrintWord
  192.     
  193.     clc
  194.     ret        
  195. ;
  196. ; arena stats
  197. ;
  198. hmem:    cmp    al,'m'
  199.     jnz    hopt
  200.     mov    ax,[userbasepsp]        ; calc PSP match
  201.     mov    [memx],ax
  202.     inc    si
  203.     call    WadeSpace
  204.     jz    memok
  205.     cmp    al,'x'
  206.     jnz    herr
  207.     inc    si
  208.     call    WadeSpace
  209.     jnz    herr
  210.     mov    [memx],0
  211. memok:
  212.     PRINT_MESSAGE    <13,10,13,10,"Top of memory: ">
  213.     mov    fs,[userbasepsp]
  214.     mov    ax,fs:[2]
  215.     call    PrintWord
  216.     call    crlf
  217.     push    es                 ; get root of chain                  
  218.     mov    ah,52h    
  219.     int    21h
  220.     mov    bx,es:[bx-2]
  221.     pop    es
  222. meml:
  223.     mov    fs,bx
  224.     test    [memx],0ffffh            ; check match and jump around if not
  225.     jz    memd
  226.     mov    ax,fs:[1]
  227.     cmp    ax,[memx]
  228.     jnz    memnd
  229. memd:
  230.     PRINT_MESSAGE    <13,10,"Address: ">
  231.     mov    ax,fs
  232.     call    PrintWord
  233.     PRINT_MESSAGE    <"  Owner: ">
  234.     test    word ptr fs:[1],-1
  235.     jz    memu
  236.     cmp    word ptr fs:[1],100h
  237.     jc    memdos
  238.     cmp    word ptr fs:[1],0f000h
  239.     jnc    membios
  240.     push    fs                    ; not special
  241.     mov    bx,fs:[1]            ; display prog name owner
  242.     dec    bx
  243.     mov    fs,bx
  244.     mov    si,8
  245.     mov    cx,8
  246. memns:
  247.     lods    byte ptr fs:[si]
  248.     or    al,al
  249.     jz    memnsx
  250.     mov    dl,al
  251.     call    PutChar
  252.     loop    memns
  253. memnsx:
  254.     pop    fs
  255.     inc    cx
  256.     push    cx
  257.     mov    dl,'('
  258.     call    PutChar
  259.     mov    ax,fs:[1]
  260.     call    PrintWord
  261.     mov    dl,')'
  262.     call    PutChar
  263.     jmp    memsz
  264. memdos:                                         ; dos special case
  265.     push    12
  266.     PRINT_MESSAGE    "DOS"
  267.     jmp    memmsg
  268. membios:                    ; bios special case
  269.     push    11
  270.     PRINT_MESSAGE    "BIOS"
  271.     jmp    memmsg
  272.  
  273. memu:                        ; free special case
  274.     push    11
  275.     PRINT_MESSAGE    "FREE"
  276. memmsg:
  277. memsz:
  278.     pop    cx
  279. memspl:
  280.     mov    dl,' '                ; field pad
  281.     push    cx
  282.     call    PutChar
  283.     pop    cx
  284.     loop    memspl
  285.     PRINT_MESSAGE    "  Size: "
  286.     mov    ax,fs:[3]
  287.     call    PrintWord
  288.     mov    bx,fs
  289. memnd:
  290.     add    bx,fs:[3]            ; index to next entry
  291.     inc    bx
  292.     cmp    byte ptr fs:[0],'Z'        ; quit if this entry was EOM
  293.     jnz    meml
  294.     clc
  295.     ret
  296. ;
  297. ; option status, jump to option routine
  298. ;
  299. hopt:
  300.     cmp    al,'o'
  301.     jnz    hchain
  302.     inc    si
  303.     jmp    doopt
  304. ;
  305. ; chain status
  306. ;
  307. hchain:
  308.     cmp    al,'i'
  309.     jnz    herr
  310.     inc    si
  311.     call    wadespace
  312.     jnz    herr
  313.     inc    si
  314.     call    crlf
  315.     push    es
  316.     mov    es,[intpage]
  317.     sub    ax,ax
  318.     mov    gs,ax
  319.     mov    cx,256
  320.     sub    si,si
  321.     sub    di,di
  322. chl:
  323.     lods    dword ptr gs:[si]    ; compare currint int page entry
  324.     scasd
  325.     jz    noch
  326.     push    si
  327.     push    di
  328.     push    eax            ; mismatch, print int #
  329.     mov    al,cl
  330.     neg    al
  331.     push    ax
  332.     call    printbyte
  333.     pop    ax
  334.     cmp    al,21h            ; int 21h is modifiable
  335.     jz    nostar
  336.     or    al,al             ; so are all ints > 7FH
  337.     js    nostar
  338.     push    es
  339.     push    ds
  340.     pop    es
  341.     mov    di,offset veclist
  342. chlx:
  343.     scasb
  344.     jz    dostar
  345.     inc    di
  346.     inc    di
  347.     cmp    byte ptr [di],0ffh
  348.     jnz    chlx
  349.     pop    es
  350. nostar:
  351.     call    printspace        ; not overridden
  352.     jmp    chj
  353. dostar:
  354.     pop    es
  355.     mov    dl,'*'
  356.     call    putchar
  357. chj:                                    ; print int vect address
  358.     mov    dl,':'
  359.     call    putchar
  360.     call    printspace
  361.     pop    bx
  362.     pop    ax
  363.     call    printword
  364.     mov    dl,':'
  365.     call    putchar
  366.     mov    ax,bx
  367.     call    printword
  368.     call    crlf
  369.     pop    di
  370.     pop    si
  371. noch:
  372.     loop    chl
  373.     pop    es
  374.     PRINT_MESSAGE    <13,10,"PIC 0 mask: ">
  375.     mov    dx,21h
  376.     mov    ah,byte ptr [orgpic+1]
  377.     call    picval
  378.     PRINT_MESSAGE    <13,10,"PIC 1 mask: ">
  379.     mov    dx,0a1h
  380.     mov    ah,byte ptr [orgpic]
  381.     call    picval
  382.     clc
  383.     ret
  384. picval:
  385.     push    ax
  386.     in    al,dx
  387.     push    dx
  388.     call    printbyte
  389.     call    printspace
  390.     mov    dl,'(' 
  391.     call    putchar
  392.     pop    dx
  393.     pop    ax
  394.     push    dx
  395.     mov    al,ah
  396.     call    printbyte
  397.     mov    dl,',' 
  398.     call    putchar
  399.     pop    dx
  400.     dec    dx
  401.     mov    al,0bh
  402.     out    dx,al
  403.     in    al,dx
  404.     call    printbyte
  405.     mov    dl,')' 
  406.     call    putchar
  407.     ret
  408. herr:
  409.     stc
  410.     ret
  411. Help    ENDP
  412. END