Exemple #1
0
            def save_T(s, end):
                end = self.Lines[end]

                ans = "T.{0}.{1}.".format(
                    s.location[2:],
                    ("%2s"%Number(Number(end.location).int() - Number(s.location).int()).hex().upper()[2:]).replace(" ","0")
                )
                "array data"

                ans+=".".join(arr)
                hte.append(ans)
                print(hte)
Exemple #2
0
    def calc_value(self):
        temp = self.Name
        if temp[0].upper() == 'C':
            self.t = 0
            #convert chars to hex
            self.value = Number(temp[2:-1]).chars_to_hex()

        elif temp[0].upper() == 'X':
            if Number(temp[2:-1]).test_hex() == False:
                raise Exception(f"{temp}\t  value must to be hex")
            self.t = 1
            self.value = self.Name[2:-1]
        elif Number(temp).is_int():  # int
            self.t = 2
            self.value = temp[2:1]
        else:
            raise Exception(f" formate {type(temp[0])} is undefined")
Exemple #3
0
    def operand_pre(self, op):
        #  print(op)
        if (op == None):
            return None, None
        if not (op[0].upper().isalpha() or Number(op[0]).is_int()):
            #      print("wwwwwwwwwww")
            if op[0] == "@" or op[0] == "#" or op[0] == "=":
                #             print("ss")
                return op[0], op[1:]
            else:
                raise Exception(f" {op[0]}\tis not defined")

        else:
            return None, op
Exemple #4
0
 def __init__(self, number_3=Number(3)):
     self.number_3 = number_3
Exemple #5
0
 def test_create_number(self):
     number = Number(5)
     self.assertEqual(5, number.value)
Exemple #6
0
 def test_is_not_divisible_for(self):
     number = Number(5)
     divisible = number.is_divisible_for(Number(2))
     self.assertFalse(divisible)
Exemple #7
0
 def test_is_divisible_for(self):
     number = Number(5)
     divisible = number.is_divisible_for(Number(5))
     self.assertTrue(divisible)
Exemple #8
0
import sys

from src.fizz_buzzer import FizzBuzzer
from src.number import Number

if __name__ == '__main__':
    fizz_buzzer = FizzBuzzer()
    for i in range(1, int(sys.argv[1]) + 1):
        i_number = Number(i)
        speach_text = fizz_buzzer.speach_text_for(i_number)
        print(speach_text)
Exemple #9
0
 def setUp(self):
     self.number_3 = Number(3)
     self.fizz_buzzer = FizzBuzzer(self.number_3)
Exemple #10
0
    def pass1(self):
        #   print(self.programe)
        for l in self.programe:
            self.lineno += 1
            #   print(self.lineno)
            parts = File.split_line(l)
            flag = True
            for part in parts:

                if str(part).upper() in DIRTAB:
                    flag = False
                    self.DIR_H.handel(parts, str(part).upper())
                    break
            if flag:
                temp = Line(
                    parts,
                    self.lineno,
                    self.current_loc,
                    instr=None,
                )
                if (temp.label != None):
                    #    print(str(temp))
                    if (temp.label.upper() not in self.symtab):
                        self.symtab[temp.label.upper()] = None
                #    print(temp.label.upper(), self.symtab[temp.label.upper()])
                #    exit(0)

                self.Lines.append(temp)
                #   print(str(self.Lines[-1]))
                self.current_loc = Number(Number(self.current_loc).int() + temp.formate).hex(size=6)
                if (self.Lines[-1].label != None):
                    self.symtab[self.Lines[-1].label.upper()] = self.Lines[-1].location
            temp = self.Lines[-1]
            if temp != None:
                #    print("ssssssssssssssssssssssssssssssssssssssssssss",temp)
                if temp.pre == '=':
                    LiteralTable(self, temp.ref)
        symb = ""
        for i in self.symtab.items():
            symb += "%-6s  |" % (i[0]) + "%s|" % ("R" if i[0] not in self.sTypeA else "A") + \
                    "\t%-6s\n" % (i[1].upper()[2:])
            if (i[1] == None):
                raise Exception(f"var [{i[0]}]\tis not defined")

        if self.base is None:
            for i in self.Lines:
                if i.instruction == "LDB":
                    self.base = i.ref
        self.base = self.symtab[self.base]

        # len(self.Lines)-10  self.Lines[i].formate == 5 and not
        for i in range(0, len(self.Lines)):
            print(i)
            if not (self.Lines[i].asm):
                print("--->><<", self.Lines[i].location)
                Pass2(self.Lines, i, self.symtab, self.base)

        print("base== ", self.base)
        print(symb)
        print("**********************************************************")
        for s in self.litpoolTable:
            print(str(s))
        print("**********************************************************")
        for s in self.Lines:
            print(str(s))
        File("/media/youssef/media/SIC XE/Files/symb.txt").write(data_str=symb)
        File("/media/youssef/media/SIC XE/Files/litpoolTable.txt").write(
            data_list=[str(i) for i in self.litpoolTable])
        File("/media/youssef/media/SIC XE/Files/Lc.txt").write(data_list=[str(i) for i in self.Lines])

        "HTE RECORD"
        hte=[]
        "H"
        hte.append("H." +
              ("%-6s." % (self.name)).replace(" ", "_") +
              "%6s." % (self.start_addr[2:]) +
              str(
                  Number(
                      Number(self.current_loc[2:]).int() -
                      Number(self.start_addr).int()
                  ).hex(size=6)[2:]
              )
                   )
        "Ts"

        now = 1
        s = self.Lines[now]
        arr = []

        while True:

            def save_T(s, end):
                end = self.Lines[end]

                ans = "T.{0}.{1}.".format(
                    s.location[2:],
                    ("%2s"%Number(Number(end.location).int() - Number(s.location).int()).hex().upper()[2:]).replace(" ","0")
                )
                "array data"

                ans+=".".join(arr)
                hte.append(ans)
                print(hte)

            if now == len(self.Lines) - 1:
                print("ada")
                ans = "T.{0}.{1}.".format(
                    s.location[2:],
                    ("%2s"%str(Number(Number(self.current_loc).int() - Number(s.location).int()).hex().upper())[2:]).replace(" ","0")
                )
                "array data"

                ans+=".".join(arr)
                hte.append(ans)
                break

            if len(self.Lines[now].instruction_list) != 3 and self.Lines[now].asm == True:
                now += 1
            elif Number(self.Lines[now].location).int() - Number(s.location).int() > 29:
                print(now)
                now -= 1
                t=arr[-1]
                arr=arr[:-1]
                save_T(s, now )

                arr = []
                arr.append(t)

                s = self.Lines[now]
                now+=1
             #   exit(0)
            elif len(self.Lines[now].instruction_list) == 3 and self.Lines[now].asm == True and self.Lines[now].object_code is None:
                save_T(s, now )

                arr = []
                temp_now = now
                print(now)
                while self.Lines[temp_now].object_code is None:
                    print("       ", self.Lines[temp_now].instruction_list)
                    temp_now += 1
                now = temp_now
                s = self.Lines[now]
                print(now)
            else:
                print(self.Lines[now].instruction_list, len(self.Lines[now].instruction_list) == 3,
                      self.Lines[now].asm == True)
                arr.append(self.Lines[now].object_code)
                print(now, arr)
                now += 1

        hte.append("E.{0}".format(self.start_addr[2:]))
        print("******************************")
        for ssyy in hte:
            print("".join(ssyy) )
        File("/media/youssef/media/SIC XE/Files/HTE.txt").write(
            data_list=["".join(i)  for i in hte])