#!/usr/bin/env python

import socket
import re

def readMonitorLine(sock, recv_buffer=4096):
	buffer = ''
	data = True
	while data:
		data = sock.recv(recv_buffer)
		buffer += data

		while buffer.find(") ") != -1:
			output, buffer = buffer.split(") ", 1)
			lines = output.split("\n")
			yield lines[:-1]
	return


def processLines(lines):
	if len(lines) != 1:
		return

	line = lines[0]
	#print line
	m = re.search('...([0-9a-f]+).{14}([A-Z]{3}) ([^ ]+).*  ([0-9]+)', line)
	if not m:
		return

	print m.group(4), m.group(1), m.group(2), m.group(3)


TCP_IP = '127.0.0.1'
TCP_PORT = 6510
MESSAGE = "\nreset\n"

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((TCP_IP, TCP_PORT))
sock.send(MESSAGE)

for lines in readMonitorLine(sock):
	processLines(lines);	
	sock.send("step\n")



sock.close()

@@ -436,28 +436,36 @@
 14%7D(
-%5BA-Z%5D%7B3%7D) (%5B%5E %5D+
+.+) - A:(..) X:(..) Y:(..
 ).*
- 
  (%5B0
@@ -504,60 +504,289 @@
 n%0A%0A%09
-print m.group(4), m.group(1), m.group(2), m.group(3)
+groups = %5Bm.group(i) for i in range(1, 7)%5D%0A%09ip, instruction, a, x, y, time = groups%0A%0A%09im = re.search('... %5C(%5C$(%5B%5E)%5D+)%5C),Y', instruction)%0A%09flags = %22%22%0A%09if not im:%0A%09%09print time, ip, instruction, a, x, y, flags%0A%09else:%0A%09%09flags = flags + %22I%22%0A%09%09print time, ip, instruction, a, x, y, flags
 %0A%0A%0AT
@@ -901,16 +901,75 @@
 STREAM)%0A
+sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)%0A
 sock.con
@@ -1095,17 +1095,16 @@
 p%5Cn%22)%0A%0A%0A
-%0A
 sock.clo

fix missing zero-arg instructions, show register values, flag indirect indexed addressing