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

  1. ;----------------------------------------------------------------
  2. ;          This is a module in the ASMLIB library.
  3. ;
  4. ; This module uses a barber pole type approach to testing memory.
  5. ; The barber pole is an uneven number of bytes long so that address
  6. ; and page faults are detected. This is supposedly better than
  7. ; walking bit tests at detecting faults in memory. This program
  8. ; may be modified to suit the type of ram chips that are being used.
  9. ; If the ram chips are 1 bit wide (4116 or 4864 etc) then use the
  10. ; size1 equate.
  11. ; Ir ram is 8 bits wide (6116 etc) then use size 8.
  12. ; The effect of these is to modify the size of the barber pole pattern
  13. ; that is written into memory and to optimize the test so that will
  14. ; find faults in addressing better.
  15. ;
  16. ; If an error is found then HL-> memeory in error and A = the value
  17. ; that was being tested.
  18. ;
  19. ;          This is the barber pole memory test program from
  20. ;          Byte December 1982
  21. ;
  22. ;                         Written    R.C.H.       22/10/83
  23. ;                         Last Update   R.C.H.       24/10/83
  24. ;----------------------------------------------------------------
  25. ;
  26.     name    'rambpt'
  27.     public    rambpt
  28.     maclib    z80
  29. ;
  30. true    equ    0ffffh
  31. false    equ    not true
  32. size1    equ    true        ; 1 bit wide memories
  33. size8    equ    not size1    ; 8 or 4 bit wide memories
  34. ;
  35.     if    size1
  36. lnpat    equ    017
  37.     endif
  38. ;
  39.     if    size8
  40. lnpat    equ    9
  41.     endif
  42.  
  43. ;
  44. ; here DE -> start of memory to be tested, Hl --> end of test area
  45. ;
  46. rambpt:
  47.     sded    memst        ; Save memory start address
  48.     shld    memnd
  49. ;
  50. ; Test if end > start
  51. ;
  52.     xchg            ; now DE = end address, HL = start
  53.     mov    a,h
  54.     cma    
  55.     mov    h,a        ; Take complement
  56.     mov    a,l
  57.     cma
  58.     mov    l,a
  59.     inx    h        ; Bump to take the complement
  60.     dad    d        ; Add the 2's complement
  61.     jc    main3        ; Carry and all is ok else error
  62. ;
  63. ; Here and end is > start address
  64. ;
  65.     stc            ; set the carry flag
  66.     ret
  67. ;
  68. main3:
  69.     inx    h        ; Calculate number of bytes to test
  70.     shld    nbyte
  71.     mvi    a,lnpat        ; Load pattern length
  72.     sta    patln        ; Save in length
  73.     sta    ncycl        ; Load cycle counter
  74.     lxi    b,patrn        ; Point to the pattern to put in ram
  75.     push    b
  76. main4:
  77.     lhld    nbyte
  78.     xchg            ; Put number of bytes in DE
  79.     lhld    memst        ; Load HL with start address
  80. ;
  81. ; This routine drops the barber pole into memory
  82. ;
  83. main5:
  84.     ldax    b        ; get a pattern byte
  85.     mov    m,a        ; put into memory
  86.     inx    b        ; point to next batrber pole pattern
  87.     inx    h        ; bump memory pointer
  88.     dcx    d        ; decrement counter of bytes
  89.     mov    a,d        
  90.     ora    e        ; is DE = 0 ??
  91.     jz    main6        ; if so then test the pattern
  92.     lda    patln        ; decerment the pattern length
  93.     dcr    a
  94.     sta    patln
  95.     jnz    main5        ; If not zero, load another byte
  96.     pop    b
  97.     push    b        ; Restore the pattern start pointer
  98.     mvi    a,lnpat        ; Re-load pattern length
  99.     sta    patln
  100.     jmp    main5
  101. ;
  102. ; Test the barber pole in memory
  103. ;
  104. main6:
  105.     pop    b
  106.     push    b        ; Get start of pattern
  107.     mvi    a,lnpat        ; get length of pattern
  108.     sta    patln        ; save in length store
  109.     lhld    nbyte        ; get the size
  110.     xchg
  111.     lhld    memst        ; get the start address
  112. ;
  113. ;
  114. main7:
  115.     ldax    b        ; get the pattern byte
  116.     cmp    m        ; is memory the same as the pattern ?
  117.     jnz    error        ; error if it is not
  118.     inx    b        ; next pattern character
  119.     inx    h        ; next memory
  120.     dcx    d        ; one less byte to test
  121.     mov    a,e
  122.     ora    d        ; end of bytes ?
  123.     jz    main8        ; end if d = e = 0
  124.     lda    patln
  125.     dcr    a
  126.     sta    patln
  127.     jnz    main7        ; keep on till patln = 0
  128.     pop    b
  129.     push    b        ; restore pattern start address
  130.     mvi    a,lnpat
  131.     sta    patln
  132.     jmp    main7
  133. ;
  134. ; Shift the barber pole left by 1 bit and test for last shift
  135. ;
  136. main8:
  137.     lda    ncycl
  138.     pop    b
  139.     inx    b        ; shift left by moving table pointer
  140.     push    b
  141.     mvi    a,lnpat        ; get the length
  142.     sta    patln
  143.     lda    ncycl        ; get number of cycles done
  144.     dcr    a
  145.     sta    ncycl
  146.     jnz    main4        ; keep on till ncycl = 0
  147. ;
  148. ; end of test when here
  149. ;
  150.     pop    b        ; restore pattern pointer & stack
  151.     ora    a        ; disable carry flag if it was set
  152.     ret            ; all done, no errors
  153. ;
  154. ; Error handler
  155. ; If an error then return carry flag set, HL-> error
  156. ; and A = value written to ram.
  157. ;
  158. error:
  159.     pop    b        ; restore stack. BC -> barber pole pattern.
  160.     stc            ; set carry to indiacte a testing error
  161.     ret
  162. ;
  163. ; For 1 bit wide memories, use the following
  164.     if    size1
  165. patrn    db    00h,01h,02,04h,08h,10h,20h,40h,80h
  166.     db    0feh,0fdh,0fbh,0f7h,0efh,0dfh,0bfh,07fh
  167.          db    00h,01h,02,04h,08h,10h,20h,40h,80h
  168.     db    0feh,0fdh,0fbh,0f7h,0efh,0dfh,0bfh,07fh
  169.     endif
  170. ;
  171. ; For 4 and 8 bit wide rams use the following.
  172. ;
  173.     if    size8
  174. patrn    db    00h,11h,22h,44h,88h,0eeh,0ddh,0bbh,077h
  175.           db    00h,11h,22h,44h,88h,0eeh,0ddh,0bbh,077h
  176.     endif
  177.  
  178. ;
  179.     dseg
  180. memnd    db    00,00
  181. memst    db    00,00
  182. nbyte    db    00,00
  183. ncycl    db    00,00
  184. patln    db    00,00
  185.     end
  186.  
  187.  
  188.