First two are written in assembly (in the way exist is one to one
corrispondence)
the last is a subset of C++ that is more near to C
------------
; char* __stdcall MemCat_m(char* des, char* ori, int nc)
; ritorna la posizione a cui e' arrivato nel vettore di char "des"
; s=0j, 4i, 8b, 12ra, 16Ades, 20Aori, 24Anc
align 4
MemCat_m:
<b,i,j
j=[s+16]|b=[s+20]|i=[s+24]
i==0#.2 |j==0#.2
.1: al=*b|*j=al|++b,j|--i#.1
.2: a=j
.cf:
>b,i,j
ret 12
; -1 cf==1 per errore
; 0 cf==0 tutto ok
; 0ra, 4P
align 4
ZeroFree:
a=^4|a==0#.f
GetSize(a)|jnc .1
.e: a=-1|stc|#.z
.1: r=^4|Zero(r, a)
a=^4|Free_m(a)|jc .e
.f: a^=a
.z:
ret 4
----------
#define F for
#define P printf
#define R return
#define G goto
// ritorna 0 errore 1 tutto ok
int DaiNumeri(fnum* nDeb, fnum* nCred, u32 nConto,
Data inizio, Data fine, Conto0* filiale,
FILE_m* FileStriscieP, FILE_m* FileStriscieOldP,
FILE_m* FilePuntatoriStriscieP, FILE_m* FileSaldiP)
{i32 n_elx[2], r, r0, r1, k, n_el, j, delta;
u32 dovefile;
i8 **pi, *p, *p1, *elencox[2], *elenco;
Data dataP;
fnum saldo, t;
if(nDeb==0||nCred==0||filiale==0) R 0;
*nDeb=0; *nCred=0;
if(inizio>fine||(fine-inizio)>365) R 0;
if(fine.anno<200) R 0;
r0=StriscieContoAnno(&elencox[0], &n_elx[0], nConto, fine.anno-1,
filiale, FileStriscieP, FileStriscieOldP, FilePuntatoriStriscieP);
if(r0==0) R 0;
r1=StriscieContoAnno(&elencox[1], &n_elx[1], nConto, fine.anno,
filiale, FileStriscieP, FileStriscieOldP, FilePuntatoriStriscieP);
if(r1==0){l0:; ZeroFree(elencox[0]); R 0;}
r0=n_elx[0]; if(r0< 0){l1:; ZeroFree(elencox[1]); G l0;}
r1=n_elx[1]; if(r1< 0) G l1;
r=r0+r1; if(r < 0) G l1; if(r+2<0) G l1;
if((k=(r+2)*sizeof(Striscia))<0) G l1;
p=(char*)Malloc_m(k); if(p==0) G l1;
p1=MemCat_m(p, elencox[0], r0*sizeof(Striscia));
MemCat_m(p1, elencox[1], r1*sizeof(Striscia));
elenco=p; n_el=r;
ZeroFree(elencox[0]); ZeroFree(elencox[1]);
pi= (i8**) Malloc_m((n_el+8)*sizeof(i8*));
if(pi==0){l2:; ZeroFree(elenco); R 0;}
F(j=0; j<n_el; ++j)
pi[j]=elenco+j*sizeof(Striscia);
if(qsortPnt_m(pi, n_el, comparaStrisciaValuta)==0)
{l3:; ZeroFree(pi); G l2;}
r=SaldoInData(&saldo, &dovefile, nConto, (inizio-1),
filiale, FileStriscieP, FileStriscieOldP,
FilePuntatoriStriscieP, FileSaldiP);
if(r==-1) G l3;
cout << "Saldo iniziale in data " << (inizio-1) << " : ";
StampaSaldo(stdout_m, saldo, globalPrecision);
P("\n");
F(j=0, dataP=(inizio-1); j<n_el; ++j)
{Striscia *s1;
fnum v;
s1=(Striscia*)pi[j];
if(s1->DataValuta> fine) break;
if(s1->DataValuta>=inizio)
{if( DaCifraAfnum(&t, s1->imp)==0) G l3;
delta=(s1->DataValuta)-dataP;
dataP=(s1->DataValuta);
v=saldo*delta;
if(saldo>=0) *nCred+=v;
else *nDeb -=v;
cout << v << " ";
saldo=saldo+t;
}
else if(s1->DataOperazione>=inizio)
{if( DaCifraAfnum(&t, s1->imp)==0) G l3;
saldo=saldo+t;
cout << saldo << "s ";
}
}
ZeroFree(pi); ZeroFree(elenco);
R 1;
}
--------------------------------
the result is something like
Numero Debitore: 0.00000000000000000000F
Numero Creditore: 387475.35000000000000000110F+
i have to say that 20 cicle of the loop
"F(j=0, dataP=(inizio-1); j<n_el; ++j)"
make one error of 0.00000000000000000110F+
It doesn't help that I don't know Italian, but more off-putting is the
strange assembler syntax.
PS why not define 'if' as I?
It all smacks of BASIC programming where single letter variables were all
you had.
--
Nuns! Reverse!
"MemCat_m:" and "ZeroFree:" are address of function written
in something near to assembly
(save in some way the (1 subset of symbols) to (1 cpu instruction))
int DaiNumeri(etc)
is a C++ function
> PS why not define 'if' as I?
in the C/C++ environment, yes good idea I(a<32) G label;
but don't know if "I" is reserved for complex number representation
> It all smacks of BASIC programming where single letter variables were all you
> had.
the error of the first basic programs are in the absence of indentation
the same now for the "raw assembly"
> --
> Nuns! Reverse!
It is an esoteric asm language. Perhaps it is best described as an
'obfuscated' asm language?
Nathan.
Nathan.
it is 'obfuscated' for you
like some code people write could be 'obfuscated' for me
things are easy but
people find many way to complicate them
i find a little bug, but this would be ot (because it would be 1/2 C++ + 1/2 C)
for find it i had manually done 21 bank operation for find that the error
was in the last one;
then it seems there is one error that signal itself only one time
don't know how correct it
int DaiNumeri(fnum* nDeb, fnum* nCred, u32 nConto,
Data inizio, Data fine, Conto0* filiale,
FILE_m* FileStriscieP, FILE_m* FileStriscieOldP,
FILE_m* FilePuntatoriStriscieP, FILE_m* FileSaldiP)
{i32 n_elx[2], r, r0, r1, k, n_el, j, delta;
u32 dovefile;
i8 **pi, *p, *p1, *elencox[2], *elenco;
Striscia *s1, *s2;
Data dataP;
fnum saldo, t, v;
if(nDeb==0||nCred==0||filiale==0) R 0;
*nDeb=0; *nCred=0;
if(inizio>fine||(fine-inizio)>370) R 0;
s2=0;
F(j=0, dataP=(inizio-1); j<n_el; ++j)
{s1=(Striscia*)pi[j];
if(s1->DataValuta> fine) break;
if(s1->DataValuta>=inizio)
{if( DaCifraAfnum(&t, s1->imp)==0) G l3;
delta=(s1->DataValuta)-dataP;
dataP=(s1->DataValuta);
v=saldo*delta;
if(saldo>=0) *nCred+=v;
else *nDeb -=v;
cout << v << " ";
saldo=saldo+t;
s2=s1;
}
else if(s1->DataOperazione>=inizio)
{if( DaCifraAfnum(&t, s1->imp)==0) G l3;
saldo=saldo+t;
cout << saldo << "s ";
}
}
if(s2!=0){delta=fine-(s2->DataValuta);
v=saldo*delta;
if(saldo>=0) *nCred+=v;
else *nDeb -=v;
}
ZeroFree(pi); ZeroFree(elenco);
R 1;
}
I'm sorry, but th structure (or lack of) plus obfuscation make me
unwilling to look at what happens - maybe others are OK with it. Ciao!
--
Nuns! Reverse!
here i say can not calculate nDeb and nCred for period > 1 year
>> if(fine.anno<200) R 0;
>> r0=StriscieContoAnno(&elencox[0], &n_elx[0], nConto, fine.anno-1,
>> filiale, FileStriscieP, FileStriscieOldP, FilePuntatoriStriscieP);
here i load in memory all the bank operations of nConto in the fine.anno-1
elencox[0], with n_operation in n_elx[0]
>> if(r0==0) R 0;
if some error exit
>> r1=StriscieContoAnno(&elencox[1], &n_elx[1], nConto, fine.anno,
>> filiale, FileStriscieP, FileStriscieOldP, FilePuntatoriStriscieP);
>> if(r1==0){l0:; ZeroFree(elencox[0]); R 0;}
here the same for the fine.anno
>> r0=n_elx[0]; if(r0< 0){l1:; ZeroFree(elencox[1]); G l0;}
>> r1=n_elx[1]; if(r1< 0) G l1;
>> r=r0+r1; if(r < 0) G l1; if(r+2<0) G l1;
>> if((k=(r+2)*sizeof(Striscia))<0) G l1;
>> p=(char*)Malloc_m(k); if(p==0) G l1;
>> p1=MemCat_m(p, elencox[0], r0*sizeof(Striscia));
>> MemCat_m(p1, elencox[1], r1*sizeof(Striscia));
here cat all the elemnts in one big memory pointed by p
>> elenco=p; n_el=r;
and total element are r==n_el
>> ZeroFree(elencox[0]); ZeroFree(elencox[1]);
here free the old pointers
>> pi= (i8**) Malloc_m((n_el+8)*sizeof(i8*));
>> if(pi==0){l2:; ZeroFree(elenco); R 0;}
>> F(j=0; j<n_el; ++j)
>> pi[j]=elenco+j*sizeof(Striscia);
here pi[j] point to operation j
>> if(qsortPnt_m(pi, n_el, comparaStrisciaValuta)==0)
>> {l3:; ZeroFree(pi); G l2;}
here sort all the pi[j] pointers using "data Valuta" of the ioperation
>> r=SaldoInData(&saldo, &dovefile, nConto, (inizio-1),
>> filiale, FileStriscieP, FileStriscieOldP,
>> FilePuntatoriStriscieP, FileSaldiP);
here from one file with each year have the year "saldo" it find
the start value
>> if(r==-1) G l3;
>> cout << "Saldo iniziale in data " << (inizio-1) << " : ";
>> StampaSaldo(stdout_m, saldo, globalPrecision);
>> P("\n");
print it
this is below is how calculate from the inital "saldo" the "numeri creditori"
and "numeri debitori"
>> s2=0;
>> F(j=0, dataP=(inizio-1); j<n_el; ++j)
"inizio-1" is the day before "inizio"
if for example inizio=="1/1/2009" inizio-1=="31/12/2008"
>> {s1=(Striscia*)pi[j];
>> if(s1->DataValuta> fine) break;
>> if(s1->DataValuta>=inizio)
>> {if( DaCifraAfnum(&t, s1->imp)==0) G l3;
>> delta=(s1->DataValuta)-dataP;
>> dataP=(s1->DataValuta);
>> v=saldo*delta;
>> if(saldo>=0) *nCred+=v;
>> else *nDeb -=v;
>> cout << v << " ";
>> saldo=saldo+t;
>> s2=s1;
>> }
>> else if(s1->DataOperazione>=inizio)
>> {if( DaCifraAfnum(&t, s1->imp)==0) G l3;
>> saldo=saldo+t;
>> cout << saldo << "s ";
>> }
>> }
>>
>> if(s2!=0){delta=fine-(s2->DataValuta);
>> v=saldo*delta;
>> if(saldo>=0) *nCred+=v;
>> else *nDeb -=v;
>> }
this place is what i forget the last time
>> ZeroFree(pi); ZeroFree(elenco);
>> R 1;
>> }
>>
>>
> I'm sorry, but th structure (or lack of) plus obfuscation make me unwilling
> to look at what happens - maybe others are OK with it. Ciao!
easy
> --
> Nuns! Reverse!
True.
> things are easy but
> people find many way to complicate them
>
>
Also true.
I recently wanted to become more knowledgable about the wierd Python
language, so I quickly coded a Brainf**k interpreter. I can't think of
anything more 'esoteric' or 'obfuscated' than Brainf**k. But after writing
this interpreter, I can almost read Brainf**k code as easily as any other
language.
import sys
mem = []
stk = []
comments = []
prg =
'++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.'
mptr = 0
x = 0
# set the following value to size of memory desired
while x < 100:
mem.append(0)
x = x + 1
tkn = []
stk.append(0)
y = 0
t = 0
while y < len(prg):
c = prg[y]
if c == '+':
tkn.append(1)
elif c == '-':
tkn.append(2)
elif c == '>':
tkn.append(3)
elif c == '<':
tkn.append(4)
elif c == '.':
tkn.append(5)
elif c == ',':
tkn.append(6)
elif c == '[':
tkn.append(7)
tkn.append(0)
stk.append(t+1)
t = t + 1
elif c == ']':
tkn.append(8)
bow = stk.pop()
if bow == 0:
raise SyntaxError, "Unmatched Brackets"
tkn[bow] = t
tkn.append(bow)
t = t + 1
else:
# collect comments
comments.append(c)
y = y + 1
t = t + 1
y = 0
while y < len(tkn):
c = tkn[y]
j = 0
if c == 1:
j = mem[mptr] + 1
mem[mptr] = j
elif c == 2:
j = mem[mptr] - 1
mem[mptr] = j
elif c == 3:
if mptr == len(mem)-1:
raise RangeError, "Memory wall reached"
mptr = mptr + 1
elif c == 4:
if mptr == 0:
raise RangeError, "Memory wall reached"
mptr = mptr - 1
elif c == 5:
j = mem[mptr]
sys.stdout.write(str(chr(j)))
elif c == 6:
s = sys.stdin.read(1)
mem[mptr] = ord(s)
elif c == 7:
if mem[mptr] == 0:
j = tkn[y + 1]
y = j
y = y + 1
elif c == 8:
if mem[mptr] != 0:
j = tkn[y + 1]
y = j
else:
y = y + 1
y = y + 1
w = 0
# while w < len(mem):
# print mem[w],
# w = w + 1
# print
# w = 0
# while w < len(tkn):
# print tkn[w],
# w = w + 1
# print
Nathan.