[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c

Re: example4-25 of c++cookbook

io_x

7/11/2011 6:09:00 AM

[comp.lang.c++,comp.lang.c,comp.programming,alt.lang.asm]
"eric" <cneric12lin0@gmail.com> ha scritto nel messaggio
news:5b15b612-b003-4b37-8859-38af722dd4f3@v7g2000prl.googlegroups.com...
Dear advanced programers:

> In that book's chapter 4 Section 16: Wrapping Lines in a Text File
>author desribe:
>Problem
>You want to "wrap" text at a spicific number of characters in a file.
>For example, if
>you want to wrap text at 72 characters, you would insert a new-line
>character after
>every 72 characters in the file. If the file contains human-readable
>text, you probably
>want to avoid splitting words.
>Solution
>Write a function that uses input and output streams to read in
>characters with
>istream::get(char), do some bookkeeping, and wirte our characters with
>ostream::
>put(char). Example 4-25 shows how to do this for text files that
>contain human-
>readable text without splitting words.
>c++ cookbook 's example source code is here
>http://examples.oreilly.com/9780...

very interesting problem...

this is my solution in .asm [that splipt if long words> maxSizeLine];
i tried some time one solution more difficult but
afther many debugging time no good result;

when i thought to this solution, using sub functions
all goes well the first time of the run
don't know why...
so it could be full of errors and can make seg fault
your pc if not worse.

I wait for your C or C++ or whatherver other language
solution: i think if the language not have one function
like the RompiLinee() below; it is difficult for you
to write such program.

----------------------------
;Nasmw -fobj thisFile.asm
;bcc32 -v ThisFile.obj

section _DATA use32 public class=DATA

global _main
extern _printf
extern _fputc
extern _fgetc
extern _fclose
extern _fopen
extern _atoi
extern _isspace
extern __streams

IIIthisProgIinFileIIoutFileIINIdilineeIn
db "> thisProg inFile [outFile] N.dilinee" , 13, 10, 0, 0

IFindIoneIorImoreIerrorIn
db "Find one or more error" , 13, 10, 0, 0

nl db 13, 10, 0, 0

section _BSS use32 public class=BSS
buffer resd 41792

section _TEXT use32 public class=CODE

;[32+20]52ra, 56P1, 60P2
align 4
_main:
pushad
sub esp, 20
mov ecx, dword[esp+ 56]
mov eax, dword[esp+ 60]
mov dword[esp+ 12], 0 ; se c=1 r=a[0] il nome del file
cmp eax, 0
jne .1
..usage: push IIIthisProgIinFileIIoutFileIINIdilineeIn
call _printf
add esp, 4
jmp .z
..e2: push esi
call _fclose
add esp, 4
..e1: cmp dword[esp+ 12], 0
je .error
push ebp
call _fclose
add esp, 4
..error: push IFindIoneIorImoreIerrorIn
call _printf
add esp, 4
jmp .z
..1: cmp ecx, 3
jb .usage
cmp ecx, 4
ja .usage ; only 3 or 4 argument
mov esi, [eax+4]
mov edi, [eax+8]
; __streams point to stdin, 24=sizeof(FILE)
mov ebp, __streams
add ebp, 24 ; k point to stdout
cmp ecx, 4
jne .2
mov edi, [eax+12]
mov ebp, [eax+8]
mov eax, esp
mov dword[esp], "w"
push eax
push ebp
call _fopen
add esp, 8
cmp eax, 0
je .error
mov ebp, eax
mov dword[esp+ 12], 7 ; k point to a oper file handle
..2: push edi
call _atoi
add esp, 4
cmp edi, 10
jle .e1
mov edi, eax
mov eax, esp
mov dword[esp], "r"
push eax
push esi
call _fopen
add esp, 8
cmp eax, 0
je .e1
mov esi, eax
push edi
push esi
push ebp
call RompiLinee
jc .e2
push esi
call _fclose
add esp, 4
cmp eax, 0
jne .e1
cmp dword[esp+ 12], 0
je .z
push ebp
call _fclose
add esp, 4
cmp eax, 0
jne .error
..z:
add esp, 20
popad
xor eax, eax
ret

;32Ra, 36P_fileOut, 40P_fileIn, 44P_linesz + 2048
; 2084 2088 2092
align 4
RompiLinee:
pushad
sub esp, 2048
mov edi, dword[esp+ 2084]
mov esi, dword[esp+ 2088]
mov ebp, dword[esp+ 2092]
mov dword[esp+ 0], ebp
mov dword[esp+ 4], 10 ; ^0 sizeMax
cmp edi, 0
je .e
cmp esi, 0
je .e
cmp ebp, 10
jle .e
cmp ebp, 1010
ja .e
lea ebx, [esp+40]
jmp short .1
..e: mov eax, -1
stc
jmp .z
..1: mov ecx, ebp
sub ecx, 2
call LeggiParola_ibc
mov dword[esp+ 8], eax
mov dword[esp+ 12], edx
mov dword[esp+ 16], ecx
cmp ecx, dword[esp+ 0]
jb .2
cmp dword[esp+ 4], 10
je .10
push edi
push 13
call _fputc
add esp, 8
cmp eax, -1
je .e
push edi
push 10
call _fputc
add esp, 8
cmp eax, -1
je .e
mov dword[esp+ 4], 0
..10: mov dword[esp+ 0], ebp
..2: mov ecx, dword[esp+ 16]
call InserisciFile_jbc
jc .e
mov ecx, dword[esp+ 16]
sub dword[esp+ 0], ecx
mov eax, dword[esp+ 8]
mov edx, dword[esp+ 12]
cmp edx, 0
je .3
cmp edx, 2
jne .23
cmp eax, 10
jne .21
mov dword[esp+ 0], ebp
jmp short .22
..21: sub dword[esp+ 0], 1
..22: mov dword[esp+ 4], eax
push edi
push eax
call _fputc
add esp, 8
cmp eax, -1
je .e
jmp .1
..23: ; caso parola troppo lunga
push edi
push 13
call _fputc
add esp, 8
cmp eax, -1
je .e ; rompe la parola
push edi
push 10
call _fputc
add esp, 8
cmp eax, -1
je .e
mov dword[esp+ 0], ebp
mov eax, dword[esp+ 8]
jmp short .21 ; stampa il carattere letto
..3: xor eax, eax
..z:
lea esp, [esp+2048]
popad
ret 12

;i:FileInHandle b:buffer c:maxleninbuffer
;Ritorna
;in c la lunghezza, in a il carattere spazio che ha fermato
;la lettura [caso r=2]
;oppure nessun carattere EOF o errore [r=0]
;oppure il prossimo carattere se la parola ha + caratteri
;del massimo consentito [r=1]
align 4
LeggiParola_ibc:
push ebx
push edi
push ebp
mov ebp, ecx
..1: push esi
call _fgetc
add esp, 4
mov edi, eax
cmp eax, -1
je .2
push eax
call _isspace
add esp, 4
cmp eax, 0
jne .4
dec ebp
jz .3
mov eax, edi
mov [ebx], al
inc ebx
jmp short .1
..2: mov edx, 0
jmp short .5
..3: mov edx, 1
jmp short .5
..4: mov edx, 2
..5: mov eax, edi
mov ecx, ebx
sub ecx, dword[esp+ 8]
clc
pop ebp
pop edi
pop ebx
ret

;j:FileOutHandle b:buffer c:lenBuffer
align 4
InserisciFile_jbc:
push ebx
push ebp
cmp ecx, 0
jl .e
jz .2
mov ebp, ecx
jmp short .1
..e: mov eax, -1
stc
jmp short .z
..1: xor eax, eax
mov al, [ebx]
push edi
push eax
call _fputc
add esp, 8
cmp eax, -1
je .e
inc ebx
dec ebp
jnz .1
..2: mov eax, ebx
sub eax, dword[esp+ 4]
clc
..z:
pop ebp
pop ebx
ret

----------------------
;Nasmw -fobj thisFile.asm
;bcc32 -v ThisFile.obj

section _DATA use32 public class=DATA

global _main
extern _printf
extern _fputc
extern _fgetc
extern _fclose
extern _fopen
extern _atoi
extern _isspace
extern __streams

"> thisProg inFile [outFile] N.dilinee\n"
db "> thisProg inFile [outFile] N.dilinee",13,10,0,0

"Find one or more error\n"
db "Find one or more error",13,10,0,0

nl db 13, 10, 0, 0

section _BSS use32 public class=BSS
buffer resd 41792

section _TEXT use32 public class=CODE

;[32+20]52ra, 56P1, 60P2
align 4
_main:
pushad
s-=20
c=^56|a=^60|^12=0 ; se c=1 r=a[0] il nome del file
a==0!#.1
..usage: _printf<("> thisProg inFile [outFile] N.dilinee\n")|##.z
..e2: _fclose<(i)
..e1: ^12==0#.error|_fclose<(k)
..error: _printf<("Find one or more error\n")|##.z
..1: c<3#.usage|c>4#.usage ; only 3 or 4 argument
i=*a+4 |j=*a+8
; __streams point to stdin, 24=sizeof(FILE)
k=__streams|k+=24 ; k point to stdout
c==4!#.2|j=*a+12 |k=*a+8
a=s|D*s="w"|_fopen<(k,a)|a==0#.error
k=a|^12=7 ; k point to a oper file handle
..2: _atoi<(j)|j<=10?#.e1|j=a
a=s|D*s="r"|_fopen<(i,a)|a==0#.e1|i=a
RompiLinee(k,i,j)|jc .e2
_fclose<(i)|a#.e1
^12==0#.z |_fclose<(k)|a#.error
..z:
s+=20
popad
a^=a
ret

;32Ra, 36P_fileOut, 40P_fileIn, 44P_linesz + 2048
; 2084 2088 2092
align 4
RompiLinee:
pushad
s-= 2048
j=^2084|i=^2088|k=^2092|^0=k|^4=10 ; ^0 sizeMax
j==0#.e|i==0#.e|k<=10?#.e|k>1010#.e|b=&*s+40|#.1
..e: a=-1|stc|##.z
..1: c=k |c-=2|LeggiParola_ibc()|^8=a|^12=r|^16=c
c>=^0!#.2|^4!=10!#.10|_fputc<(13, j)|a==-1#.e
_fputc<(10, j)|a==-1#.e|^4=0
..10: ^0=k
..2: c=^16|InserisciFile_jbc()|jc .e
c=^16|^0-=c|a=^8|r=^12
r==0#.3
r==2!#.23|a==10!#.21|^0=k|#.22
..21: ^0-=1
..22: ^4=a|_fputc<(a, j)|a==-1#.e
##.1
..23: ; caso parola troppo lunga
_fputc<(13, j)|a==-1#.e ; rompe la parola
_fputc<(10, j)|a==-1#.e
^0=k|a=^8|#.21 ; stampa il carattere letto
..3: a^=a
..z:
s =&*s+2048
popad
ret 12

;i:FileInHandle b:buffer c:maxleninbuffer
;Ritorna
;in c la lunghezza, in a il carattere spazio che ha fermato
;la lettura [caso r=2]
;oppure nessun carattere EOF o errore [r=0]
;oppure il prossimo carattere se la parola ha + caratteri
;del massimo consentito [r=1]
align 4
LeggiParola_ibc:
<b,j,k
k=c
..1: _fgetc<(i)|j=a|a==-1#.2|_isspace<(a)|a#.4
--k!#.3|a=j|*b=al|++b|#.1
..2: r=0|#.5
..3: r=1|#.5
..4: r=2
..5: a=j|c=b|c-=^8|clc
>b,j,k
ret

;j:FileOutHandle b:buffer c:lenBuffer
align 4
InserisciFile_jbc:
<b,k
c<>0|<?#.e|=#.2|k=c|#.1
..e: a=-1|stc|#.z
..1: a^=a|al=*b|_fputc<(a, j)|a==-1#.e|++b|--k#.1
..2: a=b |a-=^4|clc
..z:
>b,k
ret






9 Answers

io_x

7/11/2011 7:00:00 AM

0


"io_x" <a@b.c.invalid> ha scritto nel messaggio
news:4e1a92f9$0$44207$4fafbaef@reader1.news.tin.it...
> [comp.lang.c++,comp.lang.c,comp.programming,alt.lang.asm]
> "eric" <cneric12lin0@gmail.com> ha scritto nel messaggio
> news:5b15b612-b003-4b37-8859-38af722dd4f3@v7g2000prl.googlegroups.com...
> Dear advanced programers:
>
>> In that book's chapter 4 Section 16: Wrapping Lines in a Text File
>>author desribe:
>>Problem
>>You want to "wrap" text at a spicific number of characters in a file.
>>For example, if
>>you want to wrap text at 72 characters, you would insert a new-line
>>character after
>>every 72 characters in the file. If the file contains human-readable
>>text, you probably
>>want to avoid splitting words.
>>Solution
>>Write a function that uses input and output streams to read in
>>characters with
>>istream::get(char), do some bookkeeping, and wirte our characters with
>>ostream::
>>put(char). Example 4-25 shows how to do this for text files that
>>contain human-
>>readable text without splitting words.
>>c++ cookbook 's example source code is here
>>http://examples.oreilly.com/9780...
>
> very interesting problem...
>
> this is my solution in .asm [that splipt if long words> maxSizeLine];
> i tried some time one solution more difficult but
> afther many debugging time no good result;
>
> when i thought to this solution, using sub functions
> all goes well the first time of the run
> don't know why...
> so it could be full of errors and can make seg fault
> your pc if not worse.
>
> I wait for your C or C++ or whatherver other language
> solution: i think if the language not have one function
> like the RompiLinee() below; it is difficult for you
> to write such program.
>

first bug: i found one char(13) more in the end of lines...

----------------

;Nasmw -fobj thisFile.asm
;bcc32 -v ThisFile.obj

section _DATA use32 public class=DATA

global _main
extern _printf
extern _fputc
extern _fgetc
extern _fclose
extern _fopen
extern _atoi
extern _isspace
extern __streams

IIIthisProgIinFileIIoutFileIINIdilineeIn
db "> thisProg inFile [outFile] N.dilinee" , 13, 10, 0, 0

IFindIoneIorImoreIerrorIn
db "Find one or more error" , 13, 10, 0, 0

nl db 13, 10, 0, 0

section _BSS use32 public class=BSS
buffer resd 41792

section _TEXT use32 public class=CODE

;[32+20]52ra, 56P1, 60P2
align 4
_main:
pushad
sub esp, 20
mov ecx, dword[esp+ 56]
mov eax, dword[esp+ 60]
mov dword[esp+ 12], 0 ; se c=1 r=a[0] il nome del file
cmp eax, 0
jne .1
..usage: push IIIthisProgIinFileIIoutFileIINIdilineeIn
call _printf
add esp, 4
jmp .z
..e2: push esi
call _fclose
add esp, 4
..e1: cmp dword[esp+ 12], 0
je .error
push ebp
call _fclose
add esp, 4
..error: push IFindIoneIorImoreIerrorIn
call _printf
add esp, 4
jmp .z
..1: cmp ecx, 3
jb .usage
cmp ecx, 4
ja .usage ; only 3 or 4 argument
mov esi, [eax+4]
mov edi, [eax+8]
; __streams point to stdin, 24=sizeof(FILE)
mov ebp, __streams
add ebp, 24 ; k point to stdout
cmp ecx, 4
jne .2
mov edi, [eax+12]
mov ebp, [eax+8]
mov eax, esp
mov dword[esp], "w"
push eax
push ebp
call _fopen
add esp, 8
cmp eax, 0
je .error
mov ebp, eax
mov dword[esp+ 12], 7 ; k point to a oper file handle
..2: push edi
call _atoi
add esp, 4
cmp edi, 10
jle .e1
mov edi, eax
mov eax, esp
mov dword[esp], "r"
push eax
push esi
call _fopen
add esp, 8
cmp eax, 0
je .e1
mov esi, eax
push edi
push esi
push ebp
call RompiLinee
jc .e2
push esi
call _fclose
add esp, 4
cmp eax, 0
jne .e1
cmp dword[esp+ 12], 0
je .z
push ebp
call _fclose
add esp, 4
cmp eax, 0
jne .error
..z:
add esp, 20
popad
xor eax, eax
ret

;32Ra, 36P_fileOut, 40P_fileIn, 44P_linesz + 2048
; 2084 2088 2092
align 4
RompiLinee:
pushad
sub esp, 2048
mov edi, dword[esp+ 2084]
mov esi, dword[esp+ 2088]
mov ebp, dword[esp+ 2092]
mov dword[esp+ 0], ebp
mov dword[esp+ 4], 10 ; ^0 sizeMax
cmp edi, 0
je .e
cmp esi, 0
je .e
cmp ebp, 10
jle .e
cmp ebp, 1010
ja .e
lea ebx, [esp+40]
jmp short .1
..e: mov eax, -1
stc
jmp .z
..1: mov ecx, ebp
sub ecx, 2
call LeggiParola_ibc
mov dword[esp+ 8], eax
mov dword[esp+ 12], edx
mov dword[esp+ 16], ecx
cmp ecx, dword[esp+ 0]
jb .2
cmp dword[esp+ 4], 10
je .10
push edi
push 10
call _fputc
add esp, 8
cmp eax, -1
je .e
mov dword[esp+ 4], 0
..10: mov dword[esp+ 0], ebp
..2: mov ecx, dword[esp+ 16]
call InserisciFile_jbc
jc .e
mov ecx, dword[esp+ 16]
sub dword[esp+ 0], ecx
mov eax, dword[esp+ 8]
mov edx, dword[esp+ 12]
cmp edx, 0
je .3
cmp edx, 2
jne .23
cmp eax, 10
jne .21
mov dword[esp+ 0], ebp
jmp short .22
..21: sub dword[esp+ 0], 1
..22: mov dword[esp+ 4], eax
push edi
push eax
call _fputc
add esp, 8
cmp eax, -1
je .e
jmp .1
..23: ; caso parola troppo lunga
push edi
push 10
call _fputc
add esp, 8
cmp eax, -1
je .e ; rompe la parola
mov dword[esp+ 0], ebp
mov eax, dword[esp+ 8]
jmp short .21 ; stampa il carattere letto
..3: xor eax, eax
..z:
lea esp, [esp+2048]
popad
ret 12

;i:FileInHandle b:buffer c:maxleninbuffer
;Ritorna
;in c la lunghezza, in a il carattere spazio che ha fermato
;la lettura [caso r=2]
;oppure nessun carattere EOF o errore [r=0]
;oppure il prossimo carattere se la parola ha + caratteri
;del massimo consentito [r=1]
align 4
LeggiParola_ibc:
push ebx
push edi
push ebp
mov ebp, ecx
..1: push esi
call _fgetc
add esp, 4
mov edi, eax
cmp eax, -1
je .2
push eax
call _isspace
add esp, 4
cmp eax, 0
jne .4
dec ebp
jz .3
mov eax, edi
mov [ebx], al
inc ebx
jmp short .1
..2: mov edx, 0
jmp short .5
..3: mov edx, 1
jmp short .5
..4: mov edx, 2
..5: mov eax, edi
mov ecx, ebx
sub ecx, dword[esp+ 8]
clc
pop ebp
pop edi
pop ebx
ret

;j:FileOutHandle b:buffer c:lenBuffer
align 4
InserisciFile_jbc:
push ebx
push ebp
cmp ecx, 0
jl .e
jz .2
mov ebp, ecx
jmp short .1
..e: mov eax, -1
stc
jmp short .z
..1: xor eax, eax
mov al, [ebx]
push edi
push eax
call _fputc
add esp, 8
cmp eax, -1
je .e
inc ebx
dec ebp
jnz .1
..2: mov eax, ebx
sub eax, dword[esp+ 4]
clc
..z:
pop ebp
pop ebx
ret

----------------------
;Nasmw -fobj thisFile.asm
;bcc32 -v ThisFile.obj

section _DATA use32 public class=DATA

global _main
extern _printf
extern _fputc
extern _fgetc
extern _fclose
extern _fopen
extern _atoi
extern _isspace
extern __streams

"> thisProg inFile [outFile] N.dilinee\n"
db "> thisProg inFile [outFile] N.dilinee",13,10,0,0

"Find one or more error\n"
db "Find one or more error",13,10,0,0

nl db 13, 10, 0, 0

section _BSS use32 public class=BSS
buffer resd 41792

section _TEXT use32 public class=CODE

;[32+20]52ra, 56P1, 60P2
align 4
_main:
pushad
s-=20
c=^56|a=^60|^12=0 ; se c=1 r=a[0] il nome del file
a==0!#.1
..usage: _printf<("> thisProg inFile [outFile] N.dilinee\n")|##.z
..e2: _fclose<(i)
..e1: ^12==0#.error|_fclose<(k)
..error: _printf<("Find one or more error\n")|##.z
..1: c<3#.usage|c>4#.usage ; only 3 or 4 argument
i=*a+4 |j=*a+8
; __streams point to stdin, 24=sizeof(FILE)
k=__streams|k+=24 ; k point to stdout
c==4!#.2|j=*a+12 |k=*a+8
a=s|D*s="w"|_fopen<(k,a)|a==0#.error
k=a|^12=7 ; k point to a oper file handle
..2: _atoi<(j)|j<=10?#.e1|j=a
a=s|D*s="r"|_fopen<(i,a)|a==0#.e1|i=a
RompiLinee(k,i,j)|jc .e2
_fclose<(i)|a#.e1
^12==0#.z |_fclose<(k)|a#.error
..z:
s+=20
popad
a^=a
ret

;32Ra, 36P_fileOut, 40P_fileIn, 44P_linesz + 2048
; 2084 2088 2092
align 4
RompiLinee:
pushad
s-= 2048
j=^2084|i=^2088|k=^2092|^0=k|^4=10 ; ^0 sizeMax
j==0#.e|i==0#.e|k<=10?#.e|k>1010#.e|b=&*s+40|#.1
..e: a=-1|stc|##.z
..1: c=k |c-=2|LeggiParola_ibc()|^8=a|^12=r|^16=c
c>=^0!#.2|^4!=10!#.10|_fputc<(10, j)|a==-1#.e|^4=0
..10: ^0=k
..2: c=^16|InserisciFile_jbc()|jc .e
c=^16|^0-=c|a=^8|r=^12
r==0#.3
r==2!#.23|a==10!#.21|^0=k|#.22
..21: ^0-=1
..22: ^4=a|_fputc<(a, j)|a==-1#.e
##.1
..23: ; caso parola troppo lunga
_fputc<(10, j)|a==-1#.e ; rompe la parola
^0=k|a=^8|#.21 ; stampa il carattere letto
..3: a^=a
..z:
s =&*s+2048
popad
ret 12

;i:FileInHandle b:buffer c:maxleninbuffer
;Ritorna
;in c la lunghezza, in a il carattere spazio che ha fermato
;la lettura [caso r=2]
;oppure nessun carattere EOF o errore [r=0]
;oppure il prossimo carattere se la parola ha + caratteri
;del massimo consentito [r=1]
align 4
LeggiParola_ibc:
<b,j,k
k=c
..1: _fgetc<(i)|j=a|a==-1#.2|_isspace<(a)|a#.4
--k!#.3|a=j|*b=al|++b|#.1
..2: r=0|#.5
..3: r=1|#.5
..4: r=2
..5: a=j|c=b|c-=^8|clc
>b,j,k
ret

;j:FileOutHandle b:buffer c:lenBuffer
align 4
InserisciFile_jbc:
<b,k
c<>0|<?#.e|=#.2|k=c|#.1
..e: a=-1|stc|#.z
..1: a^=a|al=*b|_fputc<(a, j)|a==-1#.e|++b|--k#.1
..2: a=b |a-=^4|clc
..z:
>b,k
ret





Kleuskes & Moos

7/11/2011 8:03:00 AM

0

On Jul 11, 9:00 am, "io_x" <a...@b.c.invalid> wrote:
<snip>

What relation (if any) does this have to the stated subject of this
newsgroup?

io_x

7/11/2011 8:15:00 AM

0


"Kleuskes & Moos" <kleuske@xs4all.nl> ha scritto nel messaggio
news:7c5194c6-dd77-403e-bc5d-3990f329eb29@n28g2000vbs.googlegroups.com...
On Jul 11, 9:00 am, "io_x" <a...@b.c.invalid> wrote:
<snip>

>What relation (if any) does this have to the stated subject of this
>newsgroup?

i rewrite it
I wait for your C or C++ or whatherver other language
solution: i think if the language not have one function
like the RompiLinee() below; it is difficult for you
to write such program.


Mark Bluemel

7/11/2011 8:24:00 AM

0

On 07/11/2011 09:02 AM, Kleuskes & Moos wrote:
> On Jul 11, 9:00 am, "io_x"<a...@b.c.invalid> wrote:
> <snip>
>
> What relation (if any) does this have to the stated subject of this
> newsgroup?
>
First question - which newsgroup?

Second question - why bother asking him? He's clearly on a higher plane
of understanding than us. That's why I've got him in my kill file.

James Kuyper

7/11/2011 10:24:00 AM

0

On 07/11/2011 04:02 AM, Kleuskes & Moos wrote:
> On Jul 11, 9:00�am, "io_x" <a...@b.c.invalid> wrote:
> <snip>
>
> What relation (if any) does this have to the stated subject of this
> newsgroup?

Which newsgroup? It's cross-posted to 4.

I didn't see the message you're responding to, but neither relevance nor
coherence are priorities for io_x, so there's not much point in
chastising him about them.
--
James Kuyper

io_x

7/11/2011 10:52:00 AM

0


"James Kuyper" <jameskuyper@verizon.net> ha scritto nel messaggio
news:iveivh$9b4$2@dont-email.me...
> On 07/11/2011 04:02 AM, Kleuskes & Moos wrote:
>> On Jul 11, 9:00?am, "io_x" <a...@b.c.invalid> wrote:
>> <snip>
>>
>> What relation (if any) does this have to the stated subject of this
>> newsgroup?
>
> Which newsgroup? It's cross-posted to 4.
>
> I didn't see the message you're responding to, but neither relevance nor
> coherence are priorities for io_x, so there's not much point in
> chastising him about them.
> --
> James Kuyper

if you not see the message how can judge what it contain?
programming is not one language, it is not one standard
it is about the war of the languages
for write better, one algo


Kleuskes & Moos

7/11/2011 2:42:00 PM

0

On Jul 11, 10:24 am, Mark Bluemel <mark_blue...@pobox.com> wrote:
> On 07/11/2011 09:02 AM, Kleuskes & Moos wrote:> On Jul 11, 9:00 am, "io_x"<a...@b.c.invalid>  wrote:
> > <snip>
>
> > What relation (if any) does this have to the stated subject of this
> > newsgroup?
>
> First question - which newsgroup?

<sigh>
Should have checked the headers first. Sorry. But for an answer the
phrase "all of them" should apply, i guess.

> Second question - why bother asking him? He's clearly on a higher
> plane of understanding than us. That's why I've got him in my
> kill file.

Best place for him, too.

io_x

7/12/2011 7:05:00 AM

0


"io_x" <a@b.c.invalid> ha scritto nel messaggio
news:4e1a9f1a$0$15668$4fafbaef@reader2.news.tin.it...
>> [comp.lang.c++,comp.lang.c,comp.programming,alt.lang.asm]
>> "eric" <cneric12lin0@gmail.com> ha scritto nel messaggio
>> news:5b15b612-b003-4b37-8859-38af722dd4f3@v7g2000prl.googlegroups.com...
>> Dear advanced programers:
>>
>>> In that book's chapter 4 Section 16: Wrapping Lines in a Text File
>>>author desribe:
>>>Problem
>>>You want to "wrap" text at a spicific number of characters in a file.
>>>For example, if
>>>you want to wrap text at 72 characters, you would insert a new-line
>>>character after
>>>every 72 characters in the file. If the file contains human-readable
>>>text, you probably
>>>want to avoid splitting words.
>>>Solution
>>>Write a function that uses input and output streams to read in
>>>characters with
>>>istream::get(char), do some bookkeeping, and wirte our characters with
>>>ostream::
>>>put(char). Example 4-25 shows how to do this for text files that
>>>contain human-
>>>readable text without splitting words.
>>>c++ cookbook 's example source code is here
>>>http://examples.oreilly.com/9780...
>>
>> very interesting problem...
>>
>> this is my solution in .asm [that splipt if long words> maxSizeLine];
>> i tried some time one solution more difficult but
>> afther many debugging time no good result;
>>
>> when i thought to this solution, using sub functions
>> all goes well the first time of the run
>> don't know why...
>> so it could be full of errors and can make seg fault
>> your pc if not worse.
>>
>> I wait for your C or C++ or whatherver other language
>> solution: i think if the language not have one function
>> like the RompiLinee() below; it is difficult for you
>> to write such program.
>>
>
> first bug: i found one char(13) more in the end of lines...

second bug: it seem that even space can generate one \n

some adjustament:
use int as ^0 type for not to think on too much big numbers;
use ferror for the file that can be stdout too, for find error.

In the world out here, there is someone that can run this?
---------------------------------------------------------

;Nasmw -fobj thisFile.asm
;bcc32 -v ThisFile.obj

section _DATA use32 public class=DATA

global _main
extern _printf
extern _fputc
extern _fgetc
extern _fclose
extern _fopen
extern _atoi
extern _ferror
extern _isspace
extern __streams

IIIthisProgIinFileIIoutFileIINIdilineeIn
db "> thisProg inFile [outFile] N.dilinee" , 13, 10, 0, 0

IFindIoneIorImoreIerrorIn
db "Find one or more error" , 13, 10, 0, 0

nl db 13, 10, 0, 0

section _BSS use32 public class=BSS
buffer resd 41792

section _TEXT use32 public class=CODE

;[32+20]52ra, 56P1, 60P2
align 4
_main:
pushad
sub esp, 20
mov ecx, dword[esp+ 56]
mov eax, dword[esp+ 60]
mov dword[esp+ 12], 0 ; se c=1 r=a[0] il nome del file
cmp eax, 0
jne .1
..usage: push IIIthisProgIinFileIIoutFileIINIdilineeIn
call _printf
add esp, 4
jmp .z
..e2: push esi
call _fclose
add esp, 4
..e1: cmp dword[esp+ 12], 0
je .error
push ebp
call _fclose
add esp, 4
..error: push IFindIoneIorImoreIerrorIn
call _printf
add esp, 4
jmp .z
..1: cmp ecx, 3
jb .usage
cmp ecx, 4
ja .usage ; only 3 or 4 argument
mov esi, [eax+4]
mov edi, [eax+8]
; __streams point to stdin, 24=sizeof(FILE)
mov ebp, __streams
add ebp, 24 ; k point to stdout
cmp ecx, 4
jne .2
mov edi, [eax+12]
mov ebp, [eax+8]
mov eax, esp
mov dword[esp], "w"
push eax
push ebp
call _fopen
add esp, 8
cmp eax, 0
je .error
mov ebp, eax
mov dword[esp+ 12], 7 ; k point to a oper file handle
..2: push edi
call _atoi
add esp, 4
cmp edi, 10
jle .e1
mov edi, eax
mov eax, esp
mov dword[esp], "r"
push eax
push esi
call _fopen
add esp, 8
cmp eax, 0
je .e1
mov esi, eax
push edi
push esi
push ebp
call RompiLinee
jc .e2
push esi
call _fclose
add esp, 4
cmp eax, 0
jne .e1
push ebp
call _ferror
add esp, 4
cmp eax, 0
jne .e1
cmp dword[esp+ 12], 0
je .z
push ebp
call _fclose
add esp, 4
cmp eax, 0
jne .error
..z:
add esp, 20
popad
xor eax, eax
ret

;32Ra, 36P_fileOut, 40P_fileIn, 44P_linesz + 2048
; 2084 2088 2092
align 4
RompiLinee:
pushad
sub esp, 2048
mov edi, dword[esp+ 2084]
mov esi, dword[esp+ 2088]
mov ebp, dword[esp+ 2092]
mov dword[esp+ 0], ebp
mov dword[esp+ 4], 10 ; ^0 sizeMax
cmp edi, 0
je .e
cmp esi, 0
je .e
cmp ebp, 10
jle .e
cmp ebp, 1010
ja .e
lea ebx, [esp+40]
jmp short .1
..e: mov eax, -1
stc
jmp .z
..f: jmp .3
..1: mov ecx, ebp
sub ecx, 2
call LeggiParola_ibc
mov dword[esp+ 8], eax
mov dword[esp+ 12], edx
mov dword[esp+ 16], ecx
cmp ecx, dword[esp+ 0]
jl .2
cmp dword[esp+ 4], 10
je .10
push edi
push 10
call _fputc
add esp, 8
cmp eax, -1
je .e
mov dword[esp+ 4], 0
..10: mov dword[esp+ 0], ebp
..2: mov ecx, dword[esp+ 16]
call InserisciFile_jbc
jc .e
mov ecx, dword[esp+ 16]
sub dword[esp+ 0], ecx
mov eax, dword[esp+ 8]
mov edx, dword[esp+ 12]
cmp edx, 0
je .f
cmp edx, 2
jne .23
cmp eax, 10
jne .21
mov dword[esp+ 0], ebp
jmp short .22
..21: sub dword[esp+ 0], 1
jg .22
push edi
push 10
call _fputc
add esp, 8
cmp eax, -1
je .e
mov dword[esp+ 0], ebp
dec dword[esp+ 0]
..22: mov dword[esp+ 4], eax
push edi
push eax
call _fputc
add esp, 8
cmp eax, -1
je .e
jmp .1
..23: ; caso parola troppo lunga
push edi
push 10
call _fputc
add esp, 8
cmp eax, -1
je .e ; rompe la parola
mov dword[esp+ 0], ebp
mov eax, dword[esp+ 8]
jmp short .21 ; stampa il carattere letto
..3: xor eax, eax
..z:
lea esp, [esp+2048]
popad
ret 12

;i:FileInHandle b:buffer c:maxleninbuffer
;Ritorna
;in c la lunghezza, in a il carattere spazio che ha fermato
;la lettura [caso r=2]
;oppure nessun carattere EOF o errore [r=0]
;oppure il prossimo carattere se la parola ha + caratteri
;del massimo consentito [r=1]
align 4
LeggiParola_ibc:
push ebx
push edi
push ebp
mov ebp, ecx
..1: push esi
call _fgetc
add esp, 4
mov edi, eax
cmp eax, -1
je .2
push eax
call _isspace
add esp, 4
cmp eax, 0
jne .4
dec ebp
jz .3
mov eax, edi
mov [ebx], al
inc ebx
jmp short .1
..2: mov edx, 0
jmp short .5
..3: mov edx, 1
jmp short .5
..4: mov edx, 2
..5: mov eax, edi
mov ecx, ebx
sub ecx, dword[esp+ 8]
clc
pop ebp
pop edi
pop ebx
ret

;j:FileOutHandle b:buffer c:lenBuffer
align 4
InserisciFile_jbc:
push ebx
push ebp
cmp ecx, 0
jl .e
jz .2
mov ebp, ecx
jmp short .1
..e: mov eax, -1
stc
jmp short .z
..1: xor eax, eax
mov al, [ebx]
push edi
push eax
call _fputc
add esp, 8
cmp eax, -1
je .e
inc ebx
dec ebp
jnz .1
..2: mov eax, ebx
sub eax, dword[esp+ 4]
clc
..z:
pop ebp
pop ebx
ret
---------------------------------------------------------
;Nasmw -fobj thisFile.asm
;bcc32 -v ThisFile.obj

section _DATA use32 public class=DATA

global _main
extern _printf
extern _fputc
extern _fgetc
extern _fclose
extern _fopen
extern _atoi
extern _ferror
extern _isspace
extern __streams

"> thisProg inFile [outFile] N.dilinee\n"
db "> thisProg inFile [outFile] N.dilinee",13,10,0,0

"Find one or more error\n"
db "Find one or more error",13,10,0,0

nl db 13, 10, 0, 0

section _BSS use32 public class=BSS
buffer resd 41792

section _TEXT use32 public class=CODE

;[32+20]52ra, 56P1, 60P2
align 4
_main:
pushad
s-=20
c=^56|a=^60|^12=0 ; se c=1 r=a[0] il nome del file
a==0!#.1
..usage: _printf<("> thisProg inFile [outFile] N.dilinee\n")|##.z
..e2: _fclose<(i)
..e1: ^12==0#.error|_fclose<(k)
..error: _printf<("Find one or more error\n")|##.z
..1: c<3#.usage|c>4#.usage ; only 3 or 4 argument
i=*a+4 |j=*a+8
; __streams point to stdin, 24=sizeof(FILE)
k=__streams|k+=24 ; k point to stdout
c==4!#.2|j=*a+12 |k=*a+8
a=s|D*s="w"|_fopen<(k,a)|a==0#.error
k=a|^12=7 ; k point to a oper file handle
..2: _atoi<(j)|j<=10?#.e1|j=a
a=s|D*s="r"|_fopen<(i,a)|a==0#.e1|i=a
RompiLinee(k,i,j)|jc .e2
_fclose<(i)|a#.e1
_ferror<(k)|a#.e1
^12==0#.z|_fclose<(k)|a#.error
..z:
s+=20
popad
a^=a
ret

;32Ra, 36P_fileOut, 40P_fileIn, 44P_linesz + 2048
; 2084 2088 2092
align 4
RompiLinee:
pushad
s-= 2048
j=^2084|i=^2088|k=^2092|^0=k|^4=10 ; ^0 sizeMax
j==0#.e|i==0#.e|k<=10?#.e|k>1010#.e|b=&*s+40|#.1
..e: a=-1|stc|##.z
..f: ##.3
..1: c=k |c-=2|LeggiParola_ibc()|^8=a|^12=r|^16=c
c>=^0!?#.2|^4!=10!#.10|_fputc<(10, j)|a==-1#.e|^4=0
..10: ^0=k
..2: c=^16|InserisciFile_jbc()|jc .e
c=^16|^0-=c|a=^8|r=^12
r==0#.f
r==2!#.23|a==10!#.21|^0=k|#.22
..21: ^0-=1|>?#.22|_fputc<(10, j)|a==-1#.e|^0=k|--^0
..22: ^4=a |_fputc<(a, j)|a==-1#.e
##.1
..23: ; caso parola troppo lunga
_fputc<(10, j)|a==-1#.e ; rompe la parola
^0=k|a=^8|#.21 ; stampa il carattere letto
..3: a^=a
..z:
s =&*s+2048
popad
ret 12

;i:FileInHandle b:buffer c:maxleninbuffer
;Ritorna
;in c la lunghezza, in a il carattere spazio che ha fermato
;la lettura [caso r=2]
;oppure nessun carattere EOF o errore [r=0]
;oppure il prossimo carattere se la parola ha + caratteri
;del massimo consentito [r=1]
align 4
LeggiParola_ibc:
<b,j,k
k=c
..1: _fgetc<(i)|j=a|a==-1#.2|_isspace<(a)|a#.4
--k!#.3|a=j|*b=al|++b|#.1
..2: r=0|#.5
..3: r=1|#.5
..4: r=2
..5: a=j|c=b|c-=^8|clc
>b,j,k
ret

;j:FileOutHandle b:buffer c:lenBuffer
align 4
InserisciFile_jbc:
<b,k
c<>0|<?#.e|=#.2|k=c|#.1
..e: a=-1|stc|#.z
..1: a^=a|al=*b|_fputc<(a, j)|a==-1#.e|++b|--k#.1
..2: a=b |a-=^4|clc
..z:
>b,k
ret




io_x

7/12/2011 7:42:00 AM

0


"io_x" <a@b.c.invalid> ha scritto nel messaggio
news:4e1bf1c5$0$15667$4fafbaef@reader2.news.tin.it...
>>> [comp.lang.c++,comp.lang.c,comp.programming,alt.lang.asm]
>>> "eric" <cneric12lin0@gmail.com> ha scritto nel messaggio
>>> news:5b15b612-b003-4b37-8859-38af722dd4f3@v7g2000prl.googlegroups.com...
>>> Dear advanced programers:
>>>
>>>> In that book's chapter 4 Section 16: Wrapping Lines in a Text File
>>>>author desribe:
>>>>Problem
>>>>You want to "wrap" text at a spicific number of characters in a file.
>>>>For example, if
>>>>you want to wrap text at 72 characters, you would insert a new-line
>>>>character after
>>>>every 72 characters in the file. If the file contains human-readable
>>>>text, you probably
>>>>want to avoid splitting words.
>>>>Solution
>>>>Write a function that uses input and output streams to read in
>>>>characters with
>>>>istream::get(char), do some bookkeeping, and wirte our characters with
>>>>ostream::
>>>>put(char). Example 4-25 shows how to do this for text files that
>>>>contain human-
>>>>readable text without splitting words.
>>>>c++ cookbook 's example source code is here
>>>>http://examples.oreilly.com/9780...
>>>
>>> very interesting problem...
>>>
>>> this is my solution in .asm [that splipt if long words> maxSizeLine];
>>> i tried some time one solution more difficult but
>>> afther many debugging time no good result;
>>>
>>> when i thought to this solution, using sub functions
>>> all goes well the first time of the run
>>> don't know why...
>>> so it could be full of errors and can make seg fault
>>> your pc if not worse.
>>>
>>> I wait for your C or C++ or whatherver other language
>>> solution: i think if the language not have one function
>>> like the RompiLinee() below; it is difficult for you
>>> to write such program.
>>>
>>
>> first bug: i found one char(13) more in the end of lines...
>
> second bug: it seem that even space can generate one \n

III bug: i forget to push pop eax
Buona Gironata grazie

> some adjustament:
> use int as ^0 type for not to think on too much big numbers;
> use ferror for the file that can be stdout too, for find error.
>
> In the world out here, there is someone that can run this?

;Nasmw -fobj thisFile.asm
;bcc32 -v ThisFile.obj

section _DATA use32 public class=DATA

global _main
extern _printf
extern _fputc
extern _fgetc
extern _fclose
extern _fopen
extern _atoi
extern _ferror
extern _isspace
extern __streams

IIIthisProgIinFileIIoutFileIINIdilineeIn
db "> thisProg inFile [outFile] N.dilinee" , 13, 10, 0, 0

IFindIoneIorImoreIerrorIn
db "Find one or more error" , 13, 10, 0, 0

nl db 13, 10, 0, 0

section _BSS use32 public class=BSS
buffer resd 41792

section _TEXT use32 public class=CODE

;[32+20]52ra, 56P1, 60P2
align 4
_main:
pushad
sub esp, 20
mov ecx, dword[esp+ 56]
mov eax, dword[esp+ 60]
mov dword[esp+ 12], 0 ; se c=1 r=a[0] il nome del file
cmp eax, 0
jne .1
..usage: push IIIthisProgIinFileIIoutFileIINIdilineeIn
call _printf
add esp, 4
jmp .z
..e2: push esi
call _fclose
add esp, 4
..e1: cmp dword[esp+ 12], 0
je .error
push ebp
call _fclose
add esp, 4
..error: push IFindIoneIorImoreIerrorIn
call _printf
add esp, 4
jmp .z
..1: cmp ecx, 3
jb .usage
cmp ecx, 4
ja .usage ; only 3 or 4 argument
mov esi, [eax+4]
mov edi, [eax+8]
; __streams point to stdin, 24=sizeof(FILE)
mov ebp, __streams
add ebp, 24 ; k point to stdout
cmp ecx, 4
jne .2
mov edi, [eax+12]
mov ebp, [eax+8]
mov eax, esp
mov dword[esp], "w"
push eax
push ebp
call _fopen
add esp, 8
cmp eax, 0
je .error
mov ebp, eax
mov dword[esp+ 12], 7 ; k point to a oper file handle
..2: push edi
call _atoi
add esp, 4
cmp edi, 10
jle .e1
mov edi, eax
mov eax, esp
mov dword[esp], "r"
push eax
push esi
call _fopen
add esp, 8
cmp eax, 0
je .e1
mov esi, eax
push edi
push esi
push ebp
call RompiLinee
jc .e2
push esi
call _fclose
add esp, 4
cmp eax, 0
jne .e1
push ebp
call _ferror
add esp, 4
cmp eax, 0
jne .e1
cmp dword[esp+ 12], 0
je .z
push ebp
call _fclose
add esp, 4
cmp eax, 0
jne .error
..z:
add esp, 20
popad
xor eax, eax
ret

;32Ra, 36P_fileOut, 40P_fileIn, 44P_linesz + 2048
; 2084 2088 2092
align 4
RompiLinee:
pushad
sub esp, 2048
mov edi, dword[esp+ 2084]
mov esi, dword[esp+ 2088]
mov ebp, dword[esp+ 2092]
mov dword[esp+ 0], ebp
mov dword[esp+ 4], 10 ; ^0 sizeMax
cmp edi, 0
je .e
cmp esi, 0
je .e
cmp ebp, 10
jle .e
cmp ebp, 1010
ja .e
lea ebx, [esp+40]
jmp short .1
..e: mov eax, -1
stc
jmp .z
..f: jmp .3
..1: mov ecx, ebp
sub ecx, 2
call LeggiParola_ibc
mov dword[esp+ 8], eax
mov dword[esp+ 12], edx
mov dword[esp+ 16], ecx
cmp ecx, dword[esp+ 0]
jl .2
cmp dword[esp+ 4], 10
je .10
push edi
push 10
call _fputc
add esp, 8
cmp eax, -1
je .e
mov dword[esp+ 4], 0
..10: mov dword[esp+ 0], ebp
..2: mov ecx, dword[esp+ 16]
call InserisciFile_jbc
jc .e
mov ecx, dword[esp+ 16]
sub dword[esp+ 0], ecx
mov eax, dword[esp+ 8]
mov edx, dword[esp+ 12]
cmp edx, 0
je .f
cmp edx, 2
jne .23
cmp eax, 10
jne .21
mov dword[esp+ 0], ebp
jmp short .22
..21: sub dword[esp+ 0], 1
jg .22
push eax
push edi
push 10
call _fputc
add esp, 8
mov edx, eax
pop eax
cmp edx, -1
je .e
mov dword[esp+ 0], ebp
dec dword[esp+ 0]
..22: mov dword[esp+ 4], eax
push edi
push eax
call _fputc
add esp, 8
cmp eax, -1
je .e
jmp .1
..23: ; caso parola troppo lunga
push edi
push 10
call _fputc
add esp, 8
cmp eax, -1
je .e ; rompe la parola
mov dword[esp+ 0], ebp
mov eax, dword[esp+ 8]
jmp short .21 ; stampa il carattere letto
..3: xor eax, eax
..z:
lea esp, [esp+2048]
popad
ret 12

;i:FileInHandle b:buffer c:maxleninbuffer
;Ritorna
;in c la lunghezza, in a il carattere spazio che ha fermato
;la lettura [caso r=2]
;oppure nessun carattere EOF o errore [r=0]
;oppure il prossimo carattere se la parola ha + caratteri
;del massimo consentito [r=1]
align 4
LeggiParola_ibc:
push ebx
push edi
push ebp
mov ebp, ecx
..1: push esi
call _fgetc
add esp, 4
mov edi, eax
cmp eax, -1
je .2
push eax
call _isspace
add esp, 4
cmp eax, 0
jne .4
dec ebp
jz .3
mov eax, edi
mov [ebx], al
inc ebx
jmp short .1
..2: mov edx, 0
jmp short .5
..3: mov edx, 1
jmp short .5
..4: mov edx, 2
..5: mov eax, edi
mov ecx, ebx
sub ecx, dword[esp+ 8]
clc
pop ebp
pop edi
pop ebx
ret

;j:FileOutHandle b:buffer c:lenBuffer
align 4
InserisciFile_jbc:
push ebx
push ebp
cmp ecx, 0
jl .e
jz .2
mov ebp, ecx
jmp short .1
..e: mov eax, -1
stc
jmp short .z
..1: xor eax, eax
mov al, [ebx]
push edi
push eax
call _fputc
add esp, 8
cmp eax, -1
je .e
inc ebx
dec ebp
jnz .1
..2: mov eax, ebx
sub eax, dword[esp+ 4]
clc
..z:
pop ebp
pop ebx
ret


> ;Nasmw -fobj thisFile.asm
> ;bcc32 -v ThisFile.obj
>
> section _DATA use32 public class=DATA
>
> global _main
> extern _printf
> extern _fputc
> extern _fgetc
> extern _fclose
> extern _fopen
> extern _atoi
> extern _ferror
> extern _isspace
> extern __streams
>
> "> thisProg inFile [outFile] N.dilinee\n"
> db "> thisProg inFile [outFile] N.dilinee",13,10,0,0
>
> "Find one or more error\n"
> db "Find one or more error",13,10,0,0
>
> nl db 13, 10, 0, 0
>
> section _BSS use32 public class=BSS
> buffer resd 41792
>
> section _TEXT use32 public class=CODE
>
> ;[32+20]52ra, 56P1, 60P2
> align 4
> _main:
> pushad
> s-=20
> c=^56|a=^60|^12=0 ; se c=1 r=a[0] il nome del file
> a==0!#.1
> .usage: _printf<("> thisProg inFile [outFile] N.dilinee\n")|##.z
> .e2: _fclose<(i)
> .e1: ^12==0#.error|_fclose<(k)
> .error: _printf<("Find one or more error\n")|##.z
> .1: c<3#.usage|c>4#.usage ; only 3 or 4 argument
> i=*a+4 |j=*a+8
> ; __streams point to stdin, 24=sizeof(FILE)
> k=__streams|k+=24 ; k point to stdout
> c==4!#.2|j=*a+12 |k=*a+8
> a=s|D*s="w"|_fopen<(k,a)|a==0#.error
> k=a|^12=7 ; k point to a oper file handle
> .2: _atoi<(j)|j<=10?#.e1|j=a
> a=s|D*s="r"|_fopen<(i,a)|a==0#.e1|i=a
> RompiLinee(k,i,j)|jc .e2
> _fclose<(i)|a#.e1
> _ferror<(k)|a#.e1
> ^12==0#.z|_fclose<(k)|a#.error
> .z:
> s+=20
> popad
> a^=a
> ret
>
> ;32Ra, 36P_fileOut, 40P_fileIn, 44P_linesz + 2048
> ; 2084 2088 2092
> align 4
> RompiLinee:
> pushad
> s-= 2048
> j=^2084|i=^2088|k=^2092|^0=k|^4=10 ; ^0 sizeMax
> j==0#.e|i==0#.e|k<=10?#.e|k>1010#.e|b=&*s+40|#.1
> .e: a=-1|stc|##.z
> .f: ##.3
> .1: c=k |c-=2|LeggiParola_ibc()|^8=a|^12=r|^16=c
> c>=^0!?#.2|^4!=10!#.10|_fputc<(10, j)|a==-1#.e|^4=0
> .10: ^0=k
> .2: c=^16|InserisciFile_jbc()|jc .e
> c=^16|^0-=c|a=^8|r=^12
> r==0#.f
> r==2!#.23|a==10!#.21|^0=k|#.22
> .21: ^0-=1|>?#.22|_fputc<(10, j)|a==-1#.e|^0=k|--^0

^0-=1|>?#.22|<a|_fputc<(10, j)|r=a|>a|r==-1#.e|^0=k|--^0
forget to push pop eax

> .22: ^4=a |_fputc<(a, j)|a==-1#.e
> ##.1
> .23: ; caso parola troppo lunga
> _fputc<(10, j)|a==-1#.e ; rompe la parola
> ^0=k|a=^8|#.21 ; stampa il carattere letto
> .3: a^=a
> .z:
> s =&*s+2048
> popad
> ret 12
>
> ;i:FileInHandle b:buffer c:maxleninbuffer
> ;Ritorna
> ;in c la lunghezza, in a il carattere spazio che ha fermato
> ;la lettura [caso r=2]
> ;oppure nessun carattere EOF o errore [r=0]
> ;oppure il prossimo carattere se la parola ha + caratteri
> ;del massimo consentito [r=1]
> align 4
> LeggiParola_ibc:
> <b,j,k
> k=c
> .1: _fgetc<(i)|j=a|a==-1#.2|_isspace<(a)|a#.4
> --k!#.3|a=j|*b=al|++b|#.1
> .2: r=0|#.5
> .3: r=1|#.5
> .4: r=2
> .5: a=j|c=b|c-=^8|clc
>>b,j,k
> ret
>
> ;j:FileOutHandle b:buffer c:lenBuffer
> align 4
> InserisciFile_jbc:
> <b,k
> c<>0|<?#.e|=#.2|k=c|#.1
> .e: a=-1|stc|#.z
> .1: a^=a|al=*b|_fputc<(a, j)|a==-1#.e|++b|--k#.1
> .2: a=b |a-=^4|clc
> .z:
>>b,k
> ret
>
>
>
>