def printMemEngine(command): base = command[2] # x or d address = command[3] freq = command[1] listOfHex = '' address = int(address, 16) #assume to be in hex freqcount = int(freq[0:-1]) freqtype = freq[-1] # b w or d numOfBits = '' if freqtype == 'w': for i in range(freqcount): data = mem.fetchWordFromMemory(address + (4 * i)) if data == const.TRAP: print 'Memory location could not be accessed' return listOfHex += data + ' ' numOfBits = 32 elif freqtype == 'd': for i in range(0, freqcount): data1 = mem.fetchWordFromMemory(address + (8 * i)) data2 = mem.fetchWordFromMemory(address + (8 * i) + 4) if data1 == const.TRAP or data2 == const.TRAP: print 'Memory location could not be accessed' return listOfHex += data2 + '' + data1 + ' ' numOfBits = 64 elif freqtype == 'b': for i in range(0, freqcount): data = mem.fetchByteFromHelperMemory(address + i) if data == const.TRAP: print 'Memory location could not be accessed' return listOfHex += data + ' ' numOfBits = 8 listOfHex = listOfHex.split() #print '' #print listOfHex #print '<'+command[3]+'>'+' : \t\t', pretty = 0 for i in listOfHex: if (pretty % 4 == 0): print '' print '<' + command[3] + '>' + ' + ' + str( (pretty * numOfBits) / 8) + ' : \t\t', if base == 'x': print '0x' + i + '\t\t', elif base == 'd': binary = utilFunc.hexToBin('0x' + i, numOfBits) print str(utilFunc.sInt(binary, numOfBits)) + '\t\t', print ' ', pretty = pretty + 1 print ''
def printMemEngine(command): base=command[2] # x or d address=command[3] freq=command[1] listOfHex='' address=int(address,16) #assume to be in hex freqcount=int(freq[0:-1]) freqtype=freq[-1] # b w or d numOfBits='' if freqtype=='w': for i in range(freqcount): data=mem.fetchWordFromMemory(address+(4*i)) if data==const.TRAP: print 'Memory location could not be accessed' return listOfHex+=data+' ' numOfBits=32 elif freqtype=='d': for i in range(0,freqcount): data1=mem.fetchWordFromMemory(address+(8*i)) data2=mem.fetchWordFromMemory(address+(8*i)+4) if data1==const.TRAP or data2==const.TRAP: print 'Memory location could not be accessed' return listOfHex+=data2+''+data1+' ' numOfBits=64 elif freqtype=='b': for i in range(0,freqcount): data=mem.fetchByteFromHelperMemory(address+i) if data==const.TRAP: print 'Memory location could not be accessed' return listOfHex+=data+' ' numOfBits=8 listOfHex=listOfHex.split() #print '' #print listOfHex #print '<'+command[3]+'>'+' : \t\t', pretty=0 for i in listOfHex: if (pretty%4==0): print '' print '<'+command[3]+'>'+' + '+str((pretty*numOfBits)/8)+' : \t\t', if base=='x': print '0x'+i+'\t\t', elif base=='d': binary=utilFunc.hexToBin('0x'+i, numOfBits) print str(utilFunc.sInt(binary, numOfBits))+'\t\t', print ' ', pretty=pretty+1 print ''
def fetch32bitDataFromMem(address): hexData = mem.fetchWordFromMemory(address) if (hexData == const.TRAP): return const.TRAP return hexToBin(hexData)
def fetch32bitDataFromMem(address): hexData = mem.fetchWordFromMemory(address) if(hexData == const.TRAP): return const.TRAP return hexToBin(hexData)