Kevin Veroneau committed d930ad9

Updated software interrupts to include "int 12" for reading a line of text from the keyboard.
Also combined interrupt routines into single loadable binary image.
Load interrupt.tbl in address 4000
Load interrupt.bin in address 1000

  • Participants
  • Parent commits d547e2f

Comments (0)

Files changed (5)

             self.file = open(filename, 'r+b')
         except IOError:
             self.file = open(filename, 'w+b')
+            self.file.write('\x00'*size)
+            self.file.close()
+            self.file = open(filename, 'r+b')
         self.mem = mmap.mmap(self.file.fileno(), 0)
+        self.size = size
         self._ptr_stack = []
         self._ptr = 0
+    def __del__(self):
+        print "Closing channels..."
+        self.mem.flush()
+        self.mem.close()
+        self.file.close()
+    def resize(self, newsize):
+        self.size = newsize
+        self.mem.resize(newsize)
 class Coder(Cmd):
     bc16_map = {
             self.stdout.write('Exit Code: %s\n' % rt)
         except CPUException, e:
             print e
-    def do_string(self, args):
-        """ A macro to write a string to the screen 1 character at a time. """
-        s = shlex.split(args)
-        for c in s[0]:
-            self.cpu.mem.write(2)
-            self.cpu.mem.write(1)
-            self.cpu.mem.write(ord(c))
-            self.cpu.mem.write(1)
-            self.cpu.mem.write(3)
     def do_ptr(self, args):
         """ Sets or returns the current pointer location in memory. """
         if args != '':
     def in_4000(self):
         if termios:
-            return
+            return ord(
             raise CPUException("CPU: Single key input not supported on this platform.")
     import readline
     c = CPU()
     c.loadbin('interrupt.tbl', 4000)
-    c.loadbin('int10.bin', 1000)
+    c.loadbin('interrupt.bin', 1000)
     cli = Coder()

File int10.bin

Binary file removed.

File interrupt.bin

Binary file added.

File interrupt.tbl

Binary file modified.

File sample-interrupts.txt

 Simple CPU Simulator -- Simple Int table:
+All these software interrupts requires that "interrupt.bin" is loaded into memory,
+and that the interrupt vector table is pointing to it's address in memory.
 INT 10:
   Reads a 0-terminated string of bytes from CPU memory and display it on the screen.
-  Requires that "int10.bin" is loaded into memory, and that the interrupt vector table is pointing to it's address in memory.
   AX: source
+INT 12:
+  Read raw input from the keyboard and store it in CPU Memory.
+  AX: CPU Memory location to store text to.
+  Returns CX: Length of string stored.