home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / asm_kit / memscan.asm < prev    next >
Assembly Source File  |  1985-06-21  |  6KB  |  203 lines

  1. ;MEMSCAN--Scans entire megabyte of memory
  2. ;
  3. ;  Assigns a symbol to each group of 1024 bytes
  4. ;    symbol is "." if nothing is there
  5. ;    symbol is "X" if something is there
  6. ;
  7. ;  Output arranged:`
  8. ;    8 groups/divisions,
  9. ;    8 divisions/line,
  10. ;    16 lines/screen
  11. ;
  12. ;    1024 * 8 * 8 * 16 = 1 048 576
  13. ;
  14. pmess    equ       9h             ;print message function
  15. display  equ       2h             ;display output char fn
  16. doscall  equ       21h            ;DOS interrupt address
  17. ;
  18. ;***************************************************************
  19. ;
  20. ;segment to define ES
  21. ;
  22. x_seg    segment
  23. x_byte   db        ?
  24. x_seg    ends
  25. ;***************************************************************
  26. ;
  27. ;variable storage area
  28. ;
  29. var_area segment
  30. ;
  31. lines    db        ?
  32. div_line db        ?
  33. gp_div   db        ?
  34. header   db   '        0000     2000     4000     6000'
  35.          db      '     8000     A000     C000     E000$'
  36. colon    db        ': $'
  37. footer   db   0ah,0dh,'X      X      X      X      X      X      X      X'
  38.          db   0ah,0dh,'000    400    800    C00    1000   1400   1800   1C00$'
  39. ;
  40. var_area ends
  41. ;***************************************************************
  42. ;
  43. memscan segment
  44. ;
  45. ;---------------------------------------------------------------
  46. main     proc      far
  47. ;
  48.          assume cs:memscan, ds:var_area
  49.          assume es:x_seg
  50. ;
  51. ;set up stack for return
  52. start:
  53.          push      ds             ;save DS
  54.          sub       ax,ax          ;clear AX to 0
  55.          push      ax             ;push 0
  56. ;
  57. ;
  58. ;set data segment to work area
  59.          mov       ax,var_area
  60.          mov       ds,ax
  61. ;
  62. ;initialization
  63.          mov       lines,16d      ;lines per screen = 16
  64.          sub       ax,ax          ;set AX to 0
  65.          mov       es,ax          ;set ES register to 0
  66. ;
  67. ;print header
  68.          call      crlf           ;skip a line
  69.          mov       dx,offset header ;addr of message
  70.          mov       ah,pmess       ;print message function
  71.          int       doscall        ;call DOS`
  72.          call      crlf           ;skip a line
  73. ;
  74. ;start a new line
  75. new_line:
  76. ;pα╡╕╤ü╜╣╤ò╣╤═üzÖü*5IW╓V¡.]╣ at sstrrt of line
  77.          mov       bx,es          ;print contents of ES
  78.          call      binihex        ;on screen in hex
  79. ;print colon and space
  80.          mov       dx,offset colon
  81.          mov       ah,pmess       ;print message function
  82.          int       doscall        ;call DOS
  83. ;
  84.          mov       div_line,8d    ;divisions per line = 8
  85.          mov       bx,0           ;set BX to zero
  86. ;
  87. ;start a new division
  88. new_div:
  89.          mov       gp_div,8d      ;groups/division = 8
  90. ;
  91. ;start a new gruop
  92. new_grp:
  93.          mov       cx,128d        ;samples per group = 128d
  94. ;
  95. ;read two bytes and compare them
  96. new_byte:
  97.          mov       al,[bx + x_byte]
  98.          mov       ah,[bx + x_byte + 2]
  99.          and       ax,7f7fh       ;mask off high bits
  100.          cmp       al,ah          ;does 1st = 2nd ?
  101.          je        nx_byte        ;yes, nothing there
  102. ;
  103. ;may be somthing, look at third byte
  104.          mov       dl,[bx + x_byte + 5]
  105.          and       dl,7fh         ;maskoff high bit
  106.          cmp       al,dl          ;does 1st = 3rd ?
  107.          je        nx_byte        ;yes
  108.          cmp       ah,dl          ;does 2nd = 3rd ?
  109.          je        nx_byte        ;yes
  110. ;
  111. ;three bytes all different found
  112. ;  so there is something in this gruop
  113.          mov       dl,'X'         ;print "X"
  114.          mov       ah,display     ;display function
  115.          int       doscall        ;call DOS
  116. ;
  117. ;advance to next group
  118.          and       bx,0fc00h      ;mask off lower 10 bits
  119.          add       bx,1024d       ;add 1024d (400h)
  120.          jmp       done_grp       ;done this group
  121. ;
  122. ;nothing found yet, get next byte
  123. nx_byte:
  124.          add       bx,8d          ;increment byte pointer
  125.          dec       cx             ;done this group?
  126.          jnz       new_byte       ;not yet
  127. ;done group, so print a period
  128.          mov       dl,'.'         ;char in DL
  129.          mov       ah,display     ;display function
  130.          int       doscall        ;call DOS
  131. ;
  132. ;we've done one gruop (1024 bytes)
  133. done_grp:
  134.          dec       gp_div         ;done a division?
  135.          jnz       new_grp        ;no, do next group
  136.          mov       dl,' '         ;yes print a space
  137.          mov       ah,display     ;display function
  138.          int       doscall        ;call DOS
  139. ;
  140. ;we've done one division (8groups)
  141. done_div:
  142.          dec       div_line       ;done 8 divisions ?
  143.          jnz       new_div        ;no, do next division
  144.          call      crlf           ;yes, print cr & lf
  145.          mov       ax,es          ;advance ES
  146.          add       ax,1000h       ;  to next segment
  147.          mov       es,ax          ;  (add 65535d)
  148. ;
  149. ;we've done one line (8 segments)
  150. done_line:
  151.          dec       lines          ;done 16 lines?
  152.          jnz       new_line       ;no, do next line`
  153. ;
  154. ;print out values of X positions on bottom row
  155.          mov       dx,offset footer
  156.          mov       ah,pmess       ;print message function
  157.          int       doscall        ;call DOS
  158.          ret                      ;yes, return to DOS
  159. ;
  160. main     endp
  161. ;---------------------------------------------------------------
  162. ;
  163. crlf     proc      near
  164.          mov       dl,0dh
  165.          mov       ah,display
  166.          int       doscall
  167.          mov       dl,0ah
  168.          mov       ah,display
  169.          int       doscall
  170.          ret
  171. crlf     endp
  172. ;---------------------------------------------------------------
  173. ;
  174. binihex  proc      near
  175.          mov       ch,4
  176. rotate:  mov       cl,4
  177.          rol       bx,cl
  178.          mov       al,bl
  179.          and       al,0fh
  180.          add       al,30h
  181.          cmp       al,3ah
  182.          jl        printit
  183.          add       al,7h
  184. printit:
  185.          mov       dl,al
  186.          mov       ah,display
  187.          int       doscall
  188.          dec       ch
  189.          jnz       rotate
  190.          ret
  191. ;
  192. binihex  endp
  193. ;---------------------------------------------------------------
  194. ;
  195. memscan  ends
  196. ;
  197. ;***************************************************************
  198.          end       start
  199. ------------------
  200. ;
  201. memscan  ends
  202. ;
  203. ;**********************************************