One RosAsm Pre-parser



TITLE NewParser

;;

If you want to write a new RosAsm Pre-Parser, this is the room where to start:
Author name: Rosario
eMail: ...
Home Page, if any: ...
______________________________________________________________________

Description (Purpose / Syntaxe(s) / ...).

This has to be a text, ready to be included inside the B_U_Asm File, and you
should
first write this before writing any Instruction. If you are not able to
provide the
user Manual, at least partially and temporary, *before* writing the
Implementation,
you have a real problem...
----------------------------------------------------------------------
I wrote this code because many programmers wrote/write many useful
application (RosAsm is one of them) or library using gpl or
the free license, even if i'm nobody and the code came from me
is spaghetti code i want to contribute too.
So all this code has the same license of Betov RosAsm, so
or GPL-RosAsm or RosAsm license and could go with RosAsm.

it is easy, for me to make errors so you not assume
this code can be safe; for what i know it could provoke
dangers and disasters.

The sys can crash in its use many times.

I don't know well how my code work (it is a miracle
how all run well) not i know how RosAsm work so possible i
generate damages in insert this.

i didn't follow what Betov said for pre-parsers, and
the hire written AssociatoreDiStatements() function
write all the RosAsm "StatementsTable" too and i don't
know what follow from that.

Note sull'uso
Declino ogni responsabilità per qualsiasi danno che
potrebbe arrecare questo programma, o il suo risultato
e declino ogni garanzia implicita o esplicita che
questo programma serva a qualche cosa.

Spiegazione
Il Pre-Parser tratta un file di input di istruzioni
che espande (usando alcune macro) e dovrebbe permettere
a RosAsm di compilarlo. Tale file di input di istruzioni
di testo in linguaggio assembly per la cpu 386 Intel
dovrà essere scritto usando la stessa sintassi di Nasm
(- le macro di Nasm) o di RosAsm + RosAsm macro
(-meno qualche macro/espressione incompatibile vedi
gli esempi).

Questo è un Pre-Parser + un insieme di macro,
con l'obiettivo di non abolire le micro-istruzioni
dell'assembly pur trovando un modo per evidenziare
i loop e gli if. In pratica si usa l'indentazione ed
le multi istruzioni per linea per ottenere
programmazione strutturata in assembly, che mostra
come i goto o i salti, cosi' comuni in assembly,
possono, se correttamente indentati, costituire
programmi molto leggibili [a differenza di quello che
dice la gente sui goto]. In pratica si passa da un
codice in una dimensione [1 istruzione per linea] a
codice in 2 dimensioni [piu' istruzioni per linea +
indentazione].

Spero che qualche programmatore usi questo linguaggio
e non perda la speranza nel considerare il linguaggio
assembly il linguaggio migliore di tutti.


****Funzionamento****
Nota Bene:
RosAsm che ho utilizzato per l'istallazione è V.2.050a

Per l'istallazione
* Bisogna fare una copia di RosAsm, aprire la copia di
RosAsm con l'altro RosAsm

* incollare questo file tutto nel tab: "NewParser"

* Si è reso necessario cambiare qualche cosa nel codice
in RosAsm, per poter funzionare: bisogna mettere la linea

"call QuiCancellaMemoriaNewParser" ; <<NOTE THIS##

nella funzione Main() prima di

"call 'Kernel32.ExitProcess' D$FWparam"

perchè, dato il numero elevato di macro definizioni
mi sembra meglio caricarle una volta sola, alla prima
compilazione, e liberare la memoria alla fine quando il
programma termina.

bisogna mettere

"call NewParser ; Volunteers private room" ; <<NOTE THIS##

prima di

"call CoolParsers"

nella funzione AsmMain();

inoltre, nello stesso file:
cmp D$AzioneDaFareMacro2D, 1|jz @w1 ; <<NOTE THIS##
call NewCountStatements ; <<NOTE THIS##
@w1: ; <<NOTE THIS##

nella funzione AsmMain infatti la tabella
degli statement la riempiamo con questo codice.

* Riassumendo:
;------------------------------- RosAsm AsmMain ------
AsmMain:
....
call GetAsmTables ; files ready for read in
'CodeSource'
call ClearUserStubMainData
call BarProgress

; ------------------------------- First Parsers Jobs -

If B$ProfilerFlag = &TRUE
call InjectedCopyToCodeSourceA, D$CodeSource, D$SourceLen
Else
call NewCopyToCodeSourceA D$CodeSource, D$SourceLen
End_If
; int3
call NewParser ; Volunteers private room ; <<NOTE THIS##

call CoolParsers
;jmp L7>>
cmp D$AzioneDaFareMacro2D, 1|jz @w1 ; <<NOTE THIS##
call NewCountStatements ; <<NOTE THIS##
@w1: call BarProgress ; <<NOTE THIS##

call NewPrepareExport
....
ret
; ------------------------- RosAms Main
Main:
.....
.....
L1: call 'User32.GetMessageA' FirstMsg 0 0 0

cmp eax 0 | ja L0<<

; call ReleaseFonts
call UpdateRegistry

call 'KERNEL32.FreeLibrary' D$RichEditHandle

; call 'USER32.DestroyAcceleratorTable' D$AccelHandle

call QuiCancellaMemoriaNewParser ; <<NOTE THIS##
call 'Kernel32.ExitProcess' D$FWparam
------------------------------------------------
Per usarlo si deve scrivere all'inizio del file di
codice, oppure subito dopo linee di tipo "TITLE"
oppure "PREPARSE" **prima di tutti i commenti**
(; ed \n;;\n) ed iniziando dal primo carattere della
linea
* per avere tutte le macro
PREPARSE MACRO2D

* oppure per avere un linguaggio simile a Nasm
(in cui le macro non sono caricate)
ma resta la possibilità di definirle
PREPARSE ROSNASM

------------------------------------------------------
Il modo di procedere per imparare il linguaggio che
e' sottointeso e' imparare a memoria tutte le macro
istruzioni che seguono nella sezione dati ".data"
oppure "[]"
(semplicissimo perche' sono
intuitive e poche) e usandole bene per costruire
programmi strutturati.

Alcune particolarita':
* Commenti di linea: "/*" ed ";" sono stringhe di
inizio per commenti che finisco quando finisce la
linea ["\n"]

* Commenti multilinea: "\n;;\n" e' la stringa iniziale
per commenti multilinea che finiscono con "\n;;\n"

* \n;* e' commento
semplice per la traduzione verso RosAsm assembly

* Per permettere a piu' istruzioni di condividere la
stessa linea si usa il separatore "|"

* Alcuni registri hanno nuovi nomi esempio "a" sta
per eax: a->eax, b->ebx, c->ecx, r->edx, i->esi
j->edi, s->esp, k->ebp, rx->dx, jx->di, ix->si
sx->sp, kx->kp, rh->dh, rl->dl.
(i nomi degli altri registri o sottoregistri
sono quelli che usa nasmw ).

* E' possibile utilizzare stringhe come nomi di
stringhe a patto che siano di lunghezza >=5 e.g.
section .data
"stri=%i" db "stri=%i", 0
....
section .text
....
printf<("stri=%i", eax);
che dovrebbe avere traduzione in qualcosa come
[striIIi: B$ "stri=%i", 0]
....
push eax|push striIIi|call printf|add esp, 8

* Le istruzioni
mov eax, 4|98| a=4|8 | mov eax, 7*9+45
non ottengono le corrette traduzioni; quello che si
potrebbe fare e' mettere le parentesi tonde,
mov eax, (4|98) -> mov eax , (4 or 98)
a=(4|98) -> mov eax , (4 or 98)
mov eax, (7*9+45) -> mov eax , (7*9+45)
fun(8*9+45, c) -> push ecx |push 8*9+45 |call fun

a( (&SYSEQ1|&SYSEQ2), (8|4), (nome1&nome2) ) ->
push (nome1 and nome2 ) |push (8 or 4) |push ( &SYSEQ1 or &SYSEQ2 )
|call eax

* ^ ha anche una funzione particolare di accesso allo
stack per esempio:
^nome|=ebx -> or D$esp+nome , ebx
^a-4=99 -> mov D$esp+eax-4 , 99

* * ha una funzione particolare di accesso alla memoria.
Esempio: D*a-4=99 -> mov D$eax-4 , 99
D*a+b*4+4=99 -> mov D$eax+ebx*4+4 , 99

* Non ho fatto molte prove su testi; quindi errori.

* ora e' possibile in generale avere macro con spazi dentro
qualcosa come:
<< "<ò1 ò2" = "push ò1 | push ò2"
<a andarequa
>> "<ò1 ò2"
tradotto in Rosam in
\r\n
push eax | push andarequa\r\n
\r\n

* **Nota bene** a=&FALSE qui significa "lea eax, FALSE"

Esempio completo:
---------------------
PREPARSE MACRO2D

;*
%define MsgBox 'USER32.MessageBoxA'
;*

; Nasm data
section .data
"Prima prova di stampa" db "Prima prova di stampa", 0
questaEdefinizioneNasm dd 123, 0, 0
; Nasm data end with "section .text"
section .text

; rosasm data
[SecondaProva: B$ "Seconda prova di stampa", 0, 0
valore: D$ 34]

Main:
int3
mov eax, D*questaEdefinizioneNasm
mov ecx, D[questaEdefinizioneNasm]
mov eax, D$questaEdefinizioneNasm
mov ecx, *questaEdefinizioneNasm
mov eax, [questaEdefinizioneNasm]
mov ecx, questaEdefinizioneNasm
a=*questaEdefinizioneNasm
c=questaEdefinizioneNasm
a=*valore

pushad
MsgBox(0, "Prima prova di stampa", SecondaProva, &MB_SYSTEMMODAL__&MB_OK)
popad
a=0
ret
____________________________________________________________________________
Note dell'uso di questo preparser con RosAsm statements:
Che io conosca non sono supportati le seguenti classi di statements di RosAsm:

mov B$Aerror &true ; problema la "t" di true è minuscola
; è ok "mov B$Aerror &True" la prima lettera "T" di true maiuscola
if eax <s 0 ; problema "<s"
if ecx >s 0 ; problema ">s"
...If eax = M00_<<<<_ ; problema la parola "M00_<<<<_"
...Else_If eax = M00_>>>>_ ; problema la parola "M00_>>>>_"
while b$ebx<> '\' ; problema "b$" [sarebbe meglio "B$"]
cmp b$edx+1 0 ; idem
..while ecx > 0 ; problema ".w" iniziale minuscolo better ".While ecx > 0" ?
..end_while ; problema ".e" iniziale minuscolo
..if D@Message = &WM_KEYDOWN ; problema ".i" iniziale minuscolo
..else_if eax = D$DataListBox.Handle ; problema ".e" iniziale minuscolo
..end_If ; problema ".e" iniziale minuscolo
If ecx a TOOLBUTTONS_NUMBER ; problema "a" e' una macro definita
..Else_If_str D@FunctionNamePos = 'LOG10' ; problema 'LOG10' non è supportata
; stringa len>4

