git @ Cat's Eye Technologies ZOWIE / 22cce2c
It compiles! Runs the examples! Passes half the tests... Chris Pressey 7 years ago
2 changed file(s) with 21 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
66 #
77
88 import sys
9 import os
910
1011
1112 def input():
380381
381382
382383 def rpython_input():
383 import os
384384 s = os.read(1, 1)
385385 if not s:
386386 return 0
387 return ord(s)
387 return ord(s[0])
388
388389
389390 def rpython_output(code):
390 import os
391391 os.write(0, unichr(code).encode('utf-8'))
392392
393393
394 def rpython_load(filename):
395 fd = os.open(filename, os.O_RDONLY, 0644)
396 text = ''
397 chunk = os.read(fd, 1024)
398 text += chunk
399 while len(chunk) == 1024:
400 chunk = os.read(fd, 1024)
401 text += chunk
402 os.close(fd)
403 return text
404
405
394406 def rpython_main(argv):
395 # EXPERIMENTAL!
396 print "hi there"
397407 p = Processor()
398 p.load_string("""
399 MOV R10, 90 ; initially it's "Z"
400 MOV R1, R1 ; BEGIN TRANSACTION for "REPEAT"
401 MOV R0, R10 ; output character
402 MOV R8, R10 ; decrement character
403 MOV R5, 1
404 MOV R10, R8
405 MOV R8, R10 ; test if character is above "@"
406 MOV R5, 64
407 MOV R3, R8 ; COMMIT AND REPEAT if non-zero
408 """)
408 program = rpython_load(argv[1])
409 p.load_string(program)
409410 p.run()
410411 return 0
411412
55 -> Functionality "Interpret ZOWIE Program" is implemented by
66 -> shell command
77 -> "python src/zowie.py %(test-body-file)"
8
9 -> Functionality "Interpret ZOWIE Program" is implemented by
10 -> shell command
11 -> "./zowie-c %(test-body-file)"
812
913 Display the Roman alphabet in reverse.
1014