Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sic branch #1

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fce0c94
sic class
MoustafaAshraf8 Dec 28, 2022
af66d69
sic parser
MoustafaAshraf8 Dec 28, 2022
9f3172c
error class + utilities functions
MoustafaAshraf8 Dec 28, 2022
a148c8a
sic load map/ symbol table
MoustafaAshraf8 Dec 28, 2022
52435ca
memory structure
MoustafaAshraf8 Dec 28, 2022
09c4592
fill memory with T records and modify by M records
MoustafaAshraf8 Dec 29, 2022
cb4bf82
test files
MoustafaAshraf8 Dec 29, 2022
dd26fc9
Res dir for result files
MoustafaAshraf8 Dec 29, 2022
f3e3e36
Res folder for SIC + modifications for main
MoustafaAshraf8 Dec 29, 2022
9e135fc
show method + class name modified
MoustafaAshraf8 Dec 29, 2022
0ae1e56
Merge pull request #2 from MoustafaAshraf8/SICbranch
MoustafaAshraf8 Dec 29, 2022
704e51f
Merge pull request #3 from MoustafaAshraf8/dev
MoustafaAshraf8 Dec 29, 2022
77bd028
changes
MoustafaAshraf8 Dec 29, 2022
996544a
Merge pull request #4 from MoustafaAshraf8/dev
MoustafaAshraf8 Dec 29, 2022
39ff2c7
sicxe class
MoustafaAshraf8 Dec 29, 2022
6245220
sicxe parser
MoustafaAshraf8 Dec 29, 2022
ec2df07
sicxe LoadMap/external symbole table
MoustafaAshraf8 Dec 29, 2022
a250625
sicxe memory structure
MoustafaAshraf8 Dec 29, 2022
068bb29
sicxe memory fill
MoustafaAshraf8 Dec 29, 2022
7ffd4da
main handling
MoustafaAshraf8 Dec 29, 2022
eceda5a
Res dir for result files + modifications on main
MoustafaAshraf8 Dec 29, 2022
c6e2163
Merge pull request #5 from MoustafaAshraf8/SICXEbranch
MoustafaAshraf8 Dec 29, 2022
7b3362f
Merge pull request #6 from MoustafaAshraf8/dev
MoustafaAshraf8 Dec 29, 2022
3d6f9ae
up-to-date
MoustafaAshraf8 Dec 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Class/SICXEClass.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pandas as pd
from pandasgui import show
class SICXE:
df: pd.DataFrame
LoadMap: pd.DataFrame
DataList: list
HeaderList: list
DFlist: list
MEMORY: pd.DataFrame
def __init__(self):
return

def printdf(self):
print(self.df)

def MemoryShow(self):
show(self.MEMORY)
16 changes: 16 additions & 0 deletions Class/SICclass.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import pandas as pd
from pandasgui import show
class SIC:
df: pd.DataFrame
DFlist: list
LoadMap: pd.DataFrame
MEMORY: pd.DataFrame

def __init__(self):
return

def printdf(self):
print(self.df)

def MemoryShow(self):
show(self.MEMORY)
Binary file added Class/__pycache__/ProgramClass.cpython-310.pyc
Binary file not shown.
Binary file added Class/__pycache__/ProgramClass.cpython-39.pyc
Binary file not shown.
Binary file added Class/__pycache__/SICXEClass.cpython-310.pyc
Binary file not shown.
Binary file added Class/__pycache__/SICclass.cpython-310.pyc
Binary file not shown.
Empty file added ErrorClass/ExceptionClass.py
Empty file.
Binary file added ErrorClass/__pycache__/ExceptionClass.cpython-39.pyc
Binary file not shown.
2 changes: 2 additions & 0 deletions SIC/Res/loadmapSIC.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
address length end
COPY 001000 00007A 00107A
Binary file added SIC/Res/loadmapSIC.xlsx
Binary file not shown.
41 changes: 41 additions & 0 deletions SIC/SICloadmap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import pandas as pd
import numpy as np
import os
import glob
import Class.SICclass as sic
import utilities.HexaAddition as f
import ErrorClass as Err

def loadMap(prog: sic, Launch:str):
print("------------LoadMap-sic-------------------------")

DFlist = prog.DFlist
info = []
rowList = []


for df in DFlist:

progName = df.iloc[0,0][1:][:5] #program name,start address,length, actual start
progStart = df.iloc[0,0][6:][:6]
proglen = df.iloc[0,0][-6:]
actualStart = f.hexaAddition(progStart,proglen)


