Esempio n. 1
0
    def test_mem2fac1(self):
        suite.banner(self.test_mem2fac1)
        a = self.a

        # No overrun test -- FAC_PTR is there
                
        _;      a.macro     (fac, -1.234567e-89, 0x8000)
        _;      a.macro     (ldxy_imm, 0x8000)
        _;      a(jsr,      'MEM2FAC1')

        self.run_test() 
        self.assertEquals(-1.234567e-89, vm.fac2py(self.mem[f1_start:f1_end]))
Esempio n. 2
0
 def __call__(self):
     cmd = self.mem[memmap.FPU_COMMAND]
     if cmd == 0: 
         return
     op1 = vm.fac2py(self.mem[_f0_start:_f0_end]) 
     op2 = vm.fac2py(self.mem[_f1_start:_f1_end])
     result = 0
     status = aliases.FPU_OK
     if cmd in FPU_BINARY_MAP: 
         try:
             result = FPU_BINARY_MAP[cmd](op1, op2) 
         except ZeroDivisionError: 
             status = aliases.ERR_FPU_DIVISION_BY_ZERO 
     elif cmd in FPU_COMPARE_MAP: 
         cmpresult = FPU_COMPARE_MAP[cmd](op1, op2) 
         result = 1 if cmpresult else 0 
     else:
         status = aliases.ERR_FPU_INVALID_COMMAND 
     self.mem[_f0_start:_f0_end] = vm.py2fac(result) 
     self.mem[memmap.FPU_COMMAND] = 0 
     self.mem[memmap.FPU_STATUS] = status 
Esempio n. 3
0
    def test_fac2mem0(self):
        suite.banner(self.test_fac2mem0) 
        a = self.a
        
        self.mem[0x8006::2] = 0xbeef
        
        _;      a.macro     (fac0, -1.234567e-89)
        _;      a.macro     (ldxy_imm, fm_start) 
        _;      a(jsr,      'FAC2MEM0')

        self.run_test() 
        self.assertEquals(-1.234567e-89, vm.fac2py(self.mem[fm_start:fm_end]))
        self.assertEquals(0xbeef, self.mem[0x8006::2])
Esempio n. 4
0
    def test_mem2fac0(self):
        suite.banner(self.test_mem2fac0)
        a = self.a

        self.mem[aliases.FAC0 + 6::2] = 0xbeef
                
        _;      a.macro     (fac, -1.234567e-89, 0x8000)
        _;      a.macro     (ldxy_imm, 0x8000)
        _;      a(jsr,      'MEM2FAC0')

        self.run_test() 
        self.assertEquals(-1.234567e-89, vm.fac2py(self.mem[f0_start:f0_end]))
        self.assertEquals(0xbeef, self.mem[aliases.FAC0 + 6::2])
Esempio n. 5
0
 def test_facop(self):
     suite.banner(self.test_facop) 
     a = self.a 
     
     _;      a.macro     (fac0, 8) 
     _;      a.macro     (fac1, 7) 
     _;      a(lda_imm,  'FPU_ADD')
     _;      a(jsr,      'FACOP')
     _;      a(lda_zp,   'FPU_STATUS')
     
     self.run_test() 
     self.assertEquals(15, vm.fac2py(self.mem[f0_start:f0_end])) 
     self.assertEquals(0, self.cpu.a)
Esempio n. 6
0
 def test_fac2py_sign_both(self):
     bytes = [0xf0, 0x70, 0x56, 0x34, 0x12, 0x42]
     self.assertEquals(-1.234567e42, vm.fac2py(bytes)) 
Esempio n. 7
0
 def test_fac2py_sign_mantissa_with_exponent(self):
     bytes = [0xf0, 0x70, 0x56, 0x34, 0x12, 0x42]
     self.assertEquals(-1.234567e42, vm.fac2py(bytes))
Esempio n. 8
0
 def test_fac2py_sign_mantissa(self):
     bytes = [0xf0, 0x70, 0x56, 0x34, 0x12, 0x06]
     self.assertEquals(-1234567, vm.fac2py(bytes))
Esempio n. 9
0
 def test_fac2py_exponent2(self):
     bytes = [0x00, 0x00, 0x00, 0x30, 0x12, 0x02]
     self.assertEquals(123, vm.fac2py(bytes))
Esempio n. 10
0
 def test_fac2py_exponent6(self):
     bytes = [0x00, 0x70, 0x56, 0x34, 0x12, 0x06]
     self.assertEquals(1234567, vm.fac2py(bytes))
Esempio n. 11
0
 def test_fac2py(self):
     bytes = [0x00, 0x70, 0x56, 0x34, 0x12, 0x00]
     self.assertEquals(1.234567, vm.fac2py(bytes))