NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import MySQLdb



import re
import sys
from io import BytesIO
import copy


#work([['P1',0]],'/Users/mucan/Documents/hys.asm',200)

def getv(c):
val=[]
if(c.find(':')!=-1):
i=c.find(':')
while(c[i]==' '):
i=+1
c=c[c.find(':')+i:len(c)]
sp=c.find(' ')
c=c[sp:len(c)].replace(" ", "")
while True:
if(c.find(',')!=-1):
s=c[0:c.find(',')]
val.append(s)
c=c[c.find(',')+1:len(c)]
else:
val.append(c)
break

return val


def convert(item):
if(str(item).find('#')!=-1):
item=item[1:len(item)]
if(str(item).find('H')!=-1):
item=item[0:len(item)-1]
return int(item, 16)
if(str(item).find('B')!=-1):
item=item[0:len(item)-1]
return int(item, 2)
if(str(item).find('D')!=-1):
item=item[0:len(item)-1]
return item
else:
return item

def mov_v(s1, memd):
s1=str(s1)
if(s1[len(s1)-1]=='H'):
s1=int(s1[0:len(s1)-1])
if(s1 in memd):
va=memd.index(s1)
return mem[va][1]
else:
return 0

def mov_check(s2, memd,a):
s2=str(s2)

if(s2.find('@')==-1):
if(s2.find('#')!=-1 and a==2):
return convert(s2)
else:
if a==1:
if(s2[len(s2)-1]=='H'):
s2=int(s2[0:len(s2)-1])
return s2
elif a==2:
return mov_v(s2,memd)
else:
s2=s2[1:len(s2)]
s2=mov_v(s2, memd)
if(a==1):
return s2
else:
return convert(mov_v(s2, memd))


def mov_d(s1, s2, memd):
if(s1 in memd):
va=memd.index(s1)
mem[va]=[mem[va][0],s2]
else:
mem.append([s1,s2])


def work():

global point
global total
global totalpoint
global endpoint
db = MySQLdb.connect(host="mysql.hostinger.web.tr", # your host, usually localhost
user="u327424740_kbu", # your username
passwd="__12961993__", # your password
db="u327424740_kbu") # name of the data base

# you must create a Cursor object. It will let
# you execute all the queries you need
cur = db.cursor()

# Use all the SQL you like
cur.execute("SELECT * FROM sinav Where ID='{0}'".format(sys.argv[1]) )
rows=cur.fetchall()
totalpoint=[]
inputs=[]
outputs=[]
print cur.fetchall()
print rows
inputArray=rows[0][10].split(';')
for item in rows[0][10].split(';'):
if(item!=''):
inputs.append(eval(item))
for item in rows[0][11].split(';'):
if(item!=''):
outputs.append(eval(item))

global mem
mem=[]
code=rows[0][8].replace("t", "")
code=code.splitlines()

content=[]
c1=0
end=0

content = [x.strip().upper() for x in code]

loop=len(content)
x=0
x_wt=sys.argv[2]*loop
x_crnt=0
z=0
xout=0
for a in content:
if(a.find('DB')!=-1):
x=z
break
z=z+1
if(z>=len(content)):
z=0
break
while (xout<=len(outputs)-1):
mem=[]
if(xout==len(outputs)):
break
if(inputs!='[]'):
for item in inputs[xout]:
mem.append([item[0],item[1]])
while x < loop:
if(x_crnt>x_wt):
break
x_crnt=x_crnt+1
memd=[]
item=content[x]
memd=[a[0] for a in mem]
if(item.find('MOV')!=-1 and item.find('MOVC')==-1):
if(item.find('DPTR')==-1):
val=getv(item)
val[0]=mov_check(val[0],memd,1)
val[1]=mov_check(val[1],memd,2)
mov_d(val[0],convert(val[1]),memd)
else:
mov_d('DPTR', item[item.find('#')+1:len(item)],memd)
if(item.find('ADD')!=-1):
val=getv(item)
val[1]=mov_check(val[1],memd,2)
val[0]=mov_check(val[0],memd,1)
if(int(mov_v(val[0],memd))+int(val[1])<=255):
mov_d(val[0],int(mov_v(val[0],memd))+int(val[1]),memd)
else:
mov_d(val[0],int(mov_v(val[0],memd))+int(val[1])-255,memd)
mov_d('C',1,memd)
if(item.find('INC')!=-1):
val=getv(item)
if(int(mov_v(val[0],memd))+1>255):
mov_d(val[0],0,memd)
else:
mov_d(val[0],int(mov_v(val[0],memd))+1,memd)
if(item.find('DEC')!=-1):
val=getv(item)
if(int(mov_v(val[0],memd))-1<0):
mov_d(val[0],255,memd)
else:
mov_d(val[0],int(mov_v(val[0],memd))-1,memd)
if(item.find('DB')!=-1):
val=item[item.find('DB')+3:len(item)]
y=1
if(x+1<=len(content)-1):
y=getv(content[x+1])
while(y=="['0']"and x+1<=len(content)):
val=val+content[x+1]
x=+1
if(x+1<=len(content)):
y=getv(content[x+1])
else:
break
mov_d(item[0:item.find(':')],val,memd)
if z!=0:
z=0
x=0

if(item.find('JZ')!=-1):
val=getv(item)
if(mov_d('A')==0):
x=content.index(val[1]+':')

if(item.find('JNZ')!=-1 and item.find('DJNZ')==-1):
val=getv(item)
if(mov_v('A',memd)!=0):
x=content.index(val[0]+':')