# lst = df.iloc[0,0].split()
# progName = lst[0][1:]
# progStart = lst[1][:6]
# proglen = lst[1][6:]
# actualStart = f.hexaAddition(progStart,proglen)

rowList.append(progName) #insert progName as row index
info.append((progStart,proglen,actualStart)) #insert prog info

LMdf = pd.DataFrame(info,index=rowList,columns=["address","length","end"])
prog.LoadMap = LMdf

LMdf.to_excel("SIC/Res/loadmapSIC.xlsx")
LMdf.to_csv("SIC/Res/loadmapSIC.txt",sep="\t")
print(prog.LoadMap)

return prog
54 changes: 54 additions & 0 deletions SIC/SICmemory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import pandas as pd
import numpy as np
import os
import glob
import Class.SICclass as sic
import utilities.HexaAddition as f
import utilities.HexaComparison as hexcomp
from pandasgui import show
import ErrorClass as Err


def memorySetup(prog: sic):
print("----------------------------Memory-sic--------------------------")
DFlist = prog.DFlist
LM = prog.LoadMap
startAddress = LM.iloc[0,0]
endAddress = f.hexaAddition(startAddress,LM.iloc[0,1])[:5]+"0"
#print(startAddress)
#print(endAddress)
MEMcol = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]
# maxlen = "0"
# for ind in LM.index:
# a = LM.loc[ind]["start"]
# b = LM.loc[ind]["length"]
# endAddress = f.hexaAddition(a,b)[:5]+"0"
# if(hexcomp.hexaCompare(endAddress,maxlen) == True):
# maxlen = endAddress
# print(maxlen)
# print(endAddress)
# print(hexcomp.hexaCompare(endAddress,maxlen))

# endAddress = max
# print(type(endAddress))



startAddress = startAddress[:5]+"0"
MEMrow = []
while 1:
MEMrow.append(startAddress)
startAddress = f.hexaAddition(startAddress,"10")
if(MEMrow[-1] == endAddress):
break

MEMORY = pd.DataFrame(index=MEMrow,columns=MEMcol)
MEMORY.fillna("-", inplace=True)
prog.MEMORY = MEMORY
# #print(MEMORY)
# # for df in DFlist:
# # for index,row in df.iterrows():
# # if(row[:1] == "T"):
# # print(row[1:7])
print(MEMORY.to_string())
return prog
65 changes: 65 additions & 0 deletions SIC/SICmemoryFill.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import pandas as pd
import numpy as np
import os
import glob
import Class.SICclass as sic
import utilities.HexaAddition as f
import utilities.HexaComparison as hexcomp
from pandasgui import show
import ErrorClass as Err

lst = []
def splittxt(s):
if(len(s) == 0):
return lst
lst.append(s[:2])
splittxt(s[2:])

def TrecordPlacement(progaddress,row,memory):
#start = f.hexaAddition(row[0][1:7],progaddress) #actual start address of T record
#print(start)
Tstart = row[0][1:7]
opcode = row[0][9:] #T record - ('T',start address,length)
lst.clear()
splittxt(opcode) #opcode -> list of (2) hexa digits
#print(lst)
for i in range(0,len(lst)):
byte = lst[i] #2 hexa to place
#print(byte)

actualaddress = f.hexaAddition(Tstart,hex(i)) #convert i to hexa, heaxaAddition takes hexa values
#print(actualaddress)
#print(byte)
#print(actualaddress)
row = actualaddress[:5]+"0"
col = actualaddress[5:]
#print(row,col)
memory.loc[row[:6],col] = byte
lst.clear()




def memoryFill(prog: sic):
print("----------------------------Memory-sic-fill--------------------------")
MEMORY = prog.MEMORY
#print(MEMORY)
LoadMap = prog.LoadMap
#print(MEMORY)

DFlist = prog.DFlist
for df in DFlist:
for index,row in df.iterrows():
if(row[0][:1] == "T"):
#print(row[0])
progname = df.iloc[0,0][1:][:5]
#print(progname)
progaddress = LoadMap.loc[progname,"address"]
TrecordPlacement(progaddress,row,MEMORY)
#print(row[0][0])
MEMORY.replace(to_replace = np.nan, value ="-", inplace=True)
prog.MEMORY = MEMORY
print(MEMORY.to_string())
#print(MEMORY.loc["002070","A"])
#show(MEMORY)
return prog
25 changes: 25 additions & 0 deletions SIC/SICparser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import pandas as pd
import numpy as np
import Class.SICclass as sic
import ErrorClass as Err
# from pandasgui import show
def parseFile(FilePath):
print("------------Parser-sic--------------------------")
prog = sic.SIC
df = pd.read_csv(FilePath, delimiter='\t',header=None)
prog.df = df
DFlist = []
i = 1
start = 0
end = 0
for x in range(len(df)):
if(df.iloc[x,0][:1] == "E"):
end = i
DFlist.append(df[start:end])
start = end
i=i+1
prog.DFlist = DFlist #list of df/programs

