OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [tools/] [dongle/] [daa/] [z80-instruction-test-daa.py] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 gdevic
#!/usr/bin/env python
2
#
3
# This script runs Z80 command 'daa' for all 256 values and flag combinations
4
# and prints out memory access log data. This data is used to feed the simulation
5
# script and verify its algorithm correctness.
6
# It needs:
7
#   1. Arduino Z80 dongle: http://www.baltazarstudios.com
8
# Needs pyserial from https://pypi.python.org/pypi/pyserial
9
#
10
import serial
11
import sys
12
 
13
ser = serial.Serial("\\.\COM9", 115200, timeout=1)
14
 
15
# Flush the serial buffer, removes any command response
16
def serialFlush(ser):
17
    while 1:
18
        indata = ser.readline().rstrip('\n')
19
        if not indata:
20
            break
21
 
22
try:
23
    serialFlush(ser)
24
    # Stop after selected M1 cycle effectively running only that one sequence
25
    ser.write("s 4 7\r")
26
    ser.write("s 3 60\r")
27
    serialFlush(ser)
28
 
29
    # Loop for all 256 arguments
30
    for x in range(0, 256):
31
    #2:    0+10 0000  310000        ld  sp, 0000h
32
    #3:   10+10 0003  010000        ld  bc, 0000h
33
    #4:   20+11 0006  C5            push    bc
34
    #5:   31+10 0007  F1            pop     af
35
    #6:   41+4  0008  27            daa
36
    #7:   45+11 0009  F5            push    af
37
    #8:   56+4  000A  76            halt
38
        ram = ':10000000' + '310000' + '01' + '13' + ("%0.2X" % x) + 'C5F127F5760000000000'
39
 
40
        ser.write(ram + '\r')
41
        indata = ser.readline().rstrip('\n')
42
        ser.write('r\r')
43
 
44
        sys.stderr.write (ram + '\n')
45
 
46
        # Skip initial response from Arduino, includes two empty cycles after the reset
47
        for x in range(1,7):
48
            indata = ser.readline()
49
 
50
        while 1:
51
            indata = ser.readline()
52
            if not indata:
53
                break
54
            if indata[0]!=':':
55 8 gdevic
                if ("#017" in indata) or ("#020" in indata) or ("#053" in indata) or ("#056" in indata):
56 3 gdevic
                    print (indata.rstrip('\r\n'))
57
                    sys.stderr.write (indata)
58
 
59
except KeyboardInterrupt:
60
     ser.close()

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.