home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / asmutl / asmlib.lbr / RAMWBT.AZM / RAMWBT.ASM
Encoding:
Assembly Source File  |  1991-06-25  |  2.6 KB  |  135 lines

  1. ;----------------------------------------------------------------
  2. ;        This is a module in the ASMLIB library.
  3. ;
  4. ; This is a walking bit ram test that moves the following bytes
  5. ; through memory from m(de) to m(hl). After each move the pattern
  6. ; is tested.
  7. ;
  8. ; 000 then test
  9. ; 0ff then test
  10. ; 0aa then test
  11. ; 055 then test
  12. ; single bit rotated then test
  13. ;
  14. ; If memory fails then HL-> memory in error, carry set, A = test value
  15. ; that caused the error.
  16. ;
  17. ;                Written        R.C.H.     22/10/83
  18. ;                               Last Update    R.C.H.     24/10/83
  19. ;----------------------------------------------------------------
  20. ;
  21.     name    'ramwbt'
  22.     public    ramwbt
  23.     maclib    z80
  24. ;
  25. ;
  26. ramwbt:
  27.     push    d            ; save the start of ram to test
  28.     dsbc    d            ; now hl = end - start = size to test
  29.     xchg                ; de = size to test
  30.     pop    h            ; hl -> start now
  31. ; Test if size is 00
  32.     mov    a,e
  33.     ora    d            ; is d = e = e ??
  34.     rz                ; Exit if so.
  35.     mov    b,d
  36.     mov    c,e            ; put a copy into bc
  37. ;
  38. ; Perform the 00 fill and test test.
  39. ;
  40.     xra    a            ; get a zero
  41.     call    filcmp            ; do the test
  42.     rc                ; return with error
  43. ;
  44. ; use a FF next to fill and test memory
  45. ;
  46.     mvi    a,0ffh
  47.     call    filcmp
  48.     rc                ; return on carry if error
  49. ;
  50. ; use an AAh next
  51. ;
  52.     mvi    a,0aah
  53.     call    filcmp            
  54.     rc
  55. ;
  56. ; Use a 55 next
  57. ;
  58.     mvi    a,055h
  59.     call    filcmp
  60.     rc
  61. ;
  62. ; Perform the simple walking bit test next. This moves a 1 across a bit field
  63. ; and writes/reads it through memory.
  64. ;
  65. wlklp:
  66.     mvi    a,80h
  67. wlklp1:
  68.     mov    m,a
  69.     cmp    m            ; can we read it back ??
  70.     stc                ; set carry in case of error
  71.     rnz                ; no match and return an error
  72.     rrc                ; shift right by 1 bit then
  73.     cpi    080h
  74.     jrnz    wlklp1            ; keep on
  75.     mvi    m,00            ; clear this byte then
  76.     inx    h
  77.     dcx    b
  78.     mov    a,b
  79.     ora    c            ; is b = c = 0 ??
  80.     jrnz    wlklp
  81.     mvi    m,00            ; clear last byte of memory
  82.     ret                 ; return all is well
  83. ;
  84. ; This is the routine that must fill memory with the byte that is in
  85. ; A from Hl to HL + BC and then check if memory is ok or not.
  86. ; If an error then return the carry flag set.
  87. ;
  88. filcmp:
  89.     push    h
  90.     push    b
  91.     mov    e,a            ; save test value
  92.     mov    m,a            ; write original into memory
  93.     dcx    b            ; one less byte
  94.     mov    a,b
  95.     ora    c
  96.     mov    a,e
  97.     jrz    compare            ; if 1 byte then compare and exit
  98. ;
  99.     mov    d,h
  100.     mov    e,l
  101.     inx    d
  102.     ldir                ; fill memory
  103. ;
  104. ; Here we can test memory to see if it reads the same back
  105. ;
  106. compare:
  107.     pop    b
  108.     pop    h
  109.     push    h
  110.     push    b
  111. cmplp:    ; Compare loop
  112.     cci                ; compare a block of memory
  113.     jrnz    cmper            ; jump if not equal
  114.     jpe    cmplp
  115. ; here and no errors.
  116.     pop    b
  117.     pop    h
  118.     ora    a
  119.     ret
  120. ;
  121. ; Here is the error return.
  122. ;
  123. cmper:
  124.     pop    b
  125.     pop    d
  126.     stc
  127.     ret
  128. ;
  129. ;
  130.     end
  131.  
  132.  
  133.  
  134.  
  135.