#print(len(DFlist))

return prog
Binary file added SIC/__pycache__/AbsoluteLoader.cpython-310.pyc
Binary file not shown.
Binary file added SIC/__pycache__/SICloadmap.cpython-310.pyc
Binary file not shown.
Binary file added SIC/__pycache__/SICmemory.cpython-310.pyc
Binary file not shown.
Binary file added SIC/__pycache__/SICmemoryFill.cpython-310.pyc
Binary file not shown.
Binary file added SIC/__pycache__/SICparser.cpython-310.pyc
Binary file not shown.
10 changes: 10 additions & 0 deletions SICXE/Res/loadmap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
address length start program
PROGA 000000 000063 004000 -
LISTA 000040 000000 004040 PROGA
ENDA 000054 000000 004054 PROGA
PROGB 000000 00007F 004063 -
LISTB 000060 000000 0040C3 PROGB
ENDB 000070 000000 0040D3 PROGB
PROGC 000000 000051 0040E2 -
LISTC 000030 000000 004112 PROGC
ENDC 000042 000000 004124 PROGC
Binary file added SICXE/Res/loadmap.xlsx
Binary file not shown.
50 changes: 50 additions & 0 deletions SICXE/SICXEloadMap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import pandas as pd
import numpy as np
import os
import glob
import Class.SICXEClass as sicxe
import utilities.HexaAddition as f
import ErrorClass as Err

def loadMap(prog: sicxe.SICXE, Launch:str):
print("------------LoadMap-sicxe-------------------------")

DFlist = prog.DFlist
info = []
rowList = []
LaunchAddress = Launch ####input from user

for df in DFlist:

# lst = df.iloc[0,0].split()
# progName = lst[0][1:]
# progStart = lst[1][:6]
# proglen = lst[1][6:]
# actualStart = f.hexaAddition(progStart,Launch)

progName = df.iloc[0,0][1:][:5] #program name,start address,length, actual start
progStart = df.iloc[0,0][7:][:6]
proglen = df.iloc[0,0][-6:]
actualStart = f.hexaAddition(LaunchAddress,progStart)

rowList.append(progName) #insert progName as row index
info.append((progStart,proglen,actualStart,"-")) #insert prog info

extDef = df.iloc[1,0][1:].split()
DIC = {extDef[i]: extDef[i + 1] for i in range(0, len(extDef), 2)}
for x in DIC:
rowList.append(x)
info.append((DIC[x],"000000",f.hexaAddition(LaunchAddress,DIC[x]),progName))

LaunchAddress = f.hexaAddition(actualStart,proglen) #update launch address

LMdf = pd.DataFrame(info,index=rowList,columns=["address","length","start","program"])
prog.LoadMap = LMdf
files = glob.glob('./Res/*')
for q in files:
os.remove(q)
LMdf.to_excel("SICXE/Res/loadmap.xlsx")
LMdf.to_csv("SICXE/Res/loadmap.txt",sep="\t")
print(prog.LoadMap)

return prog
40 changes: 40 additions & 0 deletions SICXE/SICXEmemory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import pandas as pd
import numpy as np
import os
import glob
import Class.SICXEClass as sicxe
import utilities.HexaAddition as f
from pandasgui import show
import ErrorClass as Err


def memorySetup(prog: sicxe):
print("----------------------------Memory---------------------------")
DFlist = prog.DFlist
LM = prog.LoadMap
startAddress = LM.iloc[0,2][:5]+"0"
endAddress = 0
for ind in LM.index:
if(LM.loc[ind]["program"] == "-"):
a = LM.loc[ind]["start"]
b = LM.loc[ind]["length"]
endAddress = f.hexaAddition(a,b)[:5]+"0"

MEMcol = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]
MEMrow = []
while 1:
MEMrow.append(startAddress)
startAddress = f.hexaAddition(startAddress,"10")
if(MEMrow[-1] == endAddress):
break

MEMORY = pd.DataFrame(index=MEMrow,columns=MEMcol)
MEMORY.fillna("-", inplace=True)
prog.MEMORY = MEMORY
#print(MEMORY)
# for df in DFlist:
# for index,row in df.iterrows():
# if(row[:1] == "T"):
# print(row[1:7])
print(MEMORY)
return prog
Loading