call 'USER32.MessageBoxA' D$hwnd { "UNKNOWN TYPE !!!.
Many thanks in advance. Betov." 0 } { "Unknown Type" 0 }
&MB_SYSTEMMODAL__&MB_ICONEXCLAMATION

; problema 1 {...} {...} forse sarbbe meglio {...}, {...}
; problema 2 {...} &MB_SYSTEMMODAL__&MB_ICONEXCLAMATION sarebbe meglio
; {...}, &MB_SYSTEMMODAL__&MB_ICONEXCLAMATION

..1: loop .1 ; problem loop with local label not supported

call "kernel32.ExitProcess", 0 ; problem '"'; better call
'kernel32.ExitProcess', 0

mov eax, D$eax+4*ecx+8*3 ; problems 4*ecx and 8*3; should be "mov eax,
D$eax+ecx*4+(8*3)"
____________________________________________________________________________________________

IN BOCCA AL LUPO
;;


[numeroElementiTavola: D$ 0]

NewParser: ; RET ; <<<<<<<<<<<<<<<<<!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
pushad
mov edx, D$CodeSourceA
mov ecx, D$StripLen
push ecx
push edx
call ControllaPreparse |cmp eax, 0|jnz @0
@e: mov eax, 0-1 | mov D$AzioneDaFareMacro2D, 0| jmp @z
@0: mov esi D$CodeSourceA, edi D$CodeSourceB| mov ecx esi|add ecx
D$StripLen

; u32
; M2dToRosAsmInMemWithNoStdOutput(u32* dst, u32 dstLenMax, u32* org, u32
orgLen)
mov eax, D$AsmTablesLength|cmp eax, 0|jbe @3
mov edx, D$StripLen
push edx|push esi|push eax|push edi| call
M2dToRosAsmInMemWithNoStdOutput|jc @3
add edi, ecx
@2: mov edx, 1
jmp @4
@3: mov edx, 0
@4: cmp edx, 1|jne @e
sub edi D$CodeSourceB | mov D$StripLen edi
Exchange D$CodeSourceA D$CodeSourceB
call UndefAllNotLanguageMacros
; call FreeMem Quando si esce si libera tutta la memoria
; conta gli statement
mov B$ErrorLevel 0
mov esi D$CodeSourceA, D$StatementsCounter 0, D$LinesCounter 0
mov B$DontCountNext &FALSE
mov ebx esi | add ebx D$StripLen
push D$StripLen|push esi|call ContatoreDiStatements|jc @e
cmp eax, 0|jle @e
mov D$LinesCounter, eax
If D$LinesCounter = 0
call CloseProgressBar
call 'USER32.MessageBoxA' 0, {"RosAsm can't compile empty files",
0},
{' Sorry', 0}, 0
mov B$CompileErrorHappend &TRUE
popad| mov esp D$OldStackPointer | ret ; direct error
; pop eax | ret ; Abort, pop caller and return to Message Loop
End_If
mov eax D$LinesCounter | add eax 20 | shl eax 3 ; 2 > dword +1 >
security
mov ecx, eax
shr ecx, 2
mov D$numeroElementiTavola, ecx

push eax
VirtualAlloc StatementsTable eax
pop eax

VirtualAlloc StatementsTable2 eax


;StoreStatements:
; mov ecx D$CodeSource | sub ecx D$CodeSourceA ; Ajust from CodeSource to
CodeSourceA.
mov esi D$CodeSourceA, edi D$StatementsTable
move D$StatementsPtr D$StatementsTable
; AssociatoreDiStatements(u32* StmPtr, u32 StmPtrS,
; u8* Org, u32 OrgSz, u8* CodeP, u32 CodeSz)
push D$SourceLen
push D$CodeSource
push D$StripLen
push esi
push D$numeroElementiTavola
push edi
call AssociatoreDiStatements
mov D$AzioneDaFareMacro2D, 1
@z:
popad
ret


; usare solo all'uscita del programma
QuiCancellaMemoriaNewParser: ; ret
; int3
pushfd
pushad
cmp D$QuiIniziaTuttoNewParser, 0| je @1
call FreeMem
mov D$QuiIniziaTuttoNewParser, 0
@1:
popad
popfd
ret

[QuiIniziaTuttoNewParser: D$ 0
PreparseRosNasm: D$ 0
PreparseMacro2D: D$ 0
AzioneDaFareMacro2D: D$ 0
PuntatoreAlCodiceTradotto: D$ 0
hashtab: D$ 0

TheNext: D$ 0
NodeMem: D$ 0

MacroDefinizioniGeneraliLed: D$ 0
NasmDefLed: D$ 0
RosAsmDefLed: D$ 0

PointerSize: D$ 0
TheNextPointer: D$ 0
StringPointers: D$ 0
ContaVirgolette: D$ 0


; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
MyTable:
B$ 5 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 6 ; 0
B$ 5 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 1 10 e' fine input non
spazio
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 2
B$ 16 , 16 , 6 , 9 , 16 , 9 , 9 , 3 , 9 , 16 ; 3
B$ 9 , 9 , 9 , 9 , 9 , 9 , 2 , 16 , 0 , 0 ; 4 "." e' lettera
B$ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 16 , 16 ; 5
B$ 9 , 9 , 9 , 9 , 3 , 1 , 1 , 1 , 1 , 1 ; 6
B$ 1 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ; 7
B$ 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ; 8
B$ 2 , 16 , 16 , 16 , 9 , 2 , 16 , 1 , 1 , 1 ; 9
B$ 1 , 1 , 1 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ; 10
B$ 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ; 11
B$ 2 , 2 , 2 , 16 , 9 , 16 , 16 , 16 , 16 , 16 ; 12
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 13
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 14
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 15
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 16
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 17
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 18
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 19
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 20
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 21
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 22
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 23
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 24
B$ 16 , 16 , 16 , 16 , 16 , 16 ; 25

; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
MyTableR:
B$ 5 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 6 ; 0
B$ 12 , 16 , 16 , 12 , 16 , 16 , 16 , 16 , 16 , 16 ; 1 10 e' fine input non
spazio
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 2
B$ 16 , 16 , 6 , 9 , 10 , 9 , 9 , 0 , 9 , 10 ; 3
B$ 9 , 9 , 9 , 9 , 9 , 9 , 0 , 16 , 0 , 0 ; 4 "." e' lettera
B$ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 10 , 10 ; 5
B$ 9 , 9 , 9 , 9 , 0 , 0 , 0 , 0 , 0 , 0 ; 6
B$ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ; 7
B$ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ; 8
B$ 0 , 11 , 10 , 11 , 9 , 0 , 10 , 0 , 0 , 0 ; 9
B$ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ; 10
B$ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ; 11
B$ 0 , 0 , 0 , 11 , 9 , 11 , 10 , 16 , 16 , 16 ; 12
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 13
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 14
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 15
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 16
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 17
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 18
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 19
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 20
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 21
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 22
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 23
B$ 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ; 24
B$ 16 , 16 , 16 , 16 , 16 , 16 ; 25

MacroDefinizioniGenerali:
B$ "a", 0 , "eax", 0
B$ "b", 0 , "ebx", 0
B$ "c", 0 , "ecx", 0
B$ "jx", 0 , "di", 0
B$ "i", 0 , "esi", 0
B$ "j", 0 , "edi", 0
B$ "ix", 0 , "si", 0
B$ "r", 0 , "edx", 0
B$ "rx", 0 , "dx", 0
B$ "rl", 0 , "dl", 0
B$ "rh", 0 , "dh", 0
B$ "s", 0 , "esp", 0
B$ "sx", 0 , "sp", 0
B$ "k", 0 , "ebp", 0
B$ "kx", 0 , "bp", 0
; 15
B$ "##ò1", 0 , "jmp ò1", 0
B$ "ò1=ò2", 0 , "mov ò1, ò2", 0
B$ "ò1+=ò2", 0 , "add ò1, ò2", 0
B$ "ò1-=ò2", 0 , "sub ò1, ò2", 0
B$ "ò1++=ò2", 0 , "adc ò1, ò2", 0
B$ "ò1--=ò2", 0 , "sbb ò1, ò2", 0
B$ "ò1<->ò2", 0 , "xchg ò1, ò2", 0
B$ "ò1<<=ò2", 0 , "shl ò1, ò2", 0
B$ "ò1>>=ò2", 0 , "shr ò1, ò2", 0
B$ "ò1<<<=ò2", 0 , "rcl ò1, ò2", 0
B$ "ò1>>>=ò2", 0 , "rcr ò1, ò2", 0
B$ "ò1&ò2", 0 , "test ò1, ò2", 0
B$ "ò1=&ò2", 0 , "lea ò1, ò2", 0
B$ "ò1&=ò2", 0 , "and ò1, ò2", 0
B$ "ò1|=ò2", 0 , "or ò1, ò2", 0
B$ "ò1^=ò2", 0 , "xor ò1, ò2", 0
B$ "<ò1", 0 , "push ò1", 0
; 35
B$ ">ò1", 0 , "pop ò1", 0
B$ "ò1()", 0 , "call ò1", 0
; 37
B$ "<ò1,ò2", 0 , "push ò1 |push ò2", 0
B$ ">ò1,ò2", 0 , "pop ò2 |pop ò1", 0
B$ "<ò1,ò2,ò3", 0 , "push ò1 |push ò2 |push ò3", 0
B$ ">ò1,ò2,ò3", 0 , "pop ò3 |pop ò2 |pop ò1", 0
B$ "<ò1,ò2,ò3,ò4", 0 , "push ò1 |push ò2 |push ò3 |push ò4", 0
B$ ">ò1,ò2,ò3,ò4", 0 , "pop ò4 |pop ò3 |pop ò2 |pop ò1", 0
B$ "<ò1,ò2,ò3,ò4,ò5", 0 , "push ò1 |push ò2 |push ò3 |push ò4 |push ò5", 0
B$ ">ò1,ò2,ò3,ò4,ò5", 0 , "pop ò5 |pop ò4 |pop ò3 |pop ò2 |pop ò1", 0
B$ "<ò1,ò2,ò3,ò4,ò5,ò6", 0
B$ "push ò1 |push ò2 |push ò3 |push ò4 |push ò5 |push ò6", 0
B$ ">ò1,ò2,ò3,ò4,ò5,ò6", 0
B$ "pop ò6 |pop ò5 |pop ò4 |pop ò3 |pop ò2 |pop ò1", 0
B$ "<ò1,ò2,ò3,ò4,ò5,ò6,ò7", 0
B$ "push ò1 |push ò2 |push ò3 |push ò4 |push ò5 |push ò6 |push ò7", 0
B$ ">ò1,ò2,ò3,ò4,ò5,ò6,ò7", 0
B$ "pop ò7 |pop ò6 |pop ò5 |pop ò4 |pop ò3 |pop ò2 |pop ò1", 0
B$ "<ò1,ò2,ò3,ò4,ò5,ò6,ò7,ò8", 0
B$ "push ò1 |push ò2 |push ò3 |push ò4 |push ò5 |push ò6 |push ò7 |push ò8", 0
B$ ">ò1,ò2,ò3,ò4,ò5,ò6,ò7,ò8", 0
B$ "pop ò8 |pop ò7 |pop ò6 |pop ò5 |pop ò4 |pop ò3 |pop ò2 |pop ò1", 0
; 51
;------------------------------------------*/
B$ "ò1=ò2()", 0 , "call ò2 |mov ò1, eax", 0
B$ "ò1(ò2)", 0 , "push ò2 |call ò1", 0
B$ "ò1=ò2(ò3)", 0 , "push ò3 |call ò2 |mov ò1, eax", 0
B$ "ò1<(ò2)", 0 , "push ò2 |call ò1 |add esp, 4", 0
B$ "ò1=ò2<(ò3)", 0
B$ "push ò3 |call ò2 |add esp, 4 |mov ò1, eax", 0
; 56
B$ "ò1(ò2,ò3)", 0
B$ "push ò3 |push ò2 |call ò1", 0
B$ "ò1=ò2(ò3,ò4)", 0
B$ "push ò4 |push ò3 |call ò2 |mov ò1, eax", 0
B$ "ò1<(ò2,ò3)", 0
B$ "push ò3 |push ò2 |call ò1 |add esp, 8", 0
B$ "ò1=ò2<(ò3,ò4)", 0
B$ "push ò4 |push ò3 |call ò2 |add esp, 8 |mov ò1, eax", 0
B$ "ò1(ò2,ò3,ò4)", 0
B$ "push ò4 |push ò3 |push ò2 |call ò1", 0
B$ "ò1=ò2(ò3,ò4,ò5)", 0
B$ "push ò5 |push ò4 |push ò3 |call ò2 |mov ò1, eax", 0
B$ "ò1<(ò2,ò3,ò4)", 0
B$ "push ò4 |push ò3 |push ò2 |call ò1 |add esp, 12", 0
B$ "ò1=ò2<(ò3,ò4,ò5)", 0
B$ "push ò5 |push ò4 |push ò3 |call ò2 |add esp, 12 |mov ò1, eax", 0
B$ "ò1(ò2,ò3,ò4,ò5)", 0
B$ "push ò5 |push ò4 |push ò3 |push ò2 |call ò1", 0
B$ "ò1=ò2(ò3,ò4,ò5,ò6)", 0
B$ "push ò6 |push ò5 |push ò4 |push ò3 |call ò2 |mov ò1, eax", 0
; 66
B$ "ò1<(ò2,ò3,ò4,ò5)", 0
B$ "push ò5 |push ò4 |push ò3 |push ò2 |call ò1 |add esp, 16", 0
B$ "ò1=ò2<(ò3,ò4,ò5,ò6)", 0
B$ "push ò6 |push ò5 |push ò4 |push ò3 |call ò2 |add esp, 16 |mov ò1, eax", 0
B$ "ò1(ò2,ò3,ò4,ò5,ò6)", 0
B$ "push ò6 |push ò5 |push ò4 |push ò3 |push ò2 |call ò1", 0
B$ "ò1=ò2(ò3,ò4,ò5,ò6,ò7)", 0
B$ "push ò7 |push ò6 |push ò5 |push ò4 |push ò3 |call ò2 |mov ò1, eax", 0
B$ "ò1<(ò2,ò3,ò4,ò5,ò6)", 0
B$ "push ò6 |push ò5 |push ò4 |push ò3 |push ò2 |call ò1 |add esp, 20", 0
B$ "ò1=ò2<(ò3,ò4,ò5,ò6,ò7)", 0
B$ "push ò7 |push ò6 |push ò5 |push ò4 |push ò3 |call ò2 |add esp, 20 |mov ò1,
eax", 0
B$ "ò1(ò2,ò3,ò4,ò5,ò6,ò7)", 0
B$ "push ò7 |push ò6 |push ò5 |push ò4 |push ò3 |push ò2 |call ò1", 0

B$ "ò1=ò2(ò3,ò4,ò5,ò6,ò7,ò8)", 0
B$ "push ò8 |push ò7 |push ò6 |push ò5 |push ò4 |push ò3 |call ò2 |mov ò1, eax",
0
B$ "ò1<(ò2,ò3,ò4,ò5,ò6,ò7)", 0
B$ "push ò7 |push ò6 |push ò5 |push ò4 |push ò3 |push ò2 |call ò1 |add esp, 24",
0
B$ "ò1=ò2<(ò3,ò4,ò5,ò6,ò7,ò8)", 0
B$ "push ò8 |push ò7 |push ò6 |push ò5 |push ò4 |push ò3 |call ò2 |add esp, 24
|mov ò1, eax", 0
; 76
B$ "ò1(ò2,ò3,ò4,ò5,ò6,ò7,ò8)", 0
B$ "push ò8 |push ò7 |push ò6 |push ò5 |push ò4 |push ò3 |push ò2 |call ò1", 0
B$ "ò1=ò2(ò3,ò4,ò5,ò6,ò7,ò8,ò9)", 0
B$ "push ò9 |push ò8 |push ò7 |push ò6 |push ò5 |push ò4 |push ò3 |call ò2 |mov
ò1, eax", 0
B$ "ò1<(ò2,ò3,ò4,ò5,ò6,ò7,ò8)", 0
B$ "push ò8 |push ò7 |push ò6 |push ò5 |push ò4 |push ò3 |push ò2 |call ò1 |add
esp, 28", 0
B$ "ò1=ò2<(ò3,ò4,ò5,ò6,ò7,ò8,ò9)", 0
B$ "push ò9 |push ò8 |push ò7 |push ò6 |push ò5 |push ò4 |push ò3 |call ò2 |add
esp, 28 |mov ò1, eax", 0
B$ "ò1(ò2,ò3,ò4,ò5,ò6,ò7,ò8,ò9)", 0
B$ "push ò9 |push ò8 |push ò7 |push ò6 |push ò5 |push ò4 |push ò3 |push ò2 |call
ò1", 0
B$ "ò1=ò2(ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10)", 0
B$ "push ò10 |push ò9 |push ò8 |push ò7 |push ò6 |push ò5 |push ò4 |push ò3
|call ò2 |mov ò1, eax", 0
B$ "ò1<(ò2,ò3,ò4,ò5,ò6,ò7,ò8,ò9)", 0
B$ "push ò9 |push ò8 |push ò7 |push ò6 |push ò5 |push ò4 |push ò3 |push ò2 |call
ò1 |add esp, 32", 0
B$ "ò1=ò2<(ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10)", 0
B$ "push ò10 |push ò9 |push ò8 |push ò7 |push ò6 |push ò5 |push ò4 |push ò3
|call ò2 |add esp, 32 |mov ò1, eax", 0
B$ "ò1(ò2,ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10)", 0
B$ "push ò10 |push ò9 |push ò8 |push ò7 |push ò6 |push ò5 |push ò4 |push ò3
|push ò2 |call ò1", 0
B$ "ò1=ò2(ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10,ò11)", 0
B$ "push ò11 |push ò10 |push ò9 |push ò8 |push ò7 |push ò6 |push ò5 |push ò4
|push ò3 |call ò2 |mov ò1, eax", 0
; 86
B$ "ò1<(ò2,ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10)", 0
B$ "push ò10 |push ò9 |push ò8 |push ò7 |push ò6 |push ò5 |push ò4 |push ò3
|push ò2 |call ò1 |add esp, 36", 0
B$ "ò1=ò2<(ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10,ò11)", 0
B$ "push ò11 |push ò10 |push ò9 |push ò8 |push ò7 |push ò6 |push ò5 |push ò4
|push ò3 |call ò2 |add esp, 36 |mov ò1, eax", 0
;--------------taglio
B$ "ò1(ò2,ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10,ò11)", 0
B$ "push ò11 |push ò10 |push ò9 |push ò8 |push ò7 |push ò6 |push ò5 |push ò4
|push ò3 |push ò2 |call ò1", 0
; ------------taglio
B$ "ò1=ò2(ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10,ò11,ò12)", 0
B$ "push ò12 |push ò11 |push ò10 |push ò9 |push ò8 |push ò7 |push ò6 |push ò5
|push ò4 |push ò3 |call ò2 |mov ò1, eax", 0
B$ "ò1<(ò2,ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10,ò11)", 0
B$ "push ò11 |push ò10 |push ò9 |push ò8 |push ò7 |push ò6 |push ò5 |push ò4
|push ò3 |push ò2 |call ò1 |add esp, 40", 0
B$ "ò1=ò2<(ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10,ò11,ò12)", 0
B$ "push ò12 |push ò11 |push ò10 |push ò9 |push ò8 |push ò7 |push ò6 |push ò5
|push ò4 |push ò3 |call ò2 |add esp, 40 |mov ò1, eax", 0
B$ "ò1(ò2,ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10,ò11,ò12)", 0
B$ "push ò12 |push ò11 |push ò10 |push ò9 |push ò8 |push ò7 |push ò6 |push ò5
|push ò4 |push ò3 |push ò2 |call ò1", 0
B$ "ò1=ò2(ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10,ò11,ò12,ò13)", 0
B$ "push ò13 |push ò12 |push ò11 |push ò10 |push ò9 |push ò8 |push ò7 |push ò6
|push ò5 |push ò4 |push ò3 |call ò2 |mov ò1, eax", 0
B$ "ò1<(ò2,ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10,ò11,ò12)", 0
B$ "push ò12 |push ò11 |push ò10 |push ò9 |push ò8 |push ò7 |push ò6 |push ò5
|push ò4 |push ò3 |push ò2 |call ò1 |add esp, 44", 0
B$ "ò1=ò2<(ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10,ò11,ò12,ò13)", 0
B$ "push ò13 |push ò12 |push ò11 |push ò10 |push ò9 |push ò8 |push ò7 |push ò6
|push ò5 |push ò4 |push ò3 |call ò2 |add esp, 44 |mov ò1, eax", 0
; 96
B$ "ò1(ò2,ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10,ò11,ò12,ò13)", 0
B$ "push ò13 |push ò12 |push ò11 |push ò10 |push ò9 |push ò8 |push ò7 |push ò6
|push ò5 |push ò4 |push ò3 |push ò2 |call ò1", 0
B$ "ò1=ò2(ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10,ò11,ò12,ò13,ò14)", 0
B$ "push ò14 |push ò13 |push ò12 |push ò11 |push ò10 |push ò9 |push ò8 |push ò7
|push ò6 |push ò5 |push ò4 |push ò3 |call ò2 |mov ò1, eax", 0
B$ "ò1<(ò2,ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10,ò11,ò12,ò13)", 0
B$ "push ò13 |push ò12 |push ò11 |push ò10 |push ò9 |push ò8 |push ò7 |push ò6
|push ò5 |push ò4 |push ò3 |push ò2 |call ò1 |add esp, 48", 0
B$ "ò1=ò2<(ò3,ò4,ò5,ò6,ò7,ò8,ò9,ò10,ò11,ò12,ò13,ò14)", 0
B$ "push ò14 |push ò13 |push ò12 |push ò11 |push ò10 |push ò9 |push ò8 |push ò7
|push ò6 |push ò5 |push ò4 |push ò3 |call ò2 |add esp, 48 |mov ò1, eax", 0
;100

;------------------------------------------*/
B$ "++ò1", 0 , "inc ò1", 0
B$ "--ò1", 0 , "dec ò1", 0 ; --[a+si]
B$ "++ò1,ò2", 0 , "inc ò1 |inc ò2", 0
B$ "--ò1,ò2", 0 , "dec ò1 |dec ò2", 0
B$ "++ò1,ò2,ò3", 0
B$ "inc ò1 |inc ò2 |inc ò3", 0
B$ "--ò1,ò2,ò3", 0
B$ "dec ò1 |dec ò2 |dec ò3", 0
; 106
B$ "++ò1,ò2,ò3,ò4", 0
B$ "inc ò1 |inc ò2 |inc ò3 |inc ò4", 0
B$ "--ò1,ò2,ò3,ò4", 0
B$ "dec ò1 |dec ò2 |dec ò3 |dec ò4", 0
B$ "--ò1#ò2", 0 , "dec ò1 |jnz ò2", 0
B$ "--ò1!#ò2", 0 , "dec ò1 |jz ò2", 0
B$ "++ò1#ò2", 0 , "inc ò1 |jnz ò2", 0
B$ "++ò1!#ò2", 0 , "inc ò1 |jz ò2", 0
B$ "ò1<>ò2", 0 , "cmp ò1, ò2", 0
B$ "ò1#ò2", 0 , "cmp ò1, 0 |jne ò2", 0
B$ "ò1!#ò2", 0 , "cmp ò1, 0 |je ò2", 0
B$ "ò1<ò2#ò3", 0 , "cmp ò1, ò2 |jb ò3", 0 ; numeri senza segno
; 116
B$ "ò1&ò2#ò3", 0 , "test ò1, ò2 |jnz ò3", 0
B$ "ò1>ò2#ò3", 0 , "cmp ò1, ò2 |ja ò3", 0
B$ "ò1<=ò2#ò3", 0 , "cmp ò1, ò2 |jbe ò3", 0
B$ "ò1>=ò2#ò3", 0 , "cmp ò1, ò2 |jae ò3", 0
B$ "ò1==ò2#ò3", 0 , "cmp ò1, ò2 |je ò3", 0
B$ "ò1!=ò2#ò3", 0 , "cmp ò1, ò2 |jne ò3", 0
B$ "ò1>=ò2!#ò3", 0 , "cmp ò1, ò2 |jb ò3", 0
B$ "ò1<=ò2!#ò3", 0 , "cmp ò1, ò2 |ja ò3", 0
B$ "ò1>ò2!#ò3", 0 , "cmp ò1, ò2 |jbe ò3", 0
B$ "ò1&ò2!#ò3", 0 , "test ò1, ò2 |jz ò3", 0
B$ "ò1<ò2!#ò3", 0 , "cmp ò1, ò2 |jae ò3", 0
B$ "ò1!=ò2!#ò3", 0 , "cmp ò1, ò2 |je ò3", 0
B$ "ò1==ò2!#ò3", 0 , "cmp ò1, ò2 |jne ò3", 0
; nuovi
B$ "ò1==ò2,ò3#ò4", 0
B$ "cmp ò1, ò2 |je ò4 |cmp ò1, ò3 |je ò4", 0
B$ "ò1==ò2,ò3,ò4#ò5", 0
B$ "cmp ò1, ò2 |je ò5 |cmp ò1, ò3 |je ò5 |cmp ò1, ò4 |je ò5", 0
B$ "ò1==ò2,ò3,ò4,ò5#ò6", 0
B$ "cmp ò1, ò2 |je ò6 |cmp ò1, ò3 |je ò6 |cmp ò1, ò4 |je ò6 |cmp ò1, ò5 |je ò6",
0
B$ "ò1==ò2,ò3,ò4,ò5,ò6#ò7", 0
B$ "cmp ò1, ò2 |je ò7 |cmp ò1, ò3 |je ò7 |cmp ò1, ò4 |je ò7 |cmp ò1, ò5 |je ò7
|cmp ò1, ò6 |je ò7", 0
; -----------------------------
; 129
; numeri col segno
B$ "ò1<ò2?#ò3", 0 , "cmp ò1, ò2 |jl ò3", 0
B$ "ò1>ò2?#ò3", 0 , "cmp ò1, ò2 |jg ò3", 0
B$ "ò1<=ò2?#ò3", 0 , "cmp ò1, ò2 |jle ò3", 0
B$ "ò1>=ò2?#ò3", 0 , "cmp ò1, ò2 |jge ò3", 0
B$ "ò1==ò2?#ò3", 0 , "cmp ò1, ò2 |je ò3", 0
B$ "ò1!=ò2?#ò3", 0 , "cmp ò1, ò2 |jne ò3", 0
B$ "ò1>=ò2!?#ò3", 0 , "cmp ò1, ò2 |jl ò3", 0
B$ "ò1<=ò2!?#ò3", 0 , "cmp ò1, ò2 |jg ò3", 0
B$ "ò1>ò2!?#ò3", 0 , "cmp ò1, ò2 |jle ò3", 0
B$ "ò1<ò2!?#ò3", 0 , "cmp ò1, ò2 |jge ò3", 0
B$ "ò1!=ò2!?#ò3", 0 , "cmp ò1, ò2 |je ò3", 0
B$ "ò1==ò2!?#ò3", 0 , "cmp ò1, ò2 |jne ò3", 0
; 141
B$ "ò1=ò2+ò3", 0 , "mov ò1, ò2 |add ò1, ò3", 0
B$ "ò1=ò2-ò3", 0 , "mov ò1, ò2 |sub ò1, ò3", 0
; 143
; label: istruzione = istruzione \0 commento
; numeri senza segno
B$ "=#ò1", 0 , "jz ò1", 0
B$ "<#ò1", 0 , "jb ò1", 0
B$ ">#ò1", 0 , "ja ò1", 0
; 146
; numeri con segno
B$ "<=#ò1", 0 , "jbe ò1", 0
B$ ">=#ò1", 0 , "jae ò1", 0
B$ "=?#ò1", 0 , "je ò1", 0
B$ "<?#ò1", 0 , "jl ò1", 0
B$ ">?#ò1", 0 , "jg ò1", 0
B$ "<=?#ò1", 0 , "jle ò1", 0
B$ ">=?#ò1", 0 , "jge ò1", 0
; numeri senza segno
B$ "!#ò1", 0 , "jnz ò1", 0
B$ "!<#ò1", 0 , "jae ò1", 0
B$ "!>#ò1", 0 , "jbe ò1", 0
; 156
B$ "!<=#ò1", 0 , "ja ò1", 0
B$ "!>=#ò1", 0 , "jb ò1", 0
; numeri con segno
B$ "!?#ò1", 0 , "jne ò1", 0
B$ "!<?#ò1", 0 , "jge ò1", 0
B$ "!>?#ò1", 0 , "jle ò1", 0
B$ "!<=?#ò1", 0 , "jg ò1", 0
B$ "!>=?#ò1", 0 , "jl ò1", 0
B$ "(ò1,ò2)<<=ò3", 0 , "shld ò1, ò2, ò3", 0
B$ "(ò1,ò2)>>=ò3", 0 , "shrd ò1, ò2, ò3", 0
; 165
B$ 0FFh , 0FFh , 0 , 0FFh

RosAsmDef:
B$ "#ò1", 0
B$ "jmp ò1", 0
B$ "dword", 0 , "D", 0
B$ "word", 0 , "W", 0
B$ "byte", 0 , "B", 0
B$ "qword", 0 , "Q", 0
B$ "tword", 0 , "T", 0
B$ "short", 0 , " ", 0
B$ 0FFh , 0FFh , 0 , 0FFh , 0
EndofAllMacros: B$ 0, 0, 0, 0

Isection: B$ "section", 0, 0
Isegment: B$ "segment", 0, 0
IIdefine: B$ "%define", 0, 0
IIundef: B$ "%undef", 0, 0
Iexport: B$ "export", 0, 0
Iimport: B$ "import", 0, 0
Iglobal: B$ "global", 0, 0
Iextern: B$ "extern", 0, 0
Itimes: B$ "times", 0, 0
IRosNasm: B$ "RosNasm", 0, 0
IMacro2D: B$ "Macro2D", 0, 0
IPREPARSE: B$ "PREPARSE", 0, 0
ITITLE: B$ "TITLE", 0, 0
IZBWIDIIIIQIT: B$ "ZBW D Q T", 0 , 0

]



align 4
Malloc_sys:
mov eax, D$esp+4 |cmp eax, 0|jl @e|jz @1
push 00004h |push 03000h |push eax |push 0 |call
'kernel32.VirtualAlloc' |cmp eax, 0 |je @f
@1: clc|jmp @z
@e: xor eax, eax
@f: stc
@z:
ret 4

align 4
Free_sys:
mov eax, D$esp+4 |cmp eax, 0 |je @1|push 08000h |push 0 |push
eax |call 'kernel32.VirtualFree' |cmp eax, 0 |jne @1
@e:
@0: mov eax, 1|stc|jmp @z
@1: xor eax, eax ; pone CF==0
@z:
ret 4

; 0ra, 4P_a, 8P_sizeinbytes
align 4
Zero:
mov eax, D$esp+4 |mov ecx, D$esp+8
cmp eax, 0 |je @e|cmp ecx, 0 |jg @1
@e: stc|jmp @z
@1: xor edx, edx|and ecx, 0FFFFFFFCh|jmp @3
@2: mov D$eax+edx, 0|add edx, 4
@3: cmp edx, ecx |jb @2
mov ecx, D$esp+8 |and ecx, 3|jz @5|add ecx, edx
@4: mov B$eax+edx, 0|inc edx
cmp edx, ecx |jb @4
@5: clc
@z:
ret 8

; 0b,4ra,8P_tav
align 4
SostituisciSbarraConRosAsm:
push ebx|mov ebx, D$esp+8 |xor ecx, ecx|cmp ebx, 0 |jne @1
@e: mov eax, -1|stc|jmp @z
@1: mov cl, B$ebx |cmp ecx, 0 |jne @2|cmp B$ebx+1, 0FFh |je @9 ;
0,0FFh => finisce
@2: cmp ecx, '|' |jne @3 ; sostituise " |" con " \0x1"
cmp B$ebx-1, ' ' |jne @3
mov B$ebx, 1
@3: inc ebx|jmp @1
@9: clc
@z:
pop ebx
ret 4

; 0r,4b,8ra, 12P_tav
align 4
ConvertiNumeriTavola:
push ebx |push edx|mov ebx, D$esp+12 |xor ecx, ecx|cmp ebx, 0
|jne @1
@e: mov eax, -1|stc|jmp @z
@1: mov cl, B$ebx |cmp ecx, 0 |jne @2|cmp B$ebx+1, 0FFh |je @9 ;
0,0FFh => finisce
@2: cmp ecx, 'ò' |jne @3
xor eax, eax|mov al, B$ebx+1 |cmp B$MyTable+eax, 0 |jne @3
inc ebx|push ebx |call AtoI|cmp eax, 0 |je @e|cmp eax, 255 |ja
@e
xor ecx, ecx
mov B$ebx, al
mov edx, 0
cmp eax, 9 |jbe @2a|inc edx
@2a: cmp eax, 99 |jbe @2b|inc edx
@2b: push edx |push ebx |call sposta
; cl=al|B[MyTable+c]==0#.e
; ci sono problemi a
; una eventuale doppia passata della funzione
@3: inc ebx|jmp @1
@9: clc
@z:
pop edx |pop ebx
ret 4

align 4
PreInstall:
cmp D$QuiIniziaTuttoNewParser , 0 |jne @1
push MacroDefinizioniGenerali |call SostituisciSbarraConRosAsm|jc @z
push MacroDefinizioniGenerali |call ConvertiNumeriTavola|jc @z
push RosAsmDef |call ConvertiNumeriTavola|jc @z
mov D$QuiIniziaTuttoNewParser , 1
@1: clc
@z:
ret

align 4
InstallRosInRosams:
call PreInstall|jc @z
cmp D$MacroDefinizioniGeneraliLed , 0 |jne @0
push MacroDefinizioniGenerali |call Installl|jc @z
mov D$MacroDefinizioniGeneraliLed , 1
@0: cmp D$RosAsmDefLed , 0 |jne @1
push RosAsmDef |call Installl|jc @z
mov D$RosAsmDefLed , 1
@1: clc
@z:
ret

align 4
InstallNasmInRosams:
call PreInstall|jc @z
cmp D$RosAsmDefLed , 0 |jne @1
push RosAsmDef |call Installl|jc @z
mov D$RosAsmDefLed , 1
@1: clc
@z:
ret

; Struttura della tavola di Hash
; hashtable
; 0
; p-->|nx--->|nx=0
; 0 |nm |nm <---nodes
; 0 |df |df
; 0 |dfl |dfl
; 0
; p-->|nx=0
; 0 |nm
; 0 |df
; 0 |dfl
align 4
FreeMem:
push esi |push edi
mov esi, D$NodeMem |mov edi, D$hashtab
push esi |call Free_sys|push edi |call Free_sys
mov D$NodeMem, 0|mov D$hashtab, 0
mov D$TheNext, 0
mov esi, D$StringPointers
cmp esi, 0 |je @9|cmp D$PointerSize, 0 |jle @9
xor edi, edi
@1: mov eax, D$esi+edi*4
push eax |call Free_sys
inc edi|cmp edi, D$PointerSize |jb @1
@9: push esi |call Free_sys
mov D$PointerSize, 0
mov D$TheNextPointer, 0
mov D$StringPointers, 0
mov D$MacroDefinizioniGeneraliLed, 0
mov D$NasmDefLed, 0
mov D$RosAsmDefLed, 0
pop edi |pop esi
ret

IsComment:

call First_ch1|jc @e
mov ecx, edi|add ecx, ebp
xor eax, eax|cmp ebx, ';' |je @2
cmp ebx, '/' |jne @0|cmp B$esi+1, '*' |jne @0|jmp @1
@0: jmp @5
@e: mov B$edi, 0|mov eax, -1|stc|jmp @z ; errore
@f: mov B$edi, 0|or D$esp+52, 1|jmp @f1
@f0: mov B$edi, 0|or D$esp+52, 128
@f1: mov eax, 1|clc|jmp @z ; trovata
@1: inc esi
@2: inc esi|or D$esp+52, 8
mov B$edi, ';' |cmp edi, ecx |jae @e|inc edi
@3: mov al, B$esi |mov B$edi, al|cmp edi, ecx |jae @e
inc esi |inc edi|cmp al, 10 |je @f|cmp al, 0 |je @f0|jmp @3
@5: mov B$edi, 0|xor eax, eax ; non trovata
@z:

ret

; la funzione chiamante se trova la label esce
; quindi scrive la label direttamente nell'argomento
; della funzione j
align 4
IsLabel:

call First_ch1|jc @e
cmp B$MyTable+ebx, 3 |jbe @0|jmp @7
@0: mov edx, esi|xor eax, eax ; r punta al primo char di una parola
@1: inc edx|mov al, B$edx |cmp B$MyTable+eax, 3 |jbe @1
mov ecx, edx|jmp @3
@2: inc ecx|mov al, B$ecx
@3: cmp B$MyTable+eax, 6 |je @2
cmp eax, ':' |je @3a|jmp @7 ; trovata label
@3a: sub edx, esi
add edx, 5|cmp edx, ebp |jb @4
@e: mov eax, -1|stc|jmp @z
@4: mov ebx, ecx
call CopyMacro_jki|jc @e
mov D$esp+48, eax
sub ebp, 3|cmp ebp, 0 |jle @e
add D$esp+48, 3
mov B$edi, ':' |inc edi
mov B$edi, ' ' |inc edi
mov B$edi, ' ' |inc edi
mov B$edi, 0
mov esi, ebx|xor ebx, ebx|call Next_ch1|cmp ebx, 13 |jne @6
mov B$edi, 13|inc edi |inc esi|mov B$edi, 0|dec ebp |jz @e|inc
D$esp+48
mov bl, B$esi |cmp ebx, 10 |jne @4a
@5: mov B$edi, 10|inc edi |inc esi|mov B$edi, 0|dec ebp |jz @e|inc
D$esp+48
or D$esp+52, 1|jmp @6a
@6: cmp ebx, 10 |je @5
@4a: cmp ebx, 0 |jne @5a|or D$esp+52, 128|jmp @6a
@5a: or D$esp+52, 512 ; fine istruzione per label
@6a: or D$esp+52, 2|mov eax, 1
clc|jmp @z
@7: xor eax, eax
@z:

ret


; o2 o3
; nome1 nome2&nome3<
; mette gia' gli spazi tra nome3 e "&"
; combine cambia j
; nel chiamante (ToNasm) DaiNumeroP=72
; nel chiamante 88-12=76=PointerArray
; Cambia i e j
; 2048 -> 2060 2064
; 3072 -> 3084 3088
; 3076 -> 3076+12=3088
; 3076 -> 3088+4=3092
align 4
combine:
push ebx |push ebx

mov ebp, eax|mov ebx, D$esp+84 |mov ecx, D$esp+3084 |mov edi,
D$esp+3088
dec ebx|jg @a|xor ebx, ebx
@a: add ecx, edi|mov D$esp+0, ebx|xor eax, eax|xor ebx, ebx|jmp @0 ;
mette spazio alla fine
@ee: jmp @e
@b: cmp ebx, D$esp+0 |je @0|mov al, B$ebp |cmp B$MyTable+eax, 9 |jne
@0 ; se non punto: non mettere
mov B$edi, ' ' |cmp edi, ecx |jae @ee|add edi, 1|jc @ee ; spazio
finale
@0: mov al, B$ebp
cmp eax, 'ò' |je @0a|jmp @2 ; 1..64
@0a: inc ebp|mov al, B$ebp |mov bl, B$ebp |cmp eax, 0 |je @ee|cmp
ebx, 128 |ja @ee|inc ebp
lea edx, D$esp+88 |mov edx, D$edx+eax*4 |cmp edx, 0 |je @ee
push edx|mov edx, edi|sub edx, 1|cmp edx, D$esp+3092 |pop edx|jle
@1 ; notare come j==^3092=^3088+4 per il "push r"
mov al, B$edi-1 |cmp B$MyTable+eax, 6 |je @1 ; se gia' spazio
iniziale: non inserisci
cmp eax, '&' |jne @0b|mov al, B$edx |cmp eax, 'A' |jb @0b|cmp
eax, 'Z' |ja @0b|jmp @1
@0b: mov B$edi, ' ' |cmp edi, ecx |jae @e|add edi, 1|jc @e ; spazio
iniziale ; qui inserisce lo spazio
@1: mov al, B$edx |cmp eax, 0 |je @b|mov B$edi, al|cmp edi, ecx
|jae @e
inc edx|add edi, 1|jnc @1|jmp @e
@2: mov B$edi, al|cmp edi, ecx |jae @e|cmp eax, 0 |je @3 ; al=0x26=&
in "mov eax &False"
inc ebp|add edi, 1|jnc @0
@e: mov eax, 1|mov B$edi, 0|stc|jmp @z
@3: lea edx, D$edi-1 |cmp edx, D$esp+3088 |jbe @4|xor ecx, ecx
mov cl, B$edx |cmp B$MyTable+ecx, 6 |jne @4
dec edi|mov B$edi, 0
@4: clc
@z:

pop ebx |pop ebx
ret


; i=origin
; ritorna in b l'ultimo carattere
; e in i la posizione del prossimo carattere
; non usa altri registri che b ed i
; quindi per uso informativo usare come in
align 4
Next_ch:

inc esi
First_ch:
@1: mov bl, B$esi |cmp B$MyTable+ebx, 6 |jne @2
add esi, 1|jnc @1|jmp @z
@2: mov eax, D$esp+44 |mov D$esp+56, eax|mov D$esp+44, esi|clc
@z:

ret

; i=origin
; ritorna in b l'ultimo carattere
; e in i la posizione del prossimo carattere
; non usa altri registri che b ed i
; quindi per uso informativo usare come in
align 4
Next_ch1:

inc esi
First_ch1:
@1: mov bl, B$esi |cmp B$MyTable+ebx, 6 |jne @2
add esi, 1|jnc @1|jmp @z
@2: mov eax, D$esp+48 |mov D$esp+60, eax|mov D$esp+48, esi|clc
@z:

ret

; la parola composta dalle lettere (0 nella tavola) + "_" + "&" + "+"
; &jsisjsi____________&siisisisi
; NB: NON USARE r
align 4
CopyAmperstandName_ij:

mov ecx, D$esp+76
mov B$edi, ' ' |cmp edi, ecx |jae @e|inc edi
jmp @2
@1: mov B$edi, bl|cmp edi, ecx |jae @e
inc esi |inc edi
@2: mov bl, B$esi
cmp B$MyTableR+ebx, 0 |je @1|cmp ebx, '&' |je @1|cmp ebx, '+'
|je @1
mov B$edi, ' ' |cmp edi, ecx |jae @e|inc edi
mov B$edi, 0
xor eax, eax|jmp @z
@e: mov eax, -1|stc
@z:

ret

; scrive tutta la stringa da origine a destinazione
; senza usare nessuna macro, sostituendo gli spazi
; e le lettere non alfanumeriche con I
; r=destinazione, i=origine
; c e' size attuale destinazione, b e' ultimo carattere
align 4
CopyPseudoString:
push ebp

mov ebp, ebx|xor eax, eax|mov ecx, D$esp+80
inc esi ; salta il " o '
mov B$edi, ' ' |cmp edi, ecx |jae @e|inc edi
mov B$edi, 'I' |cmp edi, ecx |jae @e|inc edi
@1: mov bl, B$esi |cmp ebx, ebp |je @4
mov al, B$MyTable+ebx |cmp ebx, 0 |je @e |cmp ebx, 10 |je @e
|cmp ebx, 13 |je @e
cmp ebx, '.' |je @1a
cmp eax, 2 |jbe @2
@1a: |mov B$edi, 'I' |jmp @3
@2: |mov B$edi, bl
@3: cmp edi, ecx |jae @e|inc esi |inc edi|jmp @1
@e: mov eax, -1|stc|jmp @z
@4: inc esi ; salta ultima "
mov B$edi, ' ' |cmp edi, ecx |jae @e|inc edi
mov B$edi, 0
xor eax, eax
@z:

pop ebp
ret

; scrive tutta la stringa da origine a destinazione
; senza usare nessuna macro
; j=destinazione, i=origine
; B1limit=B1limit+8=76 [2 funzioni chiamate]
; NewLine1=8+8=16
align 4
CopyString1:

mov eax, ebx ; in b vi è il carattere al=" o '
mov ecx, D$esp+76
mov B$edi, ' ' |cmp edi, ecx |jae @e|inc edi
mov B$edi, bl|cmp edi, ecx |jae @e|inc esi |inc edi|jmp @1
@0: inc D$esp+16 |cmp D$esp+16, 256 |jb @2|mov B$edi, 0|jmp @e
@1: mov bl, B$esi |mov B$edi, bl|cmp ebx, 10 |je @0
@2: cmp edi, ecx |jae @e|inc esi |inc edi|cmp ebx, eax |jne @1
mov B$edi, ' ' |cmp edi, ecx |jae @e|inc edi
mov B$edi, 0
xor eax, eax|jmp @z
@e: mov eax, -1|stc
@z:

ret


; il chiamante deve ++j quando trova che la parola è finita
align 4
ScriviParola:



@0: cmp ebx, '"' |je @1|jmp @4
@1: cmp B$esi+1, bl |je @2|cmp B$esi+2, bl |je @2|cmp B$esi+3, bl
|je @2|cmp B$esi+4, bl |je @2|cmp B$esi+5, bl |je @2
mov eax, D$esp+56 |cmp eax, 0 |je @0a|cmp B$eax, ',' |jne @1a
@0a: cmp D$esp+64, 0 |jne @3
cmp D$esp+36, 0 |jne @3|cmp D$esp+40, 0 |jne @3|jmp @2
@1a: cmp B$eax, 'd' |jne @2a|cmp B$eax+1, 'b' |jne @2a
xor edx, edx|mov dl, B$eax+2 |cmp B$MyTable+edx, 6 |jne @3 ; qui
copia stringa
@2: mov edx, edi|call CopyString1|jc @eee|jmp @6
@eee: jmp @e
@2a: cmp B$eax, "$" |je @2
xor edx, edx|mov dl, B$eax |cmp B$MyTableR+edx, 0 |je @2|cmp edx,
'{' |je @2
@3: mov edx, edi|call CopyPseudoString|jc @eee|jmp @6
@4: cmp ebx, 39 |je @1 ; e' simbolo '
; qui r e' la prima lettera della stringa
; o pseudo stringa scritta: serve per scrivere B2
cmp ebx, '*' |je @4a|jmp @4b
@4a: cmp D$esp+40, 0 |jne @3a|cmp D$esp+64, 0 |jne @3a
cmp D$esp+20, 0 |jne @3a
cmp D$esp+36, 1 |jne @3b
@3a: |mov edx, edi|mov B$edi, bl|cmp edi, D$esp+72 |jae @e|inc esi
|inc edi|jmp @6
@3b: mov D$esp+36, 1
mov edx, edi
mov eax, D$esp+3080 |cmp eax, edi |jbe @3bbb ; 3080 vecchio j: j
primo carattere ??
xor eax, eax|mov al, B$edi-1 |cmp eax, 'B' |je @3bbb |cmp eax,
'W' |je @3bbb |cmp eax, 'D' |je @3bbb |cmp eax, 'Q' |je @3bbb |cmp
eax, 'T' |je @3bbb
@3bb: mov B$edi, ' ' |cmp edi, D$esp+72 |jae @e|inc edi ; spazio per
inserire B,W,D...
@3bbb: mov B$edi, '[' |cmp edi, D$esp+72 |jae @e|inc esi |inc edi|jmp
@6
@e: mov eax, 1|stc|jmp @z
@4b: cmp ebx, '^' |jne @5
mov edx, edi|mov eax, edi|add eax, 12|cmp edi, D$esp+72 |jae @e
cmp D$esp+28, 1 |jne @4bb
mov D$edi, "D[es" |add edi, 4|mov W$edi, "p+" |add edi, 2
inc esi|jmp @6
@4bb: mov D$edi, "dwor" |add edi, 4|mov D$edi, "d[es" |add edi, 4
mov D$edi, "p+" |add edi, 2|inc esi|jmp @6
@5: cmp ebx, '&' |jne @1c
; a^=a|al=*i+1| a<'A'#.1c| a>'Z'#.1c ; l'equate di win è maiuscola
mov edx, edi ; |B*j=' '|j>=[s+B1Limit]#.e|++j
call CopyAmperstandName_ij|jc @e|jmp @6
@1c:
cmp B$MyTable+ebx, 3 |jbe @5a ; scrive *tutto* anche i punti in B1
; solo le parole alfanumeriche possono
; utilizzare FindMacroWord()
mov edx, edi
cmp bl, '[' |jne @3c|mov eax, D$esp+56 |cmp B$eax, 'B' |je @3c
|cmp B$eax, 'W' |je @3c |cmp B$eax, 'D' |je @3c |cmp B$eax, 'Q' |je
@3c |cmp B$eax, 'T' |je @3c
mov B$edi, ' ' |cmp edi, D$esp+72 |jae @e|inc edi
mov B$edi, ' ' |cmp edi, D$esp+72 |jae @e|inc edi
@3c: mov B$edi, bl|cmp edi, D$esp+72 |jae @e|inc esi |inc edi|jmp @6
@5a: mov D$esp+4, esi
push esi |call FindMacroWord
; r lunghezza della parola puntata da i
; a risultato della stringa in entrata
; c lunghezza del parametro precedente
; uso b
add esi, edx ; i e' aggiornato, r e' libero
@5b: mov edx, edi
cmp B$eax, '[' |jne @5c
mov B$edi, ' ' |cmp edi, D$esp+72 |jae @e|inc edi
@5c: lea ebx, D$edi+ecx |cmp ebx, D$esp+72 |jae @e
xor ebx, ebx
push ebp |push esi |push edx|mov ebp, ecx|mov esi, eax|call
DCopy|pop edx |pop esi |pop ebp ; cambia solo c,a
add edi, eax ; aggiorna j
@6: mov B$edi, 0
cmp D$esp+60, 0 |je @8
@7: xor eax, eax|jmp @z
; Qui deve essere InWord==0
@ee: jmp @e
@8: mov D$esp+60, 1
mov B$ebp, 'ò' |cmp ebp, D$esp+68 |jae @ee
inc ebp|mov eax, D$esp+76 |cmp eax, 0 |je @ee|cmp eax, 128 |ja
@ee ; 1..128 sono 128 puntatori
inc D$esp+76
mov B$ebp, al|cmp ebp, D$esp+68 |jae @e|inc ebp ; mette un puntatore
a inizio parola
lea ecx, D$esp+80 |lea ecx, D$ecx+eax*4 |mov D$ecx, edx ; calcola
da 76+4=80 poiche' l'indice
xor eax, eax ; parte da 1
@z:



ret

; DCopy(j,i,k)
; Copia la stringa di i di lunghezza [len] k, in j
; ritorna la lunghezza della stringa
; modifica c,a,r
align 4
DCopy:
mov ecx, ebp|xor eax, eax|and ecx, 0FFFFFFFCh|jz @3
@1: mov edx, D$esi+eax |mov D$edi+eax, edx|add eax, 4
@2: cmp eax, ecx |jb @1
@3: mov ecx, ebp|and ecx, 3|jz @5|add ecx, eax
@4: mov dl, B$esi+eax |mov B$edi+eax, dl|inc eax|cmp eax, ecx |jb @4
@5: mov B$edi+eax, 0 ; non necessario?
clc
@z:
ret


; u32 ToNasm(j:Destination, k:destinationSize, i:origin)
; c==0 Nasm, c==1 RosAsm
; in B*i vi e' il prossimo carattere da trattare
; se c!=0 nasm c==0 rosasm
; a& 1!=0: raggiunta la fine della linea con \n
; a& 2!=0: esiste la label
; a& 4!=0 [<=>CF==1] riscontrato errore
; a& 8!=0 commento
; a& 16!=0 commento doppio
; a& 32!=0 errore di parametro
; a& 64!=0 errore di copia
; a&128!=0 raggiunta la fine della istruzione con 0
; a&256!=0 raggiunta la fine della istruzione con "|", ";"
; a&512!=0 raggiunta la fine della istruzione per label
;
; j:Destination, k:destinationSize, vengono salvati nello stack
; nella routine: i:origin, b:LastChar, j=B1attuale, K=B2attuale
; in c vi e' la lunghezza della stringa scritta
; a,r sono libere
; 0, 4, 8, 12, 16, 20, 24, 28, 32, 36 variabili libere
; 40, 44, 48, 52, 56, 60, 64, 68, 72, 76
; 80, 84, ....,592 [128 puntatori]
; 600,..., 2648 [2048 Buffer1 ]
; 2656,...,3064 [408 Buffer2]
; 1024+2048=3072
; label: istruzione ; commento
align 4
ToNasm:
push edi |push ebp
; *s viene usato localmente ovunque anche in ScriviParola
sub esp, 3072





mov D$esp+48, 0|mov D$esp+44, 0|mov D$esp+40, 0|mov D$esp+52, 0|mov
D$esp+24, ecx
mov D$esp+20, 0|mov D$esp+8, 0|mov D$esp+16, 0|xor ebx, ebx
call IsComment|jc @ee0|cmp eax, 1 |je @ff ; spostano j
call IsLabel|jc @ee0|cmp eax, 1 |je @ff|jmp @0 ; il chiamante sa che
e' tutta una linea
; quindi non esiste il bisogno di continuare
@ff: jmp @f
@0: mov D$esp+60, 0|mov D$esp+36, 0
mov D$esp+32, 0|mov D$esp+28, 0|mov D$esp+12, esi
lea edi, D$esp+600 |lea ebp, D$esp+2656 |lea eax, D$edi+2048 |lea
edx, D$ebp+408
mov D$esp+68, eax|mov D$esp+64, edx|mov D$esp+56, 0|mov D$esp+72,
1|jmp @2
@ee0: xor ecx, ecx
@e: mov eax, D$esp+20 |cmp eax, 255 |jbe @e2
@e1: mov eax, 0|jmp @e3
@e2: add eax, D$esp+8 |cmp eax, 255 |ja @e1
shl eax, 16
@e3: or eax, D$esp+48 |or eax, 4|stc|jmp @z ; non sposta j errore di
buffer interno
@e9: mov edi, D$esp+3076
@ej: mov ecx, edi|sub ecx, D$esp+3076 |jmp @e ; sposta j
@f: mov eax, D$esp+20 |cmp eax, 255 |ja @e1
add eax, D$esp+8 |cmp eax, 255 |ja @e1
shl eax, 16
mov ecx, edi|sub ecx, D$esp+3076 ; sposta j
or eax, D$esp+48 |clc|jmp @z
@1: call Next_ch|jc @e9 ; aggorna "i" e "b"
@2: cmp ebx, ';' |je @1a|jmp @4
@1a: or D$esp+48, 256|cmp B$esi, '|' |jne @2a ; incontrari ; oppure |
@3: inc esi
@2a: cmp D$esp+32, 0 |je @3a|mov B$edi, ']' |cmp edi, D$esp+68 |jae
@e9|inc edi
@3a: mov B$edi, 0|mov B$ebp, 0 ; i vecchi j e k
lea edx, D$esp+2656 |push edx |call FindMacro|call combine|jc @ej ;
sposta j
; i nuovi j e k
; k j
mov ecx, D$esp+3072 |mov edx, D$esp+3076 |add ecx, edx
cmp D$esp+20, 0 |je @3ab
mov eax, D$esp+20
@3aa: mov B$edi, 13|cmp edi, ecx |jae @ej|inc edi
mov B$edi, 10|cmp edi, ecx |jae @ej|inc edi|mov B$edi, 0
dec eax |jnz @3aa
@3ab: test D$esp+48, 1 |jnz @3b
cmp B$esi, ';' |je @4b ; sposta j
cmp B$esi, '/' |je @4b
cmp D$esp+24, 2 |jne @3b ; aggiunto RosAsm
mov B$edi, '|' |cmp edi, ecx |jae @ej|inc edi ; per \n
jmp @4c
@3b: |mov eax, edi|add eax, 2|cmp eax, ecx |jae @ej
|mov B$edi, 13|inc edi|mov B$edi, 10|inc edi|mov B$edi, 0|jmp @4c
@4b: |mov B$edi, ' ' |cmp edi, ecx |jae @ej|inc edi|mov B$edi, 0
@4c: mov ecx, edi|sub ecx, edx|jl @ej ; c= i caratteri scritti
jmp @f
@4: cmp ebx, 10 |jne @5|or D$esp+48, 1|jmp @3
@5: cmp ebx, 13 |jne @6|cmp B$esi+1, 10 |jne @6
inc esi|mov bl, B$esi |jmp @4
@ee: jmp @e9 ; "a|=b" "|=#.9"
@6: cmp ebx, 0 |jne @5a|or D$esp+48, 128|jmp @2a
@5a: cmp ebx, '|' |jne @7|cmp D$esp+60, 0 |jne @7
cmp B$esi+1, '=' |je @6a
@5b: inc D$esp+24 |jmp @1a
@6a: cmp B$esi+2, '#' |je @5b
@7: cmp ebx, '/' |jne @6b
cmp B$esi+1, '*' |jne @6b|jmp @2a
@6b: cmp ebx, '\' |jne @4n|cmp B$esi+1, 10 |je @4d |cmp B$esi+1, 13
|je @4d|jmp @4n
@4d: inc esi|inc D$esp+20
cmp B$esi, 13 |jne @4e|inc esi
@4e: cmp B$esi, 10 |jne @4f|inc esi
@4f: dec esi|jmp @1 ; next_ch() incrementa i
@4n: cmp B$MyTable+ebx, 9 |je @7a
@4o: jmp @m
@7a: cmp ebx, '&' |jne @4p ; prima era 4p
xor edx, edx|mov dl, B$esi+1 |cmp edx, 'A' |jb @4p|cmp edx, 'Z'
|ja @4p
lea edx, D$esp+2656
cmp B$edx, 'ò' |jne @4o|add edx, 2|cmp B$edx, '=' |jne @4o|inc
edx|cmp edx, ebp |jne @4o
@4p: cmp ebx, ',' |jne @7c ; , 10
cmp B$esi+1, 10 |jne @7b|add esi, 1|inc D$esp+20 ; , 13 10
@6c: jmp @d0 ; 0 1 2
@7b: cmp B$esi+1, 13 |jne @6c|cmp B$esi+2, 10 |jne @6c|inc D$esp+20
add esi, 2|jmp @d0 ; next_ch() incrementa i
@7c: cmp D$esp+60, 0 |je @b1
cmp ebx, ',' |jne @a00|jmp @d0 ; tratta virgola come punto
@a00: cmp ebx, '(' |jne @a|inc D$esp+60
@a: cmp ebx, ')' |jne @b|dec D$esp+60 |jz @a0r|jmp @r
; ^InParentesiTonde=0 /* D isisi< 8d9d
@a0r: cmp D$esp+28, 0 |je @a1
mov D$esp+28, 0
@a0: mov B$edi, bl|cmp edi, D$esp+68 |jae @ee|inc edi
mov D$esp+56, 0|mov B$edi, 0|cmp edi, D$esp+68 |jae @ee|inc
edi|jmp @1
@a1: jmp @d0 ; idem ')'
@b: jmp @r ; ma il resto e' parola
@b1: cmp D$esp+36, 0 |jne @b ; B*i+1 non e' punto non '()' vai a .c1
cmp D$esp+32, 0 |je @c ; ^a+ +=0 -> D*esp+eax
cmp ebx, '*' |je @b2|cmp ebx, '+' |je @b2|cmp ebx, '-' |je
@b2|jmp @b3
@b2: xor eax, eax|mov al, B$esi+1 |cmp B$MyTableR+eax, 9 |jne @c1|cmp
eax, ')' |jbe @c1
;B[i+1]!='='#.c1
@b3: mov B$edi, ']' |cmp edi, D$esp+68 |jae @ee|inc edi
mov D$esp+32, 0|jmp @d0
@c: cmp ebx, '(' |jne @c0|inc D$esp+60
mov eax, D$esp+52 |cmp eax, 0 |je @b4|cmp B$eax, '<' |je @b4
cmp B$eax, ']' |je @b4
cmp B$eax, '(' |je @b4
xor edx, edx|mov dl, B$eax |cmp B$MyTable+edx, 3 |jbe @b4
mov D$esp+28, 1|jmp @r
@c0: cmp ebx, '*' |jne @c2
@c1: jmp @r
@b4: jmp @d0
@c2: cmp ebx, '-' |jne @d
@c3: xor eax, eax|mov al, B$esi+1 |cmp B$MyTable+eax, 0 |jne @b4
cmp esi, D$esp+12 |je @c1
mov al, B$esi-1 |cmp B$MyTable+eax, 6 |jne @c1
mov B$edi, ' ' |cmp edi, D$esp+68 |jae @e0|inc edi
mov B$edi, 0|jmp @r
@d: cmp ebx, '+' |je @c3
cmp ebx, '^' |jne @i|cmp B$esi+1, '=' |je @i
mov D$esp+32, 1|jmp @r
@i: cmp ebx, '$' |jne @d0|mov D$esp+16, 1|jmp @r
@d0: cmp D$esp+56, 0 |je @l ; finiesce la parola precedente
@i0: mov D$esp+56, 0
mov B$edi, 0|cmp edi, D$esp+68 |jae @e0|inc edi
@l: mov B$ebp, bl|cmp ebp, D$esp+64 |jae @e0|inc ebp|jmp @1
@e0: jmp @e9
@m: ; gli altri casi non punti
cmp ebx, '[' |jne @n|inc D$esp+36 |jmp @r
@n: cmp ebx, ']' |jne @o|dec D$esp+36 |jmp @a0
@o: cmp D$esp+56, 0 |je @r ; finiesce la parola precedente
mov eax, D$esp+52 |xor edx, edx|cmp eax, 0 |je @r
mov dl, B$eax |cmp B$MyTableR+edx, 0 |jne @r
mov D$esp+56, 0
mov B$edi, 0|cmp edi, D$esp+68 |jae @e0|inc edi
mov B$ebp, ' ' |cmp ebp, D$esp+64 |jae @e0|inc ebp
@r: call ScriviParola|jc @e0|call First_ch|jmp @2
@z:





lea esp, D$esp+3072
pop ebp |pop edi
ret

; a*31=a*(32-1)=a*32-a
; ritorna il valore di hash della stringa puntata da b
; in ogni caso edx==eax alla fine della funzione
; u32 Hash(u8* b)
; 0i,4b,8ra,12P_s
align 4
Hash:
push ebx |push esi
mov ebx, D$esp+12 |xor eax, eax|xor ecx, ecx|xor edx, edx|mov
esi, 8|cmp ebx, 0 |jne @2
@e: stc|jmp @z
@0: cmp B$ebx, 0 |je @3|inc ebx|jmp @0
@1: inc ebx|dec esi |jz @0 ; a*31=a*32-a
mov edx, eax|shl eax, 5|add eax, ecx|sub eax, edx
@2: mov cl, B$ebx |cmp ecx, 0 |jne @1
@3: mov edx, D$esp+12 |mov ecx, 8123|sub ebx, edx|shl eax, 4 ; in b e'
len
xor edx, edx|add eax, ebx|div ecx|mov eax, edx|mov ecx, ebx ;
eax==edx
clc ; c=strlen(name)
@z:
pop esi |pop ebx
ret 4

; u32* Lookup(u8* name)
; ritorna a=0 CF==1, hashtab posizi. nodo in edx
; strlen(name) in ecx
; se non troavato
; -----------------------------------------
; altrimenti l'indirizzo del nodo trovato in eax
; l'indirizzo del precedente in edx
; strlen(name) in ecx
; 0k,4i,8j,12b,16ra,20P_name
align 4
Lookup:
push ebx |push esi |push edi |push ebp
mov esi, D$esp+20 |xor ebp, ebp|cmp D$hashtab, 0 |je @e|cmp esi,
0 |jne @1
@e: xor eax, eax|stc|jmp @z
@0: mov eax, ebx|clc|jmp @z
@1: push esi |call Hash|mov ebp, ecx
mov ecx, D$hashtab |lea eax, D$ecx+edx*4
mov ebx, D$eax |mov edx, eax|cmp ebx, 0 |je @e ; non trovato
@2: mov edi, D$ebx+4 |cmp edi, 0 |je @e ; senza stringa???
push edx|call DCmp|pop edx|jnc @0 ; cmp(i:lenk, j:string)
@4: mov edx, ebx|mov ebx, D$edx |cmp ebx, 0 |jne @2|jmp @e
@z: mov ecx, ebp
pop ebp |pop edi |pop esi |pop ebx
ret 4

; DCmp(j,i,k)
; compara i di len k, con j terminato da 0
; Se 0 CF==0 allora la stringa i con
; l'array di lunghezza fissa j sono uguali
; altrimenti sono diversi
align 4
DCmp:
mov ecx, ebp|xor edx, edx|and ecx, 0FFFFFFFCh|jz @3|jmp @1
@n: mov eax, -1|stc|jmp @z
@1: mov eax, D$edi+edx |cmp eax, D$esi+edx |jne @n|add edx, 4
@2: cmp edx, ecx |jb @1
@3: mov ecx, ebp|and ecx, 3|jz @5|add ecx, edx
@4: mov al, B$edi+edx |cmp al, B$esi+edx |jne @n|inc edx|cmp edx, ecx
|jb @4
@5: xor eax, eax|mov al, B$edi+edx |cmp B$MyTableR+eax, 0 |je @n
xor eax, eax
@z:
ret


; compara parole separate da spazi o \0
; suppone che i parametri (esi ed esp+4)
; abbiano stringhe valide
; CF==1 trovato CF==0 non trovato
; in eax si trova la lunghezza della parola
; confrontata
; Non cambia i registri
; 0ra, 4P_str + 32
align 4
CmpS_i:
pushad
mov edx , D$esp+36 |xor eax , eax|xor ecx , ecx|jmp @2
@0: stc|jmp @z
@1: inc ecx
@2: mov al , B$esi+ecx |cmp al , B$edx+ecx |jne @3 ; se carattere diverso #.3
cmp B$MyTable+eax , 6 |je @0 ; se entrambi spazio #.0
cmp eax , 13 |je @0 |cmp eax , 10 |je @0
cmp eax , 0 |jne @1 ; se a==0 procede in uscita
@3: cmp eax , 0 |jne @5
@4: mov al , B$edx+ecx |cmp eax , 0 |je @0 ; se entrambi \0 ritorna CF==1
cmp B$MyTable+eax , 6 |je @0 ; se uno \0 l'altro space CF==1
cmp eax , 13 |je @0 |cmp eax , 10 |je @0
jmp @6
@5: cmp B$MyTable+eax , 6 |je @4
cmp eax , 13 |je @0 |cmp eax , 10 |je @0
@6: clc
@z:
popad
ret 4

; Compara Stringhe Maiuscole minuscole
; compara parole separate da spazi o \0
; NON IMPORTA SE MAIUSCOLE O MINUSCOLE
; suppone che i parametri (esi ed esp+4)
; abbiano stringhe valide
; CF==1 trovato CF==0 non trovato
; Non cambia i registri
; 0ra, 4P_str + 32
; 36
align 4
CmpSMm_i:
pushad
mov edi , D$esp+36 |xor eax , eax|xor ecx , ecx|xor ebx , ebx|jmp @2
@0: stc|jmp @z
@0a: cmp ebx , 0 |je @0
@0c: cmp B$MyTable+ebx , 6 |je @0
cmp eax , 13 |je @0 |cmp eax , 10 |je @0|jmp @6
@0b: cmp B$MyTable+eax , 6 |je @0
cmp eax , 13 |je @0 |cmp eax , 10 |je @0|jmp @6
@1: inc ecx
@2: mov al , B$esi+ecx |mov bl , B$edi+ecx
cmp eax , 0 |je @0a
@3: cmp ebx , 0 |je @0b
mov dl , B$MyTable+eax |mov dh , B$MyTable+ebx
cmp dl , 6 |je @0c|cmp dh , 6 |je @0b
cmp dl , 1 |jb @4|cmp dh , 1 |jb @4
cmp dl , 2 |ja @4|cmp dh , 2 |ja @4
or eax , 32|or ebx , 32 ; da maiuscolo a minuscolo
@4: cmp eax , ebx |je @1
@6: clc
@z:
popad
ret 4



; find macro per parole alfanumeriche
; all'interno a stringhe
; u8* FindMacroWord(u8* name)
; ritorna c=a=0 CF=1 se errore di parametro
; ----------------------------------------
; ritorna a=name, c=lenUntilNotLetter(name)
; CF=1 se non trovato nel lookup
; r=strlen(name)
; ----------------------------------------
; ritorna a=def, c=strlen(def), CF=0
; se e' trovato nel lookup
; r=strlen(name)
; ----------------------------------------
; 0k,4j,8i,12b,16ra,20P_name
align 4
FindMacroWord:
push ebx |push esi |push edi |push ebp

mov esi, D$esp+20 |cmp D$hashtab, 0 |je @e0|cmp esi, 0 |jne @1
@e0: xor eax, eax|xor ecx, ecx
@e: stc|jmp @z
@e1: mov eax, esi|mov ecx, ebp|mov edx, ebp|jmp @e
@0: mov eax, D$ebx+8 |mov ecx, D$ebx+12 |mov edx, ebp|clc|jmp @z
@1: push esi |call HashWord|mov ebp, ecx ; in k la lunghezza di i
mov ecx, D$hashtab |lea eax, D$ecx+edx*4
mov ebx, D$eax |cmp ebx, 0 |je @e1 ; non trovato
@2: mov edi, D$ebx+4 |cmp edi, 0 |je @e1 ; senza stringa???
call DCmp|jnc @0 ; cmp(i:lenk, j:string)
@4: mov edx, ebx|mov ebx, D$edx |cmp ebx, 0 |jne @2|jmp @e1
@z:

pop ebp |pop edi |pop esi |pop ebx
ret 4

; a*31=a*(32-1)=a*32-a
; ritorna il valore di hash della parola alfanumerica
; puntata da b. in ogni caso edx==eax alla fine della funzione
; e in ecx vi e' la lunghezza della parola alfanumerica "name"
; u32 HashWord(u8* name)
; 0i,4b,8ra,12P_s
align 4
HashWord:
push ebx |push esi
mov ebx, D$esp+12 |xor eax, eax|xor ecx, ecx|xor edx, edx|mov
esi, 8|cmp ebx, 0 |jne @2
@e: stc|jmp @z
@0: mov cl, B$ebx |cmp B$MyTable+ecx, 3 |ja @3|inc ebx|jmp @0
@1: inc ebx|dec esi |jz @0 ; a*31=a*32-a
mov edx, eax|shl eax, 5|add eax, ecx|sub eax, edx
@2: mov cl, B$ebx |cmp B$MyTable+ecx, 3 |jbe @1
@3: mov edx, D$esp+12 |mov ecx, 8123|sub ebx, edx|shl eax, 4 ; in b e'
len
xor edx, edx|add eax, ebx|div ecx|mov eax, edx|mov ecx, ebx ;
eax==edx==valore di hash
clc ; c=strlen(name)
; notare che in "< ss" la lunghezza tornata
@z: ; è zero infatti "<" non è alfanumerico
pop esi |pop ebx
ret 4

; FindMacro per stringhe
; u8* FindMacro(u8* name)
; ritorna c=a=0 CF=1 se errore di parametro
; ----------------------------------------
; ritorna a=name, c=strlen(name)
; CF=1 se non trovato nel lookup
; ----------------------------------------
; ritorna a=def, c=strlen(def), CF=0
; se e' trovato nel lookup
; ----------------------------------------
; 0ra,4P_name
align 4
FindMacro:

mov edx, D$esp+4 |push edx |call Lookup|jc @0
mov ecx, D$eax+12 |mov eax, D$eax+8 |clc|jmp @z
@0: mov eax, D$esp+4
@z:

ret 4

; CF==1 means find
; CF==0 means not find
; trova nella linea attuale
; 0i,4b,8ra,12P_Str,16P_StrToFind
align 4
Find:
push ebx |push esi|xor eax, eax|xor ebx, ebx|mov edx, D$esp+12
mov ecx, D$esp+16 |mov bl, B$ecx
cmp ebx, 0 |je @5|jmp @3
@0: mov esi, edx
@1: inc esi |inc ecx
mov bl, B$ecx |cmp ebx, 0 |je @5
cmp B$MyTable+ebx, 6 |je @5
cmp bl, B$esi |je @1
mov ecx, D$esp+16 |mov bl, B$ecx
@2: inc edx
@3: mov al, B$edx
cmp eax, ebx |je @0|cmp eax, 10 |je @4 |cmp eax, 13 |je @4|cmp
eax, 0 |jne @2
@4: clc|jmp @6
@5: stc
@6:
pop esi |pop ebx
ret 8

align 4
FindData_i:
sub esp, 32
mov D$esp+0, "DATA" |mov D$esp+4, 0
mov eax, esp|push eax |push esi |call Find|jc @z
mov D$esp+0, "data" |mov D$esp+4, 0
mov eax, esp|push eax |push esi |call Find|jc @z
mov D$esp+0, "bss" |mov D$esp+4, 0
mov eax, esp|push eax |push esi |call Find|jc @z
mov D$esp+0, "BSS" |mov D$esp+4, 0 ; BSS e' anche data
mov eax, esp|push eax |push esi |call Find
@z:
lea esp, D$esp+32
ret

align 4
FindCode_i:
sub esp, 32
mov D$esp+0, "CODE" |mov D$esp+4, 0
mov eax, esp|push eax |push esi |call Find|jc @z
mov D$esp+0, "code" |mov D$esp+4, 0
mov eax, esp|push eax |push esi |call Find|jc @z
mov D$esp+0, "text" |mov D$esp+4, 0
mov eax, esp|push eax |push esi |call Find|jc @z
mov D$esp+0, "TEXT" |mov D$esp+4, 0
mov eax, esp|push eax |push esi |call Find
@z:
lea esp, D$esp+32
ret

; NB Il primo carattere deve essere '['
; cambia, a, c
; b==0 Non Incontrata ']' |copia e flag
; b==1 Incontra ']' non in fine riga |non in fine riga: a tonasm
; b==2 Incontra ']' in fine riga |copia senza flag
align 4
IsParentesiQInLinea_i:
push ebx|xor ecx, ecx|mov eax, esi ; NB: Qui la linea finisce
; se commento, prima del commento
@a: xor ebx, ebx|jmp @1 ; b==0 Copiare tutta la linea
@0: inc eax ; b==0 ']' non incontrato
@1: mov cl, B$eax
cmp ecx, "'" |jne @3
@2: cmp D$ContaVirgolette, ecx |jne @1a
mov D$ContaVirgolette, 0|jmp @0
@1a: cmp D$ContaVirgolette, 0 |jne @0 ; la virgoletta trovata
@2a: inc eax ; non è quella giusta
cmp B$eax, 10 |je @c |cmp B$eax, 0 |je @c|cmp B$eax, cl |jne
@2a
jmp @0
@b: jmp @a
@c: mov D$ContaVirgolette, ecx|jmp @7
@3: cmp ecx, '"' |je @2
cmp ecx, 10 |je @7 |cmp ecx, 0 |je @7
cmp D$ContaVirgolette, 0 |jne @0
cmp ecx, ';' |je @7
cmp W$eax, '/*' |je @7
cmp ecx, ']' |jne @0|mov ebx, 1 ; b==1 a tonasm
@4: inc eax|mov cl, B$eax ; b==1 ']' incontrato non a fine linea
cmp ecx, '[' |je @b
cmp ecx, 10 |je @5 |cmp ecx, 0 |je @5 |cmp ecx, ';' |je @5
cmp W$eax, '/*' |je @5
cmp B$MyTableR+ecx, 9 |je @7 |cmp B$MyTableR+ecx, 0 |je @7 ; per i
puti: A ToNasm
jmp @4 ; per le lettere A ToNasm
@5: mov ebx, 2 ; b==2 incontrato ']' a fine linea
@7: mov ecx, eax|mov eax, ebx ; b==2 copia linea
@z:
pop ebx
ret

; CopyUntil10Or0_jki(j,k,i) e0
; Copia la stringa di i, in j di size k
; se errore ritorna 0 altrimenti ritorna
; 1 se incontra \n
; 128 se incontra \0
align 4
CopyUntil10Or0_jki:
xor eax, eax|cmp ebp, 0 |jne @1
@e: mov B$edi, 0|xor eax, eax|stc|jmp @z
@0: inc esi |inc edi
@1: mov al, B$esi |mov B$edi, al
@2: dec ebp |jz @e|cmp eax, 0 |je @3|cmp eax, 10 |jne @0
inc esi |inc edi|dec ebp |jz @e|mov B$edi, 0
mov eax, 1|jmp @4 ; trovato \n
@3: mov eax, 128 ; trovato \0
@4: clc
@z:
ret

; VaiUntil10Or0_i()
; Copia la stringa di i, in j di size k
align 4
VaiUntil10Or0_i:
xor eax, eax|jmp @1
@0: inc esi
@1: mov al, B$esi
@2: cmp eax, 0 |je @3|cmp eax, 10 |jne @0
inc esi
mov eax, 1|jmp @z
@3: mov eax, 128
@z:
ret

; u32 LineToRosAsm(u8* dest, u32 dsize, u8* origin, u32 commento)
; come risultato ecx, caratteri scritti in j
; edx, caratteri di avanzamento di i
; eax, 8:NStatements|8:NLines|16:codice errore
; ax==0 nessun statement incontrato (data oppure <spazio>\n)
;
; a& 1!=0 raggiunta la fine della istruzione con \n
; a& 2!=0 esiste la label
; a& 4==0 [<=>CF==0] nessun errore trovato
; a& 4!=0 [<=>CF==1] riscontrato errore
; a& 8!=0 commento semplice
; a& 16!=0 commento doppio
; a& 32!=0 errore di parametro
; a& 64!=0 errore di copia
; a& 128!=0 raggiunta la fine della istruzione con 0
; a& 256!=0 raggiunta la fine della istruzione con "|", ";"
; a& 512!=0 raggiunta la fine della istruzione per label
; a&1024!=0 data
; a&2048!=0 linea dello stesso tipo di dati
; a&4096!=0 Stampa "["
; 0k,4j,8i,12b,16ra,20P_d,24P_dsize,28P_or,32P_comm
; j:Destination, k:destinationSize, i:origin, b:LastChar
align 4
LineToRosAsm:
push ebx |push esi |push edi |push ebp
mov edi, D$esp+20 |mov ebp, D$esp+24 |mov esi, D$esp+28
xor ebx, ebx|cmp edi, 0 |je @e1|cmp ebp, 7 |jle @e1|mov B$edi,
0|xor eax, eax|cmp esi, 0 |jne @1
@e1: mov edx, D$esp+32
and edx, 0FFFFFC10h ; levo \n ed \0
; levo 1,2,4,32,64,128,256,512
or eax, 32|or eax, edx
@e: mov B$edi, 0|or eax, 4|sub esi, D$esp+28 |sub edi, D$esp+20 |mov
edx, esi|mov ecx, edi
stc|jmp @z
@e2: test eax, 1 |jz @e3|or eax, 000010000h
@e3: mov edx, D$esp+32 |and edx, 0FFFFFC10h
or eax, 64|or eax, edx|jmp @e
@ff0: test eax, 1 |jz @f0|or eax, 000010000h
@f0: mov B$edi, 0|sub esi, D$esp+28 |sub edi, D$esp+20 |mov edx,
esi|mov ecx, edi
@f: clc|jmp @z
@f1: mov edx, D$esp+32 |and edx, 0FFFFFC10h|or eax, edx|jmp @ff0
@f2: mov eax, ebx|jmp @ff0 ; a=2 linea con ";" a=3 ";;"
@0: inc esi
@1: mov bl, B$esi |cmp B$MyTable+ebx, 6 |je @0
cmp ebx, 10 |jne @1b
@1a: call CopyUntil10Or0_jki|jc @e2
jmp @f1
@1b: cmp ebx, 13 |jne @1c|cmp B$esi+1, 10 |je @1a
@1c: cmp B$MyTable+ebx, 5 |jne @1k
cmp ebx, 0 |jne @1cc|or eax, 128
@1cc: test D$esp+32, 1024 |jz @f1
mov eax, D$esp+32
and eax, 0FFFFFC10h
and eax, 0FFFFFBFFh
mov B$edi, ']' |inc edi|dec ebp |jz @e
@1d: jmp @ff0
@1k: test D$esp+32, 2048 |jz @0a
mov ebx, D$esp+32 |and ebx, 0FFFFFC10h|or ebx, 8
call IsParentesiQInLinea_i
cmp eax, 2 |jne @1p
and ebx, 0FFFFF7FFh ; trova la parentesi quadra not(2048)
@1p: call CopyUntil10Or0_jki|jc @e2|or ebx, eax
@3b: jmp @f2
@0a: cmp ebx, ';' |jne @4
@1a0: mov ebx, D$esp+32 |and ebx, 0FFFFFC10h|or ebx, 8
cmp B$esi+1, ';' |jne @3a
xor eax, eax|mov al, B$esi+2 |mov al, B$MyTableR+eax
cmp eax, 12 |je @1c0|jmp @3a
; caso ";;" trovato anche prima: D[s+32]&16!=0
@1c0: test D$esp+32, 16 |jnz @22
@2: or ebx, 16|jmp @3
@22: and ebx, 0FFFFFFEFh
@3: call CopyUntil10Or0_jki|jc @e2|or ebx, eax|jmp @f2
; caso ";" ora e ";;" prima oppure no
@3a: test D$esp+32, 16 |jnz @3|or ebx, 8|jmp @3
@4: test D$esp+32, 16 |jz @5
mov ebx, D$esp+32 |and ebx, 0FFFFFC10h|jmp @2
@5: cmp ebx, '/' |jne @1o|cmp B$esi+1, '*' |jne @1o
mov ebx, D$esp+32 |and ebx, 0FFFFFC10h|or ebx, 8
mov B$edi, ';' |inc edi|dec ebp|add esi, 2|jmp @3
@1o: jmp @3f
@3c: jmp @7
@3d: jmp @a
@3e: cmp eax, "segm" |jne @3d
push Isegment |call CmpSMm_i|jnc @3d ; non trovato
jmp @6
@3f: mov eax, D$esi |mov edx, D$esi+4
; b e' il primo carattere effettivo
cmp ebx, 's' |jne @3c|cmp eax, "sect" |jne @3e
push Isection |call CmpSMm_i|jnc @3d ; non trovato
@6: mov ebx, D$esp+32 |and ebx, 0FFFFFC10h|or ebx, 8 ; commento
call FindData_i|jnc @6d
test ebx, 1024 |jz @3g|test ebx, 4096 |jnz @3g
mov B$edi, ']' |inc edi|dec ebp ; fine del segmento precedente
@3g: or ebx, 1024 ; aggiungo data
@6a: call VaiUntil10Or0_i|or ebx, eax
test eax, 1 |jz @3h
mov B$edi, 13|inc edi|mov B$edi, 10|inc edi|sub ebp, 2
@3h: test ebx, 1024 |jz @6c|test ebx, 8 |jz @6c
or ebx, 4096 ; quando arriva ai dati deve
; stampare '['
@6c: jmp @f2
@6d: call FindCode_i|jnc @6a
test ebx, 1024 |jz @5b|test ebx, 4096 |jnz @5b|mov B$edi, ']'
|inc edi|dec ebp
@5b: and ebx, 0FFFFFBFFh|jmp @6a ; levo data
@6f: jmp @e2
@5c: jmp @1z
@5d: cmp eax, "SEGM" |jne @5c
push Isegment |call CmpSMm_i|jnc @5c
@5e: jmp @6
@7: cmp ebx, 'S' |jne @8|cmp eax, "SECT" |jne @5d
push Isection |call CmpSMm_i|jc @5e
@8: cmp ebx, '%' |jne @a|cmp eax, "%def" |jne @8b|push IIdefine |call
CmpS_i|jnc @8b
; a=="%def"!#.8b|r=="ine "!#.8b
@8a: mov ebx, D$esp+32 |and ebx, 0FFFFFC10h
push esi |call PushMacro|jnc @8aa
or ebx, 4 ; rivelato un errore
@8aa: jmp @6a ; definizione di macro
@8b: |cmp eax, "%und" |jne @6a|push IIundef |call CmpS_i|jnc @6a
@8c: mov ebx, D$esp+32 |and ebx, 0FFFFFC10h
push esi |call PopMacro|jnc @8cc
or ebx, 4
@8cc: jmp @6a
@des_e: jmp @e
@des_e2: jmp @e2
; j destination, i origin, b last char,
@a: cmp ax, "<<" |je @8a|cmp ax, ">>" |je @8c
and edx, 000FFFFFFh
cmp eax, "expo" |jne @7a|push Iexport |call CmpS_i|jnc @7a
mov ebx, D$esp+32 |and ebx, 0FFFFFC10h
push esi |call PushExport|jmp @6a
@7a: cmp eax, "impo" |jne @7b|push Iimport |call CmpS_i|jnc @7b
mov ebx, D$esp+32 |and ebx, 0FFFFFC10h
push esi |call PushImport|jmp @6a
@7b: cmp eax, "glob" |jne @1x|push Iglobal |call CmpS_i|jnc @1x
@1q: mov ebx, D$esp+32 |and ebx, 0FFFFFC10h|or ebx, 8
call VaiUntil10Or0_i|or ebx, eax
test eax, 1 |jz @1r
mov B$edi, 13|inc edi|mov B$edi, 10|inc edi|sub ebp, 2
@1r: jmp @f2
@1x: cmp eax, "exte" |jne @1z|push Iextern |call CmpS_i|jc @1q
@1z: test D$esp+32, 1024 |jz @8d ; settore "data"
mov ebx, D$esp+32 |and ebx, 0FFFFFC10h
or ebx, 8 ; commento
call HaLaLineaQualcheParola_i|jc @a0
@2h: call CopyUntil10Or0_jki|jc @des_e2|or ebx, eax
test eax, 128 |jz @a01|mov B$edi, ']' |inc edi|dec ebp |jz
@des_e
and ebx, 0FFFFFBFFh ; fine stringa
@a01: jmp @f2 ; quando finisce il file
@a0: test ebx, 4096 |jz @a1
mov B$edi, '[' |inc edi|dec ebp |jz @des_e
and ebx, 0FFFFEFFFh ; toglie 4096
@a1: call GetData_jki|or ebx, eax
@6g: jmp @f2
@8d: cmp al, '[' |jne @8e
call IsParentesiQInLinea_i|cmp eax, 1 |je @8e ; [ ] altro \n
mov ebx, D$esp+32 |and ebx, 0FFFFFC10h
cmp eax, 0 |jne @a2|or ebx, 2048 ; non trovata ']' => Rosasm Data or
macro
@a2: call CopyUntil10Or0_jki|jc @6f|or ebx, eax
jmp @f2
@8e: xor ebx, ebx|xor edx, edx
@8f: inc ebx|cmp ebx, 255 |ja @c|mov ecx, 1
push ebx
push edx|call ToNasm|pop edx
mov ebx, eax|shr ebx, 16|add dl, bl|jc @8g
test eax, 1 |jz @8h|add dl, 1|jc @8g
jmp @8h
@8g: pop ebx|jmp @c
@8h: pop ebx
test eax, 4 |jnz @b
add edi, ecx|sub ebp, ecx|jle @b
push ecx |push edi|sub edi, ecx|mov ecx, D$esp+0 |call
FromNasmToRos|pop edi |pop ecx ; FromNasmToRos preserva "a,b,c,r,i,j"
test eax, 128 |jnz @a9|test eax, 1 |jnz @a9
cmp ecx, 0 |jne @8f
@a9: and eax, 0FFFFh|shl edx, 16|shl ebx, 24|or eax, edx|or eax,
ebx|jmp @f0
@b: and eax, 0FFFFh|shl edx, 16|shl ebx, 24|or eax, edx|or eax, ebx ;
StatementsXLines < 256 Lines <256
@c: jmp @e ; StatementsXline NLines ErrorCode
@z: ; a = 0XX___________XX__________XXXXh
pop ebp |pop edi |pop esi |pop ebx
ret 16

;
; FromNasmToRos(j,a)
; in "j" vi e' l'inizio della stringa in "c" la sua fine
; Non cambia la lunghezza di j
; NB preserva "a" Non preserva "r"
; trasforma j->" stringa " stringa
; in-place
; da Nasm a Ros
; mov [eax], ebx
; < a272, b268, c264, i260 , j256 (con -256)
; < a1040, b1036, c1032, i1028, j1024
; < a1044, b1040, c1036, r1032, i1028, j1024
align 4
FromNasmToRos:
push eax |push ebx |push ecx |push edx |push esi |push edi
sub esp, 1024
test eax, 8 |jnz @0|test eax, 16 |jnz @0|jmp @0b
@0: clc|jmp @z
@e: stc|jmp @z
; mov D[esp],90 -> mov D$esp , 90
; | || | |
; mov [esp],eax -> mov D$esp , eax /* r==1
; | | | |
; mov eax, [esp] -> mov eax, D$esp /* r==2
; | | | |
; call [eax]
; | | |
; call D$eax
; | ||| |
@0a: mov edi, D$esp+ebx*4-4 |inc edi|cmp edi, D$esp+1036 |jae @0 ;
^1036=c la fine della stringa
@0b: mov eax, esp
push edi |push 250 |push eax |call AssegnaVettoriIstruzione|jc @e
mov ebx, eax|xor edx, edx|xor eax, eax|cmp ebx, 0 |je @0
cmp ebx, 1 |jne @0c|mov esi, D$esp+edx*4 |cmp B$esi, ';' |je @0
|cmp B$esi, 13 |je @0 |cmp B$esi, 10 |je @0 |cmp B$esi, 0 |je @0
@0c: cmp ebx, 1 |je @0a |cmp ebx, 2 |je @0a
cmp ebx, 3 |jne @1a|mov esi, D$esp+(4*1) |mov al, B$esi |cmp
eax, '$' |jne @0a
mov B$esi-1, 'D' |jmp @0a ; call dword
cmp ebx, 4 |jne @0a
@1a: inc edx|cmp edx, 3 |je @0a ; r==1,2
@1b: mov esi, D$esp+edx*4
mov al, B$esi
@2: cmp eax, '$' |jne @1a
cmp edx, 2 |je @3
mov ecx, D$esp+edx*4+4
@2a: push edx|push ecx |call Isreg|pop edx|cmp eax, 0 |je @0a
xor ecx, ecx|mov cl, B$ IZBWIDIIIIQIT +eax
mov B$esi-1, cl
jmp @0a
@3: mov ecx, D$esp+edx*4-4 |jmp @2a
@z:
lea esp, D$esp+1024
pop edi |pop esi |pop edx |pop ecx |pop ebx |pop eax
ret

; CF==1 Find
; CF==0 not Find
align 4
IsExport_k:
pushad
jmp @1
@notfind: clc|jmp @z
@find: stc|jmp @z
@1: push ebp |call FindMacroWord|jc @notfind
cmp edx, ecx |jne @notfind
mov esi, eax|mov edi, ebp|mov ebp, ecx
call DCmp|jnc @find ; trovato
jmp @notfind
@z:
popad
ret

; AssegnaVettoriIstruzione(u32* vettori, u32 NMaxParole, u8* str)
; assume che NMaxParole siano abbastanza per trattare l'istruzione
; nel vettore finale si scrive dove e' arrivato i
; NB: Cambia edx==r nello stack
; 36P_str, 32P_Nvettori, 28P_vettori,24Ra,b20,c16,r12,i8,j4, k0
align 4
AssegnaVettoriIstruzione:
push ebx |push ecx |push edx |push esi |push edi |push ebp
mov edx, D$esp+28 |mov ecx, D$esp+32 |mov esi, D$esp+36 |mov
D$esp+12, 0|shl ecx, 2
xor eax, eax|xor ebx, ebx|add ecx, edx|jmp @3
@e: mov eax, ebx|stc|jmp @z
@1: jmp @9
@2: inc esi
@3: mov al, B$esi
@4: cmp B$MyTableR+eax, 6 |je @2
cmp eax, '|' |je @1 |cmp eax, 0 |je @1 |cmp eax, 10 |je @1
|cmp eax, ';' |je @1
cmp eax, ',' |je @2
cmp W$esi, ".." |je @4a
cmp D$esi, ".If " |je @4a |cmp D$esi, ".If_" |je @4a |cmp D$esi,
".Els" |je @4a |cmp D$esi, ".End" |je @4a
cmp D$esi, ".Whi" |je @4a |cmp D$esi, ".Do " |je @4a |cmp D$esi,
".Loo" |je @4a |cmp D$esi, ".Tes" |je @4a
cmp W$esi, ".D" |jne @3a|cmp B$esi+2, 'o' |jne @3a
cmp B$esi+3, 10 |je @4a |cmp B$esi+3, 13 |je @4a |cmp B$esi+3,
9 |je @4a
@3a: cmp eax, '.' |jne @4a|mov B$esi, '@'
cmp B$esi+1, '.' |jne @4a|mov B$esi+1, '@'
@4a: inc ebx
mov D$edx, esi|add edx, 4|cmp edx, ecx |jae @e
cmp eax, '[' |jne @4m
mov eax, ']' |mov B$esi, '$'
@4h: mov edi, eax
@4i: inc esi|mov al, B$esi |cmp eax, 0 |je @i99 |cmp eax, 10 |je
@i99
cmp eax, edi |jne @4i
cmp eax, ']' |jne @2
mov B$esi, ' '
jmp @2
@i99: jmp @9
@4m: cmp eax, "'" |je @4h |cmp eax, '"' |je @4h
cmp eax, '(' |je @4ma
@4maa: jmp @4n
@4ma: inc esi
@4mb: mov al, B$esi |cmp eax, 0 |je @i99 |cmp eax, 10 |je @i99
cmp eax, '(' |jne @4mb0
inc D$esp+12 |jmp @4ma
@4mb0: cmp eax, ')' |jne @4mb1
cmp D$esp+12, 0 |je @4maa
dec D$esp+12 |jmp @4ma
@4mb1: cmp eax, '~' |je @4mc |cmp eax, '&' |je @4mc |cmp eax, '|'
|je @4mc |cmp eax, '^' |je @4mc
cmp W$esi, "<<" |je @4md |cmp W$esi, ">>" |je @4md
jmp @4ma
@ee: jmp @e
@4mc: mov al, B$esi+1 |cmp eax, '(' |je @4me0|cmp eax, '&' |jne
@4mc0|mov al, B$esi+2
@4mco0: cmp eax, 'A' |jb @4ma
cmp eax, 'Z' |ja @4ma|jmp @4me0
@4mc0: cmp B$MyTable+eax, 9 |je @4ma|jmp @4me
@4md: mov al, B$esi+2 |cmp eax, '(' |je @4me0|cmp eax, '&' |jne
@4md0|mov al, B$esi+3 |jmp @4mco0
@4md0: cmp B$MyTable+eax, 9 |je @4ma|jmp @4me0
@4me: cmp B$esi, '&' |jne @4me0
cmp eax, 'A' |jb @4me0
cmp eax, 'Z' |ja @4me0|jmp @4ma
@4me0: call AllungaStringa|jc @ee|xor eax, eax|jmp @4mb
@4mf: jmp @4
@4n: mov ebp, esi
@5: inc esi
@6: mov al, B$esi
@7: cmp B$MyTableR+eax, 0 |je @5
cmp eax, ':' |jne @8|sub edx, 4|dec ebx|inc esi
call IsExport_k|jnc @8
mov B$esi, ':' |inc esi
@8: cmp eax, '~' |je @8c |cmp eax, '&' |je @8c |cmp eax, '^' |je
@8c
@8a: cmp eax, 0 |jne @4mf|jmp @9
@8c: mov al, B$esi+1 |cmp eax, '(' |je @8e0|cmp B$MyTable+eax, 9 |je
@4mf
@8e: cmp B$esi, '&' |jne @8e0|
cmp eax, 'A' |jb @8e0
cmp eax, 'Z' |ja @8e0|jmp @4
@8e0: call AllungaStringa|jc @ee|xor eax, eax|mov al, B$esi |jmp @8a
@9: mov D$edx, esi|lea eax, D$ebx+1 |clc
@z:
pop ebp |pop edi |pop esi |pop edx |pop ecx |pop ebx
ret 12

; CF==1 Errore CF==0 Ok presa
align 4
AllungaStringa:
mov eax, D$esp+4 |sub eax, 5|jle @e|jmp @1
@e: stc|jmp @z
@1: sub D$esp+4, 4|add D$esp+1096, 4|add D$esp+1100, 4 ; Aggiorna vecchi
k,j,c di LineToRosAsm()
mov ebp, D$esp+1096 |mov edi, D$esp+1096 |sub edi, 4|xor eax, eax
; allunga sempre l'array di 4 elementi che bastano
jmp @3 ; esempio " or ", " and " [primo elemento è
sovrascritto]
@2: dec edi |dec ebp
@3: mov al, B$edi |mov B$ebp, al|cmp edi, esi |ja @2
cmp W$esi, "<<" |jne @4|mov D$esi, " shl"
@3a: add esi, 4|mov W$esi, " " |add esi, 2|jmp @a
@4: cmp W$esi, ">>" |jne @5|mov D$esi, " shr" |jmp @3a
@5: xor eax, eax|mov al, B$esi
cmp eax, '~' |jne @6|mov D$esi, " not" |jmp @9
@6: cmp eax, '|' |jne @7|mov D$esi, " or " |jmp @9
@7: cmp eax, '&' |jne @8|mov D$esi, " and" |jmp @9
@8: cmp eax, '^' |jne @e|mov D$esi, " xor"
@9: add esi, 4|mov B$esi, ' ' |inc esi
@a: clc
@z:
ret

Isreg:
mov edx, D$esp+4 |cmp edx, 0 |jne @1
@e: xor eax, eax|stc|jmp @z
@1: xor eax, eax|xor ecx, ecx
mov ax, W$edx |mov cx, W$edx+2
and ax, 05f5fh
xor edx, edx|mov dl, ch|xor ch, ch ; ah,al,ch,cl
cmp B$MyTable+ecx, 6 |je @1a
cmp ecx, ',' |je @1a |cmp ecx, ';' |je @1a |cmp ecx, 13 |je
@1a |cmp ecx, 10 |je @1a |cmp ecx, 0 |je @1a ; prima 2chars
cmp ecx, '|' |je @1a |cmp ecx, '/' |je @1a ; delimitatori ammessi
cmp al, "E" |jne @e
and cl, 05fh
cmp B$MyTable+edx, 6 |je @2
cmp dl, ',' |je @2 |cmp dl, ';' |je @2 |cmp dl, 13 |je @2
|cmp dl, 10 |je @2 |cmp dl, 0 |je @2 ; 3 chars?
cmp dl, '|' |je @2 |cmp dl, '/' |je @2 ; delimitatori ammessi
jmp @e
@1a: jmp @5
@2: cmp ecx, "X" |jne @3|cmp eax, "EA" |je @r4
|cmp eax, "EB" |je @r4
|cmp eax, "EC" |je @r4
|cmp eax, "ED" |je @r4
|jmp @e
@r4: mov eax, 4|jmp @y
@3: cmp ecx, "I" |jne @4|cmp eax, "ES" |je @r4
|cmp eax, "ED" |je @r4
|jmp @e
@4: cmp ecx, "P" |jne @e|cmp eax, "ES" |je @r4
|cmp eax, "EB" |je @r4
|jmp @e
@5: xor ecx, ecx|mov cl, al
cmp ecx, "A" |je @7|cmp ecx, "B" |je @8
cmp ecx, "C" |je @9|cmp ecx, "D" |je @a
cmp ecx, "S" |je @6|jmp @e
@6: jmp @b
@7: cmp eax, "AX" |je @r2
cmp eax, "AL" |je @r1
cmp eax, "AH" |je @r1
jmp @e
@8: cmp eax, "BX" |je @r2
cmp eax, "BL" |je @r1
cmp eax, "BH" |je @r1
cmp eax, "BP" |je @r2
jmp @e
@r2: mov eax, 2|jmp @y
@r1: mov eax, 1|jmp @y
@9: cmp eax, "CX" |je @r2
cmp eax, "CL" |je @r1
cmp eax, "CH" |je @r1
jmp @e
@a: cmp eax, "DX" |je @r2
cmp eax, "DL" |je @r1
cmp eax, "DH" |je @r1
cmp eax, "DI" |je @r2
jmp @e
@b: cmp eax, "SI" |je @r2
cmp eax, "SP" |je @r2
jmp @e
@y: clc
@z:
ret 4

; u32 Install(u8* name, u8* defn)
; name e defn devono essere stringhe
; che vengono deallocate alla fine del programma
; se ritorna 0 [<=>CF==1] errore
; altrimenti ok ed in eax vi e'
; l'indirizzo del nodo istallato
; 0j,4i,8ra,12P_name,16P_defn
align 4
Install:
push esi |push edi

mov esi, D$esp+12 |mov edi, D$esp+16 |cmp esi, 0 |je @e|cmp edi,
0 |jne @1|jmp @e
@0: call FreeMem
@e: xor eax, eax|stc|jmp @z
@1: cmp D$hashtab, 0 |jne @a
; HASHSIZE=4019, 8123
; (4019+1)*4= 16080, 32496
push 32496 |call Malloc_sys|cmp eax, 0 |je @0
mov D$hashtab, eax|push 32496 |push eax |call Zero
@a: cmp D$StringPointers, 0 |jne @b
; 2048 * 4 = 8192
; 8192 * 4 = 32768
push 32768 |call Malloc_sys|cmp eax, 0 |je @0
mov D$StringPointers, eax|mov D$TheNextPointer, 0
mov D$PointerSize, 8192
push 32768 |push eax |call Zero
@b: cmp D$NodeMem, 0 |jne @i
; 512 * 4 * 4 = 8192
; Serbatoio di 512 nodi di 4 u32
; 2048*4*4 =32768
; Serbatoio di 2048 nodi di 4 u32
push 32768 |call Malloc_sys|cmp eax, 0 |je @0
mov D$NodeMem, eax|mov D$TheNext, 0
push 32768 |push eax |call Zero
@i: push esi |call Lookup|jc @5
; point to next:nx puntatore
; name:nm nome
; defn:df definizione
; defnlen:dfl lenDefinizione
; << nx=0, nm=4, df=8, dfl=12
; u32* Lookup(u8* name)
; ritorna a=0 CF==1, hashtab posizi. nodo in edx
; strlen(name) in ecx
; se non troavato
; -----------------------------------------
; altrimenti l'indirizzo del nodo trovato in eax
; l'indirizzo del precedente in edx
; strlen(name) in ecx

; Nodo trovato
cmp eax, 0 |je @e ; se Lookup ok => a==c
@2: mov D$eax+8, edi|jmp @4 ; Caso: Nodo Esistente
@3: inc edi ; => sovrascrivi
@4: cmp B$edi, 0 |jne @3
sub edi, D$eax+8 |mov D$eax+12, edi|clc|jmp @z

@5: push edx|call AllocNodo|pop edx ; r indirizzo di Hash
jc @e|mov ecx, D$edx |mov D$eax+4, esi|mov D$eax+0, ecx|mov
D$edx, eax
jmp @2 ; a indirizzo nodo
@z:

pop edi |pop esi
ret 8

; input in eax vi sta l'indice
; risultato in eax: posizione dell'indice
; a*16
; 0 1 2
; |0,0,0,0|0,0,0,0|0,0,0,0|
; u32* AllocNodo()
align 4
AllocNodo:
push ebx
mov ecx, D$TheNext |mov ebx, D$NodeMem
cmp ecx, 2048 |jae @e|cmp ebx, 0 |jne @1
@e: xor eax, eax|stc|jmp @z
@0: mov eax, ebx|jmp @3
@1: shl ecx, 4|mov edx, 32768|lea eax, D$ebx+ecx
lea ecx, D$ebx+edx |mov edx, eax ; r=a=*TheNext
@2: cmp D$eax+4, 0 |je @4 ; c=NodeMem+2048*4*4=
add eax, 16|cmp eax, ecx |je @0 ; =NodeMem+32768 Nodo limite
@3: cmp eax, edx |jne @2|jmp @e
@4: mov ecx, eax|mov D$eax+4, 1
sub eax, ebx
shr eax, 4|inc eax|cmp eax, 2048 |jne @5|mov eax, 0
@5: mov D$TheNext, eax|mov eax, ecx|clc
@z:
pop ebx
ret

; u32 FreeNodo(u32* node)
; 0,12,24,36
; 0i,4b,8ra,12P_node
align 4
FreeNodo:
push ebx |push esi

mov ebx, D$esp+12 |cmp ebx, 0 |jne @1
@e: mov eax, 1|stc|jmp @z
@1: mov edx, D$NodeMem |cmp ebx, edx |jb @e
mov esi, edx|mov eax, 2048|shl eax, 4 ; k*16
add esi, eax|cmp ebx, esi |jae @e
mov eax, ebx|sub eax, edx|test eax, 0Fh |jnz @e ; non allineato
mov D$ebx+0, 0|mov D$ebx+4, 0|mov D$ebx+8, 0|mov D$ebx+12, 0
shr eax, 4
mov D$TheNext, eax
xor eax, eax
@z:

pop esi |pop ebx
ret 4

; 0i,4b,8ra,12P_w
align 4
Installl:
push ebx |push esi
mov ebx, D$esp+12 |mov esi, ebx|jmp @2
@1: inc esi
@2: cmp B$esi, 0 |jne @1
@1a: inc esi
@1b: cmp B$esi, 0 |je @1a
push esi |push ebx |call Install|jnc @4
@e: mov eax, -1|stc|jmp @z
@3: inc esi
@4: cmp B$esi, 0 |jne @3
@4a: inc esi
@4b: cmp B$esi, 0 |je @4a
mov ebx, esi|cmp B$esi, 0FFh |jne @2
xor eax, eax|clc
@z:
pop esi |pop ebx
ret 4

; ritorna in c la lunghezza della prossima parola
; incontrata senza far muovere i
; la prossima parola puo' essere anche una stringa
align 4
WordLen_i:
push ebx
xor eax, eax|mov ecx, esi ; leva gli spazi
@0: mov al, B$ecx |cmp B$MyTableR+eax, 6 |jne @1|inc ecx|jmp @0
@1: mov edx, ecx ; conserva la posizione
cmp eax, 0 |je @3 ; se e' fine linea esci
cmp eax, '"' |je @a0 |cmp eax, "'" |je @a0 |cmp eax, 96 |je
@a0|jmp @a9 ; se e' tra apici prendi stringa
@a0: mov ebx, eax|inc edx |inc ecx
@a1: mov al, B$ecx |cmp eax, 0 |je @3|cmp eax, ebx |je @3|inc
ecx|cmp ecx, 0 |jne @a1|jmp @z
@a9: mov bl, B$MyTableR+eax ; La prima lettera
@2: inc ecx|mov al, B$ecx |cmp eax, 0 |je @3|cmp B$MyTableR+eax, bl
|je @2
@3: sub ecx, edx
@z:
pop ebx
ret

align 4
LenStr_i:
mov eax, esi|jmp @1
@0: inc eax
@1: cmp B$eax, 0 |jne @0
sub eax, esi|mov ecx, eax
ret

; InstalMacro(u8* Def, u8* Sost, u32 delimtatore)
; il delimitatore vale solo per trovare sost
; il delimitatore per def e' lo spazio: la prima
; parola e' presa
; il delimitatore per def e' la vergoletta (" o ' o `) se il primo
; carattere è una virgoletta
; InstalMacro(b,i,0)|jc .e
; il delimitatore e' 0 => prende sost fino a \0
; InstalMacro(b,i,1)|jc .e
; il delimitatore e' 1 => prende sost fino allo spazio successivo
; il delimitatore e' 2 => prende sost fino a \0 entrambi
; (virgolette incluse)
; 0k,4j,8i,12b,16ra,20P_Def,24P_Sost, 28P_delim +64
; 84 88 92
align 4
InstalMacro:
push ebx |push esi |push edi |push ebp
sub esp, 64
mov eax, D$TheNextPointer |mov ebp, D$StringPointers
mov ecx, eax|cmp ebp, 0 |je @e
cmp eax, D$PointerSize |jl @3
@e: xor eax, eax|stc|jmp @z
@0: inc eax
cmp eax, D$PointerSize |jne @1|xor eax, eax
@1: cmp ecx, eax |je @e
@3: mov edx, D$ebp+eax*4 |cmp edx, 0 |jne @0
mov edi, eax
mov esi, D$esp+84 |call WordLen_i|cmp ecx, 0 |jle @e
mov ebx, ecx|mov esi, D$esp+88
cmp D$esp+92, 1 |je @3a|call LenStr_i|cmp ecx, 0 |jle @e|jmp @3b
@3a: call WordLen_i|cmp ecx, 0 |jle @e
@3b: add ebx, ecx|jle @e|add ebx, 8|jle @e
push ebx |call Malloc_sys|cmp eax, 0 |je @e
mov D$ebp+edi*4, eax ; conserva il vettore nell'int_array
inc edi ; StringPointers
cmp edi, D$PointerSize |jb @4|xor edi, edi
@4: mov D$TheNextPointer, edi
mov ebp, ebx|sub ebp, 2|mov D$esp, eax
mov edi, eax|mov esi, D$esp+84 |call PrendiWordOrVirgolette_jki|jc
@e
inc edi|dec ebp|jle @e|mov D$esp+4, edi|mov esi, D$esp+88
cmp D$esp+92, 0 |jne @5
@4a: call CopyLine_jki|jc @e|jmp @6
@5: cmp B$esi, "'" |je @5a |cmp B$esi, '"' |je @5a |cmp B$esi, 96
|je @5a|cmp D$esp+92, 2 |je @4a
@5a: call PrendiWordOrVirgolette_jki|jc @e
@6: mov eax, D$esp |mov edx, D$esp+4 |push edx |push eax |call
Install|jc @e
@z:
lea esp, D$esp+64
pop ebp |pop edi |pop esi |pop ebx
ret 12

; prende parola alfanumerica o di punti
; parametri: i la stringa da leggere
; j la stringa da scrivere
; k la size di j
; alla fine modifica sia i,j,k
; Ritorna in ecx la lunghezza della parola
; scritta in j
;
; il primo carattere puntato da i
; non deve essere spazio
; modifica i,j,k,a,c
; NB: Salva edx
align 4
PrendiWord_jki:
push ebp|xor eax, eax|cmp ebp, 0|jl @e|jz @ee
mov al, B$esi |mov cl, B$MyTableR+eax |jmp @1
@ee: mov ecx, D$esp |sub ecx, ebp|mov B$edi, 0
@e: stc|jmp @z
@0: dec ebp |jz @ee|inc esi |inc edi
mov al, B$esi
@1: mov B$edi, al|cmp eax, 0 |je @3
cmp B$MyTableR+eax, cl |je @0
@2: mov B$edi, 0
@3: mov ecx, D$esp |sub ecx, ebp|clc
@z:
lea esp, D$esp+4
ret

; parametri: i la stringa da leggere
; j la stringa da scrivere
; k la size di j
; alla fine modifica sia i,j,k
; Ritorna in ecx la lunghezza della stringa
; scritta in j
;
; il primo carattere puntato da i
; deve essere " oppure '
; modifica i,j,k,a,c
; NB: salva edx
align 4
PrendiWordTraVirgoletteEscludendole_jki:
push ebp|xor eax, eax|xor ecx, ecx|cmp ebp, 0|mov cl, B$esi |jl
@e|jz @ee
inc esi
cmp ecx, '"' |je @2 |cmp ecx, "'" |je @2 |cmp ecx, 96 |je
@2|jmp @e
@ee: mov B$edi, 0|mov ecx, D$esp |sub ecx, ebp
@e: stc|jmp @z
@1: dec ebp |jz @ee|inc esi |inc edi
@2: mov al, B$esi |cmp eax, ecx |je @3|mov B$edi, al|cmp eax, 0
|jne @1
@3: mov B$edi, 0|mov ecx, D$esp |sub ecx, ebp|clc
@z:
lea esp, D$esp+4
ret

; la seguente funzione differisce dalla successiva dal
; fatto che prende cio' che contengono le virgolette
; senza le virgolette stesse
; NB: Salva edx
align 4
PrendiWordOrVirgolette_jki:
call LevaSpaziDa_i
xor eax, eax|mov al, B$esi
cmp eax, "'" |je @1 |cmp eax, '"' |je @1 |cmp eax, 96 |je @1
call PrendiWord_jki|jmp @2
@1: call PrendiWordTraVirgoletteEscludendole_jki
@2:
ret

align 4
LevaSpaziDa_i:
xor eax, eax
@0: mov al, B$esi |cmp B$MyTable+eax, 6 |jne @1|inc esi|jmp @0
@1: ret

; In i vi e' il nome
; In j vi e' dove lo si vuole scrivere
; In k vi e' la dimensione di j
; prende ["stringa"] oppure word
; NB: salva edx
align 4
PrendiWordSpaziVirgolette1_jki:
call LevaSpaziDa_i
xor eax, eax|mov al, B$esi
cmp eax, '"' |jne @1
@0: call PrendiWordTraVirgolette_jki|jmp @2
@1: cmp eax, "'" |je @0|cmp eax, 96 |je @0
call PrendiWord_jki|jmp @2
@2:
ret

; parametri: i la stringa da leggere
; j la stringa da scrivere
; k la size di j
; alla fine modifica sia i,j,k
; Ritorna in ecx la lunghezza della stringa
; scritta in j
;
; il primo carattere puntato da i
; deve essere " oppure '
; modifica i,j,k,a,c
; NB: salva edx
align 4
PrendiWordTraVirgolette_jki:
push ebp|xor eax, eax|xor ecx, ecx|cmp ebp, 0|mov cl, B$esi |jl
@e|jz @ee
cmp ecx, '"' |je @1 |cmp ecx, "'" |je @1 |cmp ecx, 96 |je
@1|jmp @e
@ee: mov ecx, D$esp |sub ecx, ebp|mov B$edi, 0
@e: stc|jmp @z
@1: mov B$edi, cl
@2: dec ebp |jz @ee|inc esi |inc edi
mov al, B$esi |mov B$edi, al|cmp eax, 0 |je @3|cmp eax, ecx
|jne @2
dec ebp|inc esi |inc edi|mov B$edi, 0
@3: mov ecx, D$esp |sub ecx, ebp|clc
@z:
lea esp, D$esp+4
ret

; In i vi e' il nome
; In j vi e' dove lo si vuole scrivere
; In k vi e' la dimensione di j
; NB: Salva edx
align 4
PrendiWordSpaziVirgolette_jki:
call LevaSpaziDa_i
xor eax, eax|mov al, B$esi
cmp eax, '"' |jne @1
@0: call PrendiWordTraVirgolette_jki|jmp @2
@1: cmp eax, "'" |je @0|cmp eax, 96 |je @0
call PrendiWordTraSpazi_jki
@2:
ret

; parametri: i la stringa da leggere
; j la stringa da scrivere
; k la size di j
; alla fine modifica sia i,j,k
; Ritorna in ecx la lunghezza della parola
; scritta in j
;
; il primo carattere puntato da i
; non deve essere spazio
; modifica i,j,k,a,c
; NB: Salva edx
align 4
PrendiWordTraSpazi_jki:
push ebp|xor eax, eax|cmp ebp, 0|jl @e|jz @ee
jmp @1
@ee: mov ecx, D$esp |sub ecx, ebp|mov B$edi, 0
@e: stc|jmp @z
@0: dec ebp |jz @ee|inc esi |inc edi
@1: mov al, B$esi
cmp eax, ',' |je @2 |cmp eax, ';' |je @2 |cmp eax, 13 |je @2
|cmp eax, 10 |je @2
mov B$edi, al|cmp eax, 0 |je @3
cmp B$MyTable+eax, 6 |jne @0
@2: mov B$edi, 0
@3: mov ecx, D$esp |sub ecx, ebp|clc
@z:
lea esp, D$esp+4
ret

align 4
CopyLine_jki:
push ebp|xor eax, eax|cmp ebp, 0 |jg @1
@e: mov ecx, D$esp |sub ecx, ebp|mov B$edi, 0|stc|jmp @z
@1: mov al, B$esi |cmp eax, 13 |je @1a|cmp eax, 10 |je @1a
mov B$edi, al|cmp eax, 0 |je @2|dec ebp |jz @e
inc esi |inc edi|jmp @1
@1a: mov B$edi, 0
@2: mov ecx, D$esp |sub ecx, ebp|clc
@z:
lea esp, D$esp+4
ret

; input export one, two, none
; 0i,4r,8c,12b,16ra,20P_Str
align 4
PushExport:
push ebx |push ecx |push edx |push esi
mov esi, D$esp+20 |cmp esi, 0 |jne @1
@e: stc|jmp @z
@0: clc|jmp @z
@1: mov eax, D$esi |cmp eax, "expo" |jne @e
push Iexport |call CmpS_i|jnc @e
@2: call FindNextWord_i|cmp eax, 0 |je @e |cmp eax, 10 |je @e |cmp
eax, 13 |je @e
push 1 |push esi |push esi |call InstalMacro|jc @e
call FindNextWord_i|cmp eax, 0 |je @0 |cmp eax, 10 |je @0 |cmp
eax, 13 |je @0
cmp eax, ',' |je @2|jmp @e
@z:
pop esi |pop edx |pop ecx |pop ebx
ret 4

; 0i,4r,8c,12b,16ra, 20P_Str + 2048
; 2068
align 4
PushImport:
push ebx |push ecx |push edx |push esi
sub esp, 2048
mov esi, D$esp+2068 |cmp esi, 0 |jne @1
@e: stc|jmp @z
@f: clc|jmp @z
@1: mov eax, D$esi |cmp eax, "impo" |jne @e
push Iimport |call CmpS_i|jnc @e
add esi, 6|cmp B$esi, 0 |je @e
call FindNextWordTraSPazi_i
xor eax, eax|mov al, B$esi |cmp eax, 0 |je @e |cmp eax, 13 |je
@e |cmp eax, 10 |je @e
mov D$esp+0, esi ; I parola
call FindNextWordTraSPazi_i
xor eax, eax|mov al, B$esi |cmp eax, 0 |je @e |cmp eax, 13 |je
@e |cmp eax, 10 |je @e
mov D$esp+4, esi ; II parola
call FindNextWordTraSPazi_i
xor eax, eax|mov al, B$esi |cmp eax, 0 |je @2 |cmp eax, 10 |je
@2 |cmp eax, 13 |je @2|jmp @3
@2: ; due parametri
lea edx, D$esp+2048 |lea ebx, D$esp+20
mov B$ebx, "'" |xor eax, eax|inc ebx|mov esi, D$esp+4 |jmp @2b
@2a: inc ebx |inc esi
@2b: mov al, B$esi |cmp ebx, edx |jae @e|mov B$ebx, al|cmp eax, 0
|je @2c |cmp eax, 13 |je @2c |cmp eax, 10 |je @2c
cmp B$MyTable+eax, 6 |jne @2a
@2c: mov esi, D$esp+0 |mov B$ebx, '.' |cmp ebx, edx |jae @ee|inc
ebx|mov B$ebx, 0|jmp @2e
@2d: inc ebx |inc esi
@2e: mov al, B$esi |cmp ebx, edx |jae @ee|mov B$ebx, al|cmp eax, 0
|je @2f
cmp B$MyTable+eax, 6 |jne @2d
@2f: mov B$ebx, "'" |cmp ebx, edx |jae @ee|inc ebx|mov B$ebx, 0
@2g: mov ebx, D$esp+0 |lea edx, D$esp+20
push 0 |push edx |push ebx |call InstalMacro|jc @ee
jmp @f
@3: ; tre parametri almeno
mov D$esp+8, esi ; III parola
call FindNextWordTraSPazi_i
xor eax, eax|mov al, B$esi |cmp eax, 0 |je @4 |cmp eax, 13 |je
@4 |cmp eax, 10 |je @4
@ee: jmp @e ; + di 3 parametri
@4: lea edx, D$esp+2048 |lea ebx, D$esp+20
mov B$ebx, "'" |xor eax, eax|inc ebx|mov esi, D$esp+4 |jmp @4b
@4a: inc ebx |inc esi
@4b: mov al, B$esi |cmp ebx, edx |jae @ee|mov B$ebx, al|cmp eax, 0
|je @4c
cmp B$MyTable+eax, 6 |jne @4a
@4c: mov esi, D$esp+8 |mov B$ebx, '.' |cmp ebx, edx |jae @ee|inc
ebx|mov B$ebx, 0|jmp @4e
@4d: inc ebx |inc esi
@4e: mov al, B$esi |cmp ebx, edx |jae @ee|mov B$ebx, al|cmp eax, 0
|je @4f |cmp eax, 13 |je @4f |cmp eax, 10 |je @4f
cmp B$MyTable+eax, 6 |jne @4d
@4f: mov B$ebx, "'" |cmp ebx, edx |jae @ee|inc ebx|mov B$ebx, 0
jmp @2g
@z:
lea esp, D$esp+2048
pop esi |pop edx |pop ecx |pop ebx
ret 4

; trova la prossima parola alfanumerica
; o formata da punti
; se i punta a qualche spazio prima la
; parola => ritorna la prima parola incontrata
; se i punta gia' a una parola, scarta tale
; parola e ritorna quella dopo
align 4
FindNextWord_i:
xor eax, eax|mov edx, esi
@0: mov al, B$esi |cmp B$MyTableR+eax, 6 |jne @1|inc esi|jmp @0
@1: cmp edx, esi |jne @z ; *i non e' spazio
cmp eax, 0 |je @z |cmp eax, 13 |je @z |cmp eax, 10 |je @z
; se e' fine linea esci
; scarta la parola attuale
xor edx, edx|mov edx, eax|cmp al, '"' |je @3a |cmp al, "'" |je
@3a |cmp al, 96 |je @3a
mov dl, B$MyTableR+eax ; La prima lettera
@2: inc esi|mov al, B$esi |cmp eax, 0 |je @z|cmp B$MyTableR+eax, dl
|je @2|jmp @4
@3a: inc esi|mov al, B$esi |cmp eax, 0 |je @z|cmp eax, edx |jne
@3a|xor eax, eax
; scarta gli spazi
@3: inc esi|mov al, B$esi |cmp eax, 0 |je @z
@4: cmp B$MyTableR+eax, 6 |je @3
@z:
ret

; input %define one two
; input << a=b, c=d
; 0k,4j,8i,12b,16ra,20P_Str + 1024
; 1044
align 4
PushMacro:
push ebx |push esi |push edi |push ebp
sub esp, 1024
mov esi, D$esp+1044 |xor eax, eax|cmp esi, 0 |jne @1
@e: stc|jmp @z
@1: mov al, B$esi
cmp eax, '%' |jne @2 ; definizioni tradizionali
push IIdefine |call CmpS_i|jnc @e
call FindNextWordTraSPazi_i|cmp eax, 0 |je @e
mov ebx, esi
call FindNextWordTraSPazi_i|cmp eax, 0 |je @e
push 0 |push esi |push ebx |call InstalMacro|jc @e
@1a: jmp @9
@2: mov eax, D$esi |and eax, 00000FFFFh
cmp eax, "<<" |jne @e ; definizioni con macro del tipo:
jmp @4 ;<< "<ò1 ò2" = "push ò1|push ò2"
@3: call FindNextWord_i ; inizio prossima parola
cmp eax, 0 |je @1a |cmp eax, 13 |je @1a |cmp eax, 10 |je @1a
|cmp eax, ';' |je @1a
cmp W$esi, '/*' |je @1a
cmp eax, ',' |jne @e
@4: call FindNextWord_i|cmp eax, 0 |je @e ; I parola
mov al, B$esi
cmp eax, "'" |je @4a |cmp eax, '"' |je @4a |cmp eax, 96 |je
@4a|cmp B$MyTableR+eax, 0 |jne @e
@4a: mov edx, esi|lea edi, D$esp+8 |mov ebp, 1000 ; r e' salvata dalle
funzioni
call PrendiWordSpaziVirgolette1_jki|jc @e
lea eax, D$esp+8 |push eax |call NormalizzaNumerico|mov esi, edx
call FindNextWord_i|cmp eax, '=' |jne @e
call FindNextWord_i|cmp eax, 0 |je @e ; parola
cmp eax, "'" |je @4b |cmp eax, '"' |je @4b |cmp eax, 96 |je
@4b ; B[MyTableR+a]!=0#.e
@4b: inc edi|sub ebp, 1|jle @e
mov ebx, edi|mov edx, esi ; r e' salvata dalle funzioni
call PrendiWordSpaziVirgolette_jki|jc @e
mov eax, ebx|push eax |call NormalizzaNumerico ; | i=r
@8: lea eax, D$esp+8
push 2 |push ebx |push eax |call InstalMacro|jc @e
cmp B$esi, ',' |je @8a
jmp @3
@8a: jmp @4
@9: clc
@z:
lea esp, D$esp+1024
pop ebp |pop edi |pop esi |pop ebx
ret 4


; prende una parola separata da spazi
; se i punta a qualche spazio prima la
; parola => ritorna la prima parola incontrata
; se i punta gia' a una parola, scarta tale
; parola e ritorna quella dopo
align 4
FindNextWordTraSPazi_i:
xor eax, eax|mov edx, esi
@0: mov al, B$esi |cmp B$MyTableR+eax, 6 |jne @1|inc esi|jmp @0
@1: cmp edx, esi |jne @z ; *i non e' spazio
cmp eax, 0 |je @z |cmp eax, 13 |je @z |cmp eax, 10 |je @z
; se e' fine linea esci
; scarta la parola attuale
@2: inc esi|mov al, B$esi |cmp eax, 0 |je @z |cmp eax, 10 |je @z
|cmp eax, 13 |je @z
cmp B$MyTableR+eax, 6 |jne @2
; scarta gli spazi
@3: inc esi|mov al, B$esi |cmp eax, 0 |je @z|cmp B$MyTableR+eax, 6
|je @3
@z:
ret

; 0i,4ra,8P_a
; in ecx quanti caratteri e' andato avanti
align 4
AtoI:
push esi|mov edx, D$esp+8 |xor eax, eax|xor ecx, ecx|cmp edx, 0
|je @e
mov cl, B$edx |cmp B$MyTable+ecx, 0 |je @2
@e: xor ecx, ecx|mov eax, -1|stc|jmp @z ; 10a=(4a+a)*2
@1: inc edx|mov cl, B$edx |cmp B$MyTable+ecx, 0 |jne @3
test eax, 0C0000000h |jnz @e|mov esi, eax
shl eax, 2|add eax, esi|jc @e|add eax, eax|jc @e
@2: sub ecx, '0' |add eax, ecx|jnc @1|jmp @e
@3: mov ecx, edx|sub ecx, D$esp+8 |clc
@z:
pop esi
ret 4

; 0j,4i, 8ra, 12P_str
; salva edx
align 4
NormalizzaNumerico:
push esi |push edx
mov esi, D$esp+12 |xor edx, edx|cmp esi, 0 |je @z|jmp @1
@0: inc esi|push esi |call AtoI|jc @0a
cmp eax, 0 |je @0a|cmp eax, 255 |ja @0a
mov B$esi, al|dec ecx
push ecx |push esi |call sposta
inc esi
@0a: xor edx, edx
@1: mov dl, B$esi |cmp edx, 'ò' |je @0
cmp edx, 0 |je @z|inc esi|cmp esi, 0 |jne @1
@z:
pop edx |pop esi
ret 4

;0r, 4c,8b,12ra,16P_string, 20P_quanti
align 4
sposta:
push ebx |push ecx |push edx
mov ebx, D$esp+16 |mov edx, D$esp+20 |inc ebx
xor eax, eax|cmp edx, 0 |jle @z
jmp @1
@0: inc ebx
@1: mov al, B$ebx+edx |mov B$ebx, al|cmp eax, 0 |jne @0
lea ecx, D$ebx+edx
@2: inc ebx
mov B$ebx, 0|cmp ebx, ecx |jb @2
@z:
pop edx |pop ecx |pop ebx
ret 8

; 0k,4j,8i,12b,16ra,20P_Str + 1024
; 1044
align 4
UndefMacro:
push ebx |push esi |push edi |push ebp
sub esp, 1024

mov ebx, D$esp+1044 |cmp ebx, 0 |jne @1
@e: mov eax, 1|stc|jmp @z ; in r precedente [compreso puntatore di hash]
@0: mov edi, esp|mov esi, ebx|mov ebp, 1020|call
PrendiWordTraVirgoletteEscludendole_jki|jc @e
mov eax, esp|push eax |call NormalizzaNumerico|jmp @4
@1: mov edx, esp|mov ecx, 1020|add ecx, edx|xor eax, eax|mov al,
B$ebx |cmp eax, "'" |je @0 |cmp eax, '"' |je @0
@2: mov al, B$ebx |cmp B$MyTableR+eax, 0 |jne @3|cmp eax, 0 |je
@3|mov B$edx, al
inc edx |inc ebx|cmp edx, ecx |jae @e|jmp @2
@3: mov B$edx, 0
@4: mov eax, esp|push eax |call Lookup ; in a attuale
cmp eax, 0 |je @e ; in r precedente [compreso puntatore di hash]
mov ecx, D$eax+0 |mov D$edx+0, ecx
mov ebx, D$eax+4
push eax |call FreeNodo|jc @e
; qui a==0 ed CF==0
push ebx |call FreeIfFindAddressInString|jc @e
@z:
lea esp, D$esp+1024

pop ebp |pop edi |pop esi |pop ebx
ret 4

; 0j,4ra,8P_Str
align 4
FreeIfFindAddressInString:
push edi|xor eax, eax
mov edi, D$StringPointers
mov ecx, D$esp+8 |cmp edi, 0 |je @e
cmp D$PointerSize, 0 |jg @3
@e: xor eax, eax|stc|jmp @z
@0: inc eax|cmp eax, D$PointerSize |je @e
@3: mov edx, D$edi+eax*4
cmp edx, ecx |jne @0
push eax|push edx |call Free_sys|pop eax
jc @e
mov D$edi+eax*4, 0
mov D$TheNextPointer, eax
@z:
pop edi
ret 4

; input %undef one
; input >> a,b, c, d
; 0i,4b,8ra,12P_Str
align 4
PopMacro:
push ebx |push esi
mov esi, D$esp+12 |xor eax, eax|cmp esi, 0 |jne @1
@e: stc|jmp @z
@1: mov al, B$esi
cmp eax, '%' |jne @2
push IIundef |call CmpS_i|jnc @e
inc esi
call FindNextWordTraSPazi_i|cmp eax, 0 |je @e
push esi |call UndefMacro|jmp @z
@2: mov eax, D$esi |and eax, 00000FFFFh
cmp eax, ">>" |jne @e
@3: call FindNextWord_i|cmp eax, 0 |je @e
@4: mov al, B$esi |cmp al, "'" |je @4a |cmp al, '"' |je @4a
cmp B$MyTableR+eax, 0 |jne @e
@4a: push esi |call UndefMacro|jc @e
call FindNextWord_i
cmp eax, 0 |je @5 |cmp eax, 10 |je @5 |cmp eax, 13 |je @5
|cmp eax, ';' |je @5
cmp W$esi, '\*' |je @5
cmp eax, ',' |jne @e
jmp @3
@5: clc
@z:
pop esi |pop ebx
ret 4

; a==128 fine di i con \0
; a== 1 fine di i con \n
; a== 0 trovato qualcosa di diverso
align 4
HaLaLineaQualcheParola_i:
xor eax, eax|mov edx, esi
@0: mov al, B$edx |cmp B$MyTableR+eax, 6 |jne @1|inc edx|jmp @0
cmp eax, 13 |jne @1|inc edx|mov al, B$edx
@1: cmp eax, 10 |je @4
cmp eax, 0 |je @5
xor eax, eax|stc|jmp @z
@4: mov eax, 1|clc|jmp @z
@5: mov eax, 128|clc
@z:
ret

; parametri: i la stringa da leggere
; j la stringa da scrivere
; k la size di j
; alla fine modifica sia i,j,k
; Ritorna in ecx la lunghezza della stringa
; scritta in j
;
; il primo carattere puntato da i
; deve essere " oppure '
; modifica i,j,k,a,c
; NB: Salva edx
align 4
PrendiPseudoWordTraVirgolette_jki:
push ebp|xor eax, eax|xor ecx, ecx|cmp ebp, 0|mov cl, B$esi |jl
@e|jz @ee
cmp ecx, '"' |je @1 |cmp ecx, "'" |je @1 |cmp ecx, 96 |je
@1|jmp @e
@ee: mov ecx, D$esp |sub ecx, ebp|mov B$edi, 0
@e: stc|jmp @z
@1: mov B$edi, 'I'
@2: dec ebp |jz @ee|inc esi |inc edi
mov al, B$esi
cmp eax, '.' |je @1a0
cmp B$MyTable+eax, 2 |jbe @1a
@1a0: mov B$edi, 'I' |jmp @1b
@1a: mov B$edi, al
@1b: cmp eax, 0 |je @3|cmp eax, ecx |jne @2
inc esi
@3: mov B$edi, 0|mov ecx, D$esp |sub ecx, ebp|clc
@z:
lea esp, D$esp+4
ret

; parametri: i la stringa da leggere
; j la stringa da scrivere
; k la size di j
; alla fine modifica sia i,j,k
; Ritorna in ecx la lunghezza della stringa
; scritta in j
align 4
CopyMacro_jki:
push ecx
mov D$esp+0, 0|cmp esi, 0 |je @e
push esi |call FindMacroWord|cmp eax, 0 |je @e
cmp ebp, ecx |jbe @e|mov D$esp, ecx
add esi, edx
push esi |push ebp
mov esi, eax|mov ebp, ecx|call DCopy
pop ebp |pop esi
add edi, eax|sub ebp, eax|jmp @9
@e: stc|jmp @z
@9: clc
@z:
pop ecx
ret

; j:Destination, k:destinationSize, i:origin
;
align 4
GetData_jki:
push edi|sub esp, 64
mov D$esp, 0|cmp ebp, 0 |jle @e
jmp @tris0
@inizio:
mov D$esp, 1
@tris0:
call LevaSpaziDa_i
mov eax, D$esi |cmp al, 0 |je @0|cmp al, 10 |jne @1
mov B$edi, 10|dec ebp |jz @e0|inc edi
@bis0: mov B$edi, 0|mov eax, 1
@biss: clc|jmp @z
@0: mov B$edi, 0|mov eax, 128|clc|jmp @z
@e0: mov B$edi, 0
@e: xor eax, eax|stc|jmp @z
@1: cmp ax, 00A0Dh |jne @2|sub ebp, 2|jbe @e0
mov W$edi, ax|add edi, 2|add esi, 2|jmp @bis0
@2: cmp ax, 02A2Fh |jne @0x ; /*
mov B$edi, ';' |dec ebp |jz @e0|inc edi|add esi, 2
@2aa: call CopyUntil10Or0_jki|jc @e0
jmp @biss
@0x: cmp al, ';' |jne @0y
mov W$edi, ' ;' |sub ebp, 2|jle @e0|add edi, 2|inc esi
jmp @2aa
@0y: cmp al, '"' |jne @1d
@1a: cmp D$esp, 0 |je @1b|call PrendiWordTraVirgolette_jki|jc @e0
jmp @inizio
@1b: call PrendiPseudoWordTraVirgolette_jki|jc @e0
mov B$edi, ':' |dec ebp |jz @e0|inc edi
mov B$edi, ' ' |dec ebp |jz @e0|inc edi
jmp @inizio
@1d: cmp al, "'" |je @1a
mov edx, D$esi+4
cmp eax, "time" |je @2b
@2a: jmp @7
@2b: push Itimes |call CmpS_i|jnc @2a
;rx!="s "#.2a /* 0==time 1==48 2==db 3==num 4==fine
lea eax, D$esp+8 |push esi |push 5 |push eax |call
AssegnaVettori|cmp eax, 5 |jne @e0
mov edx, D$esp+8+(4*2) |mov eax, D$edx |and eax, 000FFFFFFh
cmp al, 'd' |jne @e0
and ah, 05fh ; da minuscola a maiuscola
mov B$edi, ah|dec ebp |jz @e0|inc edi
sub ebp, 2|jle @e0
mov W$edi, "$ " |add edi, 2
shr eax, 16|cmp B$MyTable+eax, 6 |jne @e0
mov edx, D$esp+8+(4*3) |cmp B$edx, '"' |je @3 |cmp B$edx, "'"
|je @3
push esi|mov esi, edx|call CopyMacro_jki|pop esi|jc @6a|jmp @4
@3: mov al, B$edx |mov B$edi, al|dec ebp |jz @e0|cmp eax, 0 |je @4
|cmp eax, 13 |je @4 |cmp eax, 10 |je @4
inc edx |inc edi|cmp B$MyTable+eax, 6 |jne @3
@4: mov B$edi, ' ' |dec ebp |jz @e0|inc edi
mov B$edi, '#' |dec ebp |jz @e0|inc edi
mov edx, D$esp+8+(4*1)
push esi|mov esi, edx|call CopyMacro_jki|pop esi|jc @6a
@6: mov esi, D$esp+8+(4*4)
mov B$edi, ' ' |dec ebp |jz @6a|inc edi
jmp @inizio
@6a: jmp @e0
@7: and eax, 000FFFFFFh
cmp eax, "res" |jne @7a|cmp B$esi+3, 0 |je @7a
xor edx, edx|mov dl, B$esi+4 |cmp B$MyTable+edx, 6 |jne @7a
;B[i+4]==' '!#.7a
mov dl, B$esi+3 |sub ebp, 6|jle @6a
and dl, 05fh ; da minuscola a maiuscola
mov B$edi, dl|inc edi
mov D$edi, "$ ? " |add edi, 4|add esi, 4
mov B$edi, "#" |inc edi
call LevaSpaziDa_i
call CopyMacro_jki|jc @6a
mov B$edi, ' ' |dec ebp |jz @6a|inc edi
jmp @inizio
@7a: cmp al, 'd' |jne @8|cmp B$esi+1, 0 |je @8
xor edx, edx|mov dl, B$esi+2 |cmp B$MyTable+edx, 6 |jne @8
;B[i+2]==' '!#.8
mov dl, B$esi+1 |sub ebp, 3|jle @6a
and dl, 05fh ; da minuscola a maiuscola
mov B$edi, dl|inc edi
mov W$edi, "$ " |add edi, 2|add esi, 2
jmp @inizio
@8: and eax, 0FFh ; Numeri
cmp B$MyTable+eax, 0 |jne @9
@7b: mov dl, B$esi |call PrendiWord_jki|jc @6a|cmp dl, ',' |jne @7c
mov B$edi, ' ' |dec ebp |jz @6a|inc edi
@7c: jmp @inizio
; Alfanumerici non numeri
@9: cmp B$MyTableR+eax, 0 |jne @a
cmp D$esp, 0 |jne @9a
mov edx, esi
call PrendiWord_jki|jc @9b
cmp B$esi, ':' |jne @8a|inc esi
@8a: mov B$edi, ":" |dec ebp |jz @9b|inc edi ; appendi ':'
push ebp|mov ebp, edx|call IsExport_k|pop ebp|jnc @8b
mov B$edi, ":" |dec ebp |jz @9b|inc edi ; '::'
@8b: mov B$edi, " " |dec ebp |jz @9b|inc edi
jmp @inizio
@9a: call CopyMacro_jki|jc @9b
jmp @inizio
@9b: jmp @e0
@a: cmp B$MyTable+eax, 9 |je @7b
mov B$edi, al|dec ebp |jz @9b|inc edi |inc esi
jmp @inizio
@z:
lea esp, D$esp+68
ret

; AssegnaVettori(u32* vettori, u32 NParole, u8* str)
; assume che vettori sia abbastanza per Nparole+1
; nel vettore finale si scrive dove e' arrivato i
; 28P_str, 24P_Nvettori, 20P_vettori,16Ra,b12,c8,r4,i0
align 4
AssegnaVettori:
push ebx |push ecx |push edx |push esi
mov ecx, D$esp+24 |mov esi, D$esp+28 |mov edx, D$esp+20 |shl ecx,
2
xor eax, eax|xor ebx, ebx|add ecx, edx|jmp @3
@2: inc esi
@3: mov al, B$esi
@4: cmp B$MyTable+eax, 6 |je @2
cmp eax, 0 |je @8
inc ebx
mov D$edx, esi|add edx, 4|cmp edx, ecx |je @8
@5: inc esi
@6: mov al, B$esi
@7: cmp B$MyTableR+eax, 0 |je @5
cmp eax, '"' |je @5 |cmp eax, "'" |je @5
cmp eax, 0 |jne @4
@8: mov D$edx, esi
@z: mov eax, ebx
pop esi |pop edx |pop ecx |pop ebx
ret 12

; u32
; M2dToRosAsmInMemWithNoStdOutput(u32* dst,u32 dstLenMax,u32* org,u32 orgLen)
; NB:
; se orgLen!=0 => deve essere scrivibile B*org+orgLen e viene posto
; B*org+orgLen=0
; se orgLen==0 => l'input della routine e' la 0-terminata string di "org"
; CF==1 eax==n errore ove n e' il numero ultimo di linea trattato
; CF==0 eax==n Tutto ok, n e' il numero di errori non segnalati
; in ecx avanzamento in "dst"
; in edx avanzamento in "org"
; 0k,4j,8i,12b,16ra, 20P_d, 24P_dLenMax, 28P_o, 32P_oLen + 64
; 84 , 88 , 92 , 96
align 4
M2dToRosAsmInMemWithNoStdOutput:
push ebx |push esi |push edi |push ebp
sub esp, 64

mov edi, D$esp+84 |mov ebx, D$esp+88 |mov esi, D$esp+92 |mov ebp,
D$esp+96 |mov D$esp+12, 0|mov D$esp+20, 0|cmp edi, 0 |jne @0
@e: mov ecx, edi|mov edx, esi|sub ecx, D$esp+84 |sub edx, D$esp+92
|mov eax, D$esp+20 |stc|jmp @z
@0: cmp ebx, 0 |jle @e|cmp esi, 0 |je @e|cmp ebp, 0 |jl @e
jz @1|lea eax, D$esi+ebp |mov B$esi+ebp, 0|mov D$esp+12, eax
@1: mov D$esp+24, 0|mov D$esp+20, 0|xor ebp, ebp|jmp @3
@ee: jmp @e
@bb: jmp @b
@printError:
inc D$esp+24
mov ebp, D$esp+0 |and ebp, 0FFFFh
test ebp, 128 |jnz @bb ; incontrato 0
@3: push ebp |push esi |push ebx |push edi |call LineToRosAsm|mov
D$esp+0, eax
shr eax, 16|and eax, 0ffh|add D$esp+20, eax|mov eax, D$esp+0 ;
aggiorna il numero di linee trattato
; tutto ok: fine di input
; oppure errori fine memoria
; oppure non avanzano [i oppure j]
@3a: cmp edx, 0 |je @eee
add esi, edx|jc @eee|cmp D$esp+12, 0 |je @4|cmp esi, D$esp+12 |ja
@eee
@4: add edi, ecx|jc @eee|sub ebx, ecx|jle @eee
; trovato errore nella linea
; linea:instruzione
test eax, 4 |jnz @9
; Lo stato di uscita normale
test eax, 128 |jnz @bb ; incontrato 0
; prosegue niente di anormale
and eax, 0FFFFh|mov ebp, eax|jmp @3
@9: jmp @printError
@eee: test eax, 128 |jnz @b ; se incontrato 0 tutto ok
jmp @e ; errore inrecuperabile
@b: mov ecx, edi|mov edx, esi|sub ecx, D$esp+84 |sub edx, D$esp+92
|mov eax, D$esp+24 |clc
@z:

lea esp, D$esp+64
pop ebp |pop edi |pop esi |pop ebx
ret 16

; dopo il preparser conta gli statement
; sul modello di quello usato nel programma
; sull'origine di rosasm file
; contiamo "|", 10, '['
; a:NStatements ContatoreDiStatements(u8* org, u32 orgsz)
; 0k,4j,8i,12b,16ra, 20P_org, 24P_orgsz
align 4
ContatoreDiStatements:
push ebx |push esi |push edi |push ebp
xor esi, esi|mov eax, D$esp+20 |mov ecx, D$esp+24 |xor edx,
edx|mov ebp, 1
cmp eax, 0 |je @e|cmp ecx, 0 |jl @e
add ecx, eax|jc @e|jz @e
lea edi, D$ecx-4
jmp @2
@e: mov eax, esi|stc|jmp @z
@0: mov eax, esi|clc|jmp @z
@1: inc eax
@2: cmp eax, ecx |jae @0
cmp B$eax, ';' |jne @3
mov edx, D$esp+20
push ecx|call PrendiDoppioStatement|pop ecx|jc @3
mov ebp, 1 ; prendi la prossima
@1b: jmp @1
@ee: jmp @e
@3: cmp edx, 2 |je @e
mov dl, B$eax
cmp edx, ";" |jne @4
@3a: inc eax|cmp eax, ecx |jae @ee|cmp B$eax, 10 |jne @3a
mov ebp, 1 ; prendi la prossima
jmp @1b
@4: cmp edx, '"' |jne @5
@4a: inc eax|cmp eax, ecx |jae @ee|cmp B$eax, dl |jne @4a
jmp @1b
@5: cmp edx, "'" |je @4a ; \13\10 ; ; \13\10
cmp edx, '[' |jne @6 ; 1 2 3 4 5 6
inc esi
@5a: inc eax|mov dl, B$eax |cmp eax, ecx |jae @ee
cmp edx, '"' |jne @5c
@5b: inc eax|cmp eax, ecx |jae @ee|cmp B$eax, dl |jne @5b|jmp @5a
@5c: cmp edx, "'" |je @5b
cmp edx, ";" |jne @5cg
mov edx, D$esp+20
push ecx|call PrendiDoppioStatement|pop ecx|jnc @5a
mov edx, 10|jmp @5b
@5cg: cmp edx, ']' |jne @5a
mov ebp, 0 ; non prendere la prossima
@5d: jmp @1
@6: cmp edx, "|" |jne @7
@6a: mov ebp, 1|jmp @1
@7: cmp edx, 10 |je @6a |cmp edx, 1 |je @6a ; 1 è lo statement che non
conta
cmp ebp, 0 |je @5d
cmp edx, '_' |je @5d
cmp edx, ' ' |jbe @5d|mov ebp, 0|inc esi|jmp @5d
@z:
pop ebp |pop edi |pop esi |pop ebx
ret 8

; trovati 01a06h statements in mh.m

; in input "r" ==inizio dell'array in "a"
; j=max(a)-4
; c==NLines
; CF==0 preso r=0
; CF==1 non preso r=2 errore
; r=1 vai avanti
align 4
PrendiDoppioStatement:
xor ecx, ecx|jmp @1
@e0: mov edx, 2|stc|jmp @z
@e: mov edx, 1|stc|jmp @z
@1: cmp eax, edi |jae @e
cmp W$eax, ";;" |jne @e
cmp eax, edx |jbe @a
cmp B$eax-1, 10 |jne @e
@a: cmp B$eax+2, 13 |jne @e
cmp B$eax+3, 10 |jne @e
@b: inc eax|cmp eax, edi |jae @e0
cmp B$eax, 10 |jne @b1|inc ecx
@b1: cmp W$eax, ";;" |jne @b
|cmp B$eax-1, 10 |jne @b
|cmp B$eax+2, 13 |jne @b
|cmp B$eax+3, 10 |jne @b
add eax, 3 ; ;,;,13,10
; 0 1 2 3
inc ecx
@3: xor edx, edx
@z:
ret

align 4
AllineaGliAccapo:

push eax|mov eax, D$esp+60 |xor edx, edx
cmp eax, D$esp+56 |jae @r|jmp @e
@b: inc eax ; conta i \n
@c: cmp eax, D$esp+56 |jae @f ; in modo che code e traslazione
@d: inc ebx ; siano nello stesso numero di riga
@e: cmp ebx, ebp |jae @ee|mov dl, B$ebx |cmp edx, 10 |je @b|jmp @d
@f: mov D$esp+60, eax|inc ebx|jmp @r
@p: inc ebx
@r: cmp ebx, ebp |jae @ee
@s: cmp B$ebx, '_' |je @p|cmp B$ebx, 13 |je @t |cmp B$ebx, 10 |je
@t|cmp B$ebx, ' ' |jbe @p
@t: clc|jmp @z
@ee: stc
@z:
pop eax

ret

; dopo il preparser conta gli statement
; sul modello di quello usato nel programma
; sull'origine di rosasm file
; contiamo "|", 10, '['
; NB: Cambia P_org sostituendo 1 con "|"
; a:NStatements
; AssociatoreDiStatements(u32* StmPtr, u32 StmPtrS,
; u8* Org, u32 OrgSz, u8* CodeP, u32 CodeSz)
; 0k,4j,8i,12b,16ra,
; 20P_StmPtr, 24P_StmPtrSz, 28P_Org, 32P_OrgSz, 36P_CodeP, 40P_CodeSz +64
; 84 88 92 96 100 104
align 4
AssociatoreDiStatements:
push ebx |push esi |push edi |push ebp

sub esp , 64 ; Statement=2 inizio file
xor esi , esi|mov eax , D$esp+92 |mov ecx , D$esp+96 |xor edx , edx|mov
D$esp+44 , 1
mov D$esp+40 , 0|mov D$esp+52 , 0|mov D$esp+48 , 0
cmp eax , 0 |je @e|cmp ecx , 0 |jl @e
add ecx , eax|jc @e|jz @e
lea edi , D$ecx-4 |mov ebx , D$esp+100 |mov D$esp+56 , edi
mov ebp , D$esp+104 |cmp D$esp+104 , 0 |jle @e ; a,c == Org, MaxPorg
mov edi , D$esp+84 |add ebp , ebx ; b,k == CodeP, MaxPCode
cmp ebx , 0 |je @e|cmp edi , 0 |je @e ; j è libero
mov D$edi+esi*4 , ebx ; la talvola è inizializzata
jmp @2
@e: mov eax , esi|stc|jmp @z
@0: mov eax , esi|clc|jmp @z
@1: inc eax
@2: cmp eax , ecx |jae @0
xor edx , edx
cmp B$eax , ";" |jne @3aa
mov edi , D$esp+56 |mov edx , D$esp+92 ; doppio statement in code
push ecx|call PrendiDoppioStatement|add D$esp+48+4 , ecx|pop ecx
mov edi , D$esp+84
cmp edx , 0 |jne @3
mov D$esp+40 , 0 ; statement normale
mov D$esp+44 , 1 ; prendi la prossima
@1b: jmp @1
@ee: jmp @e
@3: cmp edx , 2 |je @e
@3aa: mov dl , B$eax
cmp edx , ";" |jne @4
@3a: inc eax|cmp eax , ecx |jae @ee|cmp B$eax , 10 |jne @3a
mov D$esp+44 , 1 ; prendi la prossima
inc D$esp+48
mov D$esp+40 , 0
mov D$esp+44 , 1 ; prendi la prossima
jmp @1b ; main statement inizia con " o '
@4: cmp edx , '"' |jne @5 ; quindi si puo' mettere prima
@4a: inc eax|cmp eax , ecx |jae @ee
cmp B$eax , 10 |jne @4b|inc D$esp+48
@4b: cmp B$eax , dl |jne @4a
jmp @1b
@5: cmp edx , "'" |je @4a
cmp edx , '[' |je @5aa|jmp @6
@5aa: call AllineaGliAccapo|jc @ee
cmp esi , D$esp+88 |ja @ee|mov D$edi+esi*4 , ebx
inc esi
@5a: inc eax|mov dl , B$eax |cmp eax , ecx |jae @ee
cmp edx , '"' |jne @5c
@5b: inc eax|cmp eax , ecx |jae @ee
cmp B$eax , 10 |jne @5bb|inc D$esp+48
@5bb:
cmp B$eax , dl |jne @5b|jmp @5a
@5c: cmp edx , "'" |je @5b
cmp edx , ";" |jne @5cg
mov edi , D$esp+56 |mov edx , D$esp+92 ; doppio statement in data
push ecx|call PrendiDoppioStatement|add D$esp+48+4 , ecx|pop ecx
mov edi , D$esp+84
cmp edx , 0 |je @5a ; preso
cmp edx , 2 |je @ee ; errore
; altrimenti e' ";"
mov edx , 10|jmp @5b
@5cg:
cmp edx , 10 |jne @5cc|inc D$esp+48
@5cc:
cmp edx , ']' |jne @5a
mov D$esp+40 , 0
@5d: jmp @1
@eee:
jmp @e
@6: cmp edx , "|" |jne @7
@6aa:
mov D$esp+40 , 1
@6a: mov D$esp+44 , 1|jmp @1
@7: cmp edx , 10 |jne @7a|inc D$esp+48 |mov D$esp+40 , 0|jmp @6a
@7a: cmp edx , 1 |jne @7aa|mov D$esp+40 , 0|mov B$eax , '|'|jmp @6a ;
statement fittizio
@7aa:
cmp D$esp+44 , 0 |je @5d
cmp edx , '_' |je @5d
cmp edx , ' ' |jbe @5d
mov D$esp+44 , 0
cmp eax , D$esp+92 |jbe @7a0|cmp B$eax-1 , 10 |jne @7a9
@7a0:
cmp edx , 'T' |jne @7a1|cmp D$eax , "TITL" |jne @7a9
push esi|mov esi , eax|push ITITLE |call CmpS_i|pop esi|jc @5d
jmp @7a9
@7a1:
cmp edx , 'P' |jne @7a9|cmp D$eax , "PREP" |jne @7a9
push esi|mov esi , eax|push IPREPARSE |call CmpS_i|pop esi|jc @5d
@7a9:
call AllineaGliAccapo|jc @eee
cmp D$esp+40 , 0 |je @7b
call NextStatement_b
@7b: cmp esi , D$esp+88 |jae @ee|mov D$edi+esi*4 , ebx
inc esi|jmp @1
@z:

lea esp , D$esp+64
pop ebp |pop edi |pop esi |pop ebx
ret 24





; 40 + 4 + 8= 52
align 4
NextStatement_b:
push eax |push edx

mov edx, ebx|xor eax, eax|jmp @1
@e: mov D$esp+52, 1|stc|jmp @z
@0: inc edx
@1: cmp edx, ebp |jae @e|mov al, B$edx
cmp eax, '"' |jne @1b
@1a: inc edx|cmp edx, ebp |jae @e|cmp B$edx, al |jne @1a|jmp @0
@1b: cmp eax, "'" |je @1a
cmp eax, 10 |je @4 |cmp eax, ';' |je @4 ; fine linea
cmp eax, '/' |jne @2|cmp W$edx, '/*' |je @4
@2: cmp eax, '|' |jne @0
@3: inc edx
@3a: cmp edx, ebp |jae @e
@3b: cmp B$edx, '_' |je @3|cmp B$ebx, 13 |je @3c |cmp B$ebx, 10 |je
@3c|cmp B$edx, ' ' |jbe @3
@3c: mov ebx, edx|jmp @5 ; cambia b
@4: mov D$esp+52, 1 ; non aggiorna b
@5: clc ; e questa funzione non interviene +
@z:

pop edx |pop eax
ret

; Serve per undef tutte le macro che non appartengono
; al linguaggio
; notabene: tutte le macro definizioni del linguaggio
; devono essere tra le label
; MacroDefinizioniGenerali..EndofAllMacros
align 4
UndefAllNotLanguageMacros:
push ebx |push esi |push edi |push ebp

mov esi, D$hashtab |mov edi, D$hashtab
add esi, 32496|jc @e|cmp edi, 0 |jne @0
@e: xor eax, eax|stc|jmp @z
@0: cmp D$edi, 0 |jne @2
@1: add edi, 4|cmp edi, esi |jb @0
mov eax, edi|sub eax, D$hashtab |clc|jmp @z
@2: mov eax, D$edi |mov ebx, edi
@3: mov edx, D$eax+4 |mov ebp, D$eax+0
cmp edx, MacroDefinizioniGenerali |jb @4
cmp edx, EndofAllMacros |ja @4
cmp ebp, 0 |je @1 ; caso
mov ebx, eax|mov eax, ebp|jmp @3 ; "LanguageMacros"
@4: mov edx, D$eax+4 |mov D$ebx+0, ebp|push edx|push eax |call
FreeNodo|pop edx|jc @ee
push edx |call FreeIfFindAddressInString|jc @ee
mov eax, ebp|cmp ebp, 0 |jne @3|jmp @1
@ee: jmp @e
@z:

pop ebp |pop edi |pop esi |pop ebx
ret


cancellaLinea_ij:
xor eax , eax|jmp @9
@8: inc esi |inc edi
@9: cmp edi , D$esp+28 |jae @x
mov al , B$esi |cmp eax , 0 |je @x |cmp eax , 13 |je @x |cmp eax , 10 |je
@x |cmp eax , ';' |je @x
cmp W$esi , '/*' |je @x|mov B$esi , ' '|jmp @8
@x:
ret

levaSpazi_ij:
xor eax , eax|jmp @2
@e: stc|jmp @z
@1: inc esi |inc edi
@2: cmp edi , D$esp+28 |jae @e
mov al , B$esi |cmp B$MyTable+eax , 6 |je @1
@3: clc
@z:
ret

; ControllaPreparse(u32* org, u32 orgLen)
; a==0 non incontrato il preparser giusto
; a==1 trovato RosNasm, a=2 trovato Macro2d
; 0k,4j,8i,12b, 16ra, 20P_org, 24P_orgLen
align 4
ControllaPreparse:
push ebx |push esi |push edi |push ebp
mov esi , D$esp+20 |xor edi , edi|xor eax , eax|cmp esi , 0 |jne @1
@e: xor eax , eax|stc|jmp @z
@xx: jmp @x
@99: jmp @9
@0: inc esi |inc edi
@1: cmp edi , D$esp+24 |jae @xx
mov al , B$esi |cmp eax , 0 |je @xx|cmp eax , 32 |jbe @0
push ITITLE |call CmpS_i|jc @99
push IPREPARSE |call CmpS_i|jnc @xx
mov ebx , esi|mov ebp , edi
add edi , 8|cmp edi , D$esp+24 |jae @xx|add esi , 8
call levaSpazi_ij|jc @xx
push IRosNasm |call CmpSMm_i|jnc @2
cmp D$PreparseMacro2D , 1 |jne @1a
call FreeMem
mov D$PreparseMacro2D , 0
jmp @1aa
@1a: cmp D$PreparseRosNasm , 0 |jne @1b
@1aa:
call InstallNasmInRosams|jc @ee
mov D$PreparseRosNasm , 1
@1b: mov edi , ebp|mov esi , ebx|call cancellaLinea_ij
mov eax , 1|jmp @y
@ee: jmp @e
@2: push IMacro2D |call CmpSMm_i|jnc @9
cmp D$PreparseRosNasm , 1 |jne @2a
call FreeMem
mov D$PreparseRosNasm , 0
jmp @2aa
@2a: cmp D$PreparseMacro2D , 0 |jne @2b
@2aa:
call InstallRosInRosams|jc @ee
mov D$PreparseMacro2D , 1
@2b: mov edi , ebp|mov esi , ebx|call cancellaLinea_ij
mov eax , 2|jmp @y
@8: inc esi |inc edi
@9: cmp edi , D$esp+24 |jae @x
mov al , B$esi |cmp eax , 0 |je @x|cmp eax , 10 |jne @8
jmp @0
@x: xor eax , eax
@y: clc
@z:
pop ebp |pop edi |pop esi |pop ebx
ret 8








.