home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / EMULATOR / UNIX / CAIN2 / Z80TEST.Z < prev   
Text File  |  2000-06-30  |  2KB  |  198 lines

  1. ; Z80TEST
  2. ; tests the validity of a z80 emulation
  3. ;
  4.  
  5. ; First we test a few flags to make sure that the emulator works enough
  6. ; to test itself.  Basically we want to make sure we can test the flags
  7. ; and jump to 0 if the processor does something unexpected.  If it passes
  8. ; all of our tests then the OK string is printed and the program ends.
  9. ; if there is a problem the program should end just after the problem
  10. ; instructions.  This allows us to examine the debugger output at that
  11. ; point without having to painstakingly follow the code all the way.
  12.  
  13.     org     100h
  14.  
  15. ; test some flags flags first
  16.     ld        a, 0ffh
  17.     add     a, a
  18.     jp        nc, 0
  19.  
  20.     ld        a, 1
  21.     add     a, a
  22.     jp        c, 0
  23.  
  24.     xor        a, a
  25.     jp        nz, 0
  26.  
  27.     inc     a
  28.     jp        z, 0
  29.  
  30.     dec        a
  31.  
  32.     jp        m, 0
  33.     dec        a
  34.     jp      p, 0
  35.  
  36.     ld        a, 7fh
  37.     inc        a
  38.     jp        po, 0
  39.  
  40.     and        0ffh
  41.     jp        pe, 0
  42.  
  43. ; adc and add
  44. add_test1    macro    reg
  45.     ld        reg, 34h
  46.     ld        a, 21h
  47.     add        a, reg
  48.     jp        c, 0
  49.     cp        55h
  50.     jp        nz, 0
  51.     scf
  52.     ld        a, 21h
  53.     adc        a, reg
  54.     jp        c, 0
  55.     cp        56h
  56.     jp        nz, 0
  57.     adc        a, a
  58.     jp        po, 0
  59.     adc        a, a
  60.     jp        nc, 0
  61.     ld        a, 0fh
  62.     ld        reg, 55h
  63.     and        reg
  64.     cp        5
  65.     jp        nz, 0
  66.     endm
  67.  
  68.     ld        hl, test_var
  69.     add_test1    (hl)
  70.     ld        ix, test_var - 7
  71.     add_test1    (ix+7)
  72.     ld        iy, test_var - 7
  73.     add_test1    (iy+7)
  74.     add_test1    b
  75.     add_test1    c
  76.     add_test1    d
  77.     add_test1    e
  78.     add_test1    h
  79.     add_test1    l
  80.  
  81. add_test2    macro    reg
  82.     ld        hl, 1234h
  83.     ld        reg, 4321h
  84.     add        hl, reg
  85.     jp        c, 0
  86.     ld        a, l
  87.     cp        h
  88.     jp        nz, 0
  89.     cp        55h
  90.     jp        nz, 0
  91.     scf
  92.     adc        hl, hl
  93.     ld        a, l
  94.     dec        a
  95.     cp        h
  96.     jp        nz, 0
  97.     cp        0aah
  98.     jp        nz, 0
  99.     endm
  100.  
  101.     add_test2    bc
  102.     add_test2    de
  103.     add_test2    sp
  104.  
  105. add_test3    macro    reg
  106.     ld        ix, 1234h
  107.     ld        reg, 4321h
  108.     add        ix, reg
  109.     jp        c, 0
  110.     push    ix
  111.     pop        hl
  112.     ld        a, l
  113.     cp        h
  114.     jp        nz, 0
  115.     cp        55h
  116.     jp        nz, 0
  117.     add        ix, ix
  118.     push    ix
  119.     pop        hl
  120.     ld        a, l
  121.     cp        h
  122.     jp        nz, 0
  123.     cp        0aah
  124.     jp        nz, 0
  125.     ld        iy, 1234h
  126.     ld        reg, 4321h
  127.     add        iy, reg
  128.     jp        c, 0
  129.     push    iy
  130.     pop        hl
  131.     ld        a, l
  132.     cp        h
  133.     jp        nz, 0
  134.     cp        55h
  135.     jp        nz, 0
  136.     add        iy, iy
  137.     push    iy
  138.     pop        hl
  139.     ld        a, l
  140.     cp        h
  141.     jp        nz, 0
  142.     cp        0aah
  143.     jp        nz, 0
  144.     endm
  145.  
  146.     add_test3    bc
  147.     add_test3    de
  148.     add_test3    sp
  149.  
  150.     ld        a, 21h
  151.     add        a, 34h
  152.     jp        c, 0
  153.     cp        55h
  154.     jp        nz, 0
  155.     scf
  156.     ld        a, 21h
  157.     adc        a, 34h
  158.     jp        c, 0
  159.     cp        56h
  160.     jp        nz, 0
  161.     adc        a, a
  162.     jp        po, 0
  163.     adc        a, a
  164.     jp        nc, 0
  165.     ld        a, 0fh
  166.     and        55h
  167.     cp        5
  168.     jp        nz, 0
  169.  
  170. ; that finishes the As!
  171.  
  172. ld_imm    macro    reg
  173.     ld        reg, 34h
  174.     ld        a, 34h
  175.     cp        reg
  176.     jp        nz, 0
  177.     endm
  178.     ld_imm        a
  179.     ld_imm        b
  180.     ld_imm        c
  181.     ld_imm        d
  182.     ld_imm        e
  183.     ld_imm        h
  184.     ld_imm        l
  185.     ld_imm        (hl)
  186.  
  187.     ld        de, ok
  188.     ld        c, 9
  189.     call    5
  190.     jp        0
  191.  
  192. ok:
  193.     db        'OK', 0dh, 0ah, '$'
  194.  
  195. test_var:
  196.     ds        100h
  197.  
  198.