if(item.find('JC')!=-1):
val=getv(item)
if(mov_d('C')!=0):
x=content.index(val[1]+':')

if(item.find('JNC')!=-1):
val=getv(item)
if(mov_v('C',memd)==0):
x=content.index(val[1]+':')

if(item.find('SJMP')!=-1):
item=item.replace(" ", "")
x=content.index(item[4:len(item)]+':')

if(item.find('DJNZ')!=-1):
val=getv(item)
s=int(mov_v(val[0],memd))-1
mov_d(val[0],s,memd)
if(s>0):
x=content.index(str(val[1])+':')


if(item.find('SETB')!=-1):
val=getv(item)
s=val[0]
s=int(s[s.find('.')+1])
s=2**s
b=mov_v(val[0][0:val[0].find('.')],memd)
nv=s|int(b)
mov_d(val[0][0:val[0].find('.')],nv,memd)


if(item.find('CLR')!=-1):
val=getv(item)
s=val[0]
if(s.find('.')!=-1):
b=mov_v(s[0:s.find('.')],memd)
s=int(s[s.find('.')+1])
b=bin(b)
nv=b[0:len(b)-1-s]+'0'+b[len(b)-s:len(b)]
nv=int(nv,2)
mov_d(val[0][0:val[0].find('.')],nv,memd)
else:
mov_d(val[0],'0',memd)

if(item.find('CJNE')!=-1):
val=getv(item)
val[0]=mov_check(val[0],memd,2)
val[1]=mov_check(val[1],memd,2)
if(val[0]!=val[1]):
x=content.index(val[2]+':')

if(item.find('SWAP')!=-1):
val=getv(item)
b=mov_v(val[0],memd)
b=hex(int(b))
if(len(b)==3):
b='0x0'+str(b[2])
c='0x'+str(b[len(b)-1])+str(b[len(b)-2])
c=int(c, 16)
mov_d(val[0],c,memd)

if(item.find('XCHD')!=-1):
val=getv(item)
s1=mov_check(val[0],memd,1)
s2=mov_check(val[1],memd,2)
s1=hex(int(mov_v(s1,memd)))
s2=hex(int(s2))
if(len(s2)==3):
s2='0x0'+str(s2[2])
if(len(s1)==3):
s1='0x0'+str(s1[2])
b1='0x'+str(s1[len(s1)-2])+str(s2[len(s2)-1])
b2='0x'+str(s2[len(s2)-2])+str(s1[len(s1)-1])
mov_d(mov_check(val[0],memd,1),int(b1, 16),memd)
mov_d(mov_check(val[1],memd,1),int(b2, 16),memd)

if(item.find('MOVC')!=-1 and item.find('DPTR')!=-1):
if(item.find('DPTR')!=-1 and item.find('@A')!=-1):
a=(mov_v(mov_v('DPTR',memd),memd)).split(',')
b=mov_v('A',memd)
if(int(b)>len(a)):
b=len(a)-int(b)
mov_d('A',int(a[int(b)]),memd)

if(item.find('MUL AB')!=-1):
s1=mov_check('A',memd,2)
s2=mov_check('B',memd,2)
mul=int(s1)*int(s2)
if(mul>255):
mov_d('OV',1,memd)
mul=hex(mul)
mul=mul[2:len(x)]
while(len(x)<4):
mul='0'+mul
s2='0x'+mul[0:2]
s1='0x'+mul[2:4]

mov_d('C',0,memd)
mov_d('A',int(s2, 16),memd)
mov_d('B',int(s1, 16),memd)

if(item.find('SUBB')!=-1):
val=getv(item)
s1=mov_check(val[0],memd,2)
s2=mov_check(val[1],memd,2)
if(s1>=s2):
mov_d('A',int(s1)-int(s2),memd)
else:
s3=bin(s2-s1)
x=len(s3)
while(x>1):
if(s3[x]=='1'):
y=y+'0'
else:
y=y+'1'
x=x-1
y='0b'+y
y=bin(y)
y=y+1
mov_d('C',1,memd)
mov_d('A',int(str(y),2),memd)

if(item.find('CPL')!=-1):
val=getv(item)
s=val[0]
s=int(s[s.find('.')+1])
b=mov_v(val[0][0:val[0].find('.')],memd)
b=bin(b)
if(b[len(b)-1-s]==1):
s=2**s
s=127-s
b=b&s
else:
s=2**s
b=int(b,2)|int(s)
mov_d(val[0][0:val[0].find('.')],int(b),memd)


if(item.find('DIV AB')!=-1):
s1=mov_check('A',memd,2)
s2=mov_check('B',memd,2)
mov_d('A',int(int(s1)/int(s2)),memd)
mov_d('B',int(int(s1)%int(s2)),memd)

if(item.find('END')!=-1):
break


x+=1
total=0
point=0
for item in outputs[xout]:
total=+1
print mem
print item[0]
print item[1]
print mov_check(item[0],memd,2)
if mov_check(item[0],memd,2)==item[1]:
point=+1
totalpoint.append(point/total)
xout=+1
if(xout==len(outputs)):
break
if(len(totalpoint)!=0):
endpoint=sum(totalpoint)/len(totalpoint)
else:
endpoint=sum(totalpoint)
cur.execute ("UPDATE sinav SET puan={0}, durum={1} WHERE ID={2}".format(endpoint,'1',sys.argv[1]))
db.commit()
db.close()






if __name__ == "__main__":
work()
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.