flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > extra characters on line (missing "or al,al/jz"?)

Author
Thread Post new topic Reply to topic
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 15 Aug 2011, 08:26

I'm not sure, but I think so.

Tomasz ?

Code:
;PREPROCE.INC
;------------
         .....
backslash_character:
           mov     byte[edi],0
         lods    byte[esi]
           cmp     al,20h
              je      concatenate_lines
           cmp     al,09h
              je      concatenate_lines
           cmp     al,1Ah
              je      unexpected_end_of_file
              cmp     al,0Ah
              je      concatenate_lf
              cmp     al,0Dh
              je      concatenate_cr
              or      al,al                   ;<-- +
           jz      concatenate_ok          ;<-- +
           cmp     al,3Bh
              je      find_concatenated_line

          .....

concatenate_lines:
         lods    byte[esi]
           cmp     al,20h
              je      concatenate_lines
           cmp     al,09h
              je      concatenate_lines
           cmp     al,1Ah
              je      unexpected_end_of_file
              cmp     al,0Ah
              je      concatenate_lf
              cmp     al,0Dh
              je      concatenate_cr
              or      al,al                   ;<-- +
           jz      concatenate_ok          ;<-- +
           cmp     al,3Bh
              jne     extra_characters_on_line
            .....
    

_________________
I am not young enough to know everything (Oscar Wilde)- Image


Last edited by ouadji on 23 Aug 2011, 14:47; edited 1 time in total
Post 15 Aug 2011, 08:26
View user's profile Send private message Send e-mail Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 20 Aug 2011, 20:01

Tomasz, your opinion on this ?
thank you in advance.

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 20 Aug 2011, 20:01
View user's profile Send private message Send e-mail Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 20 Aug 2011, 20:02
Maybe you should explain what your patch does?
Post 20 Aug 2011, 20:02
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 20 Aug 2011, 20:29
Code:
;PREPROCE.INC
;------------

control_character:
 cmp     al,1Ah
      je      line_end
    cmp     al,0Dh
      je      cr_character
        cmp     al,0Ah
      je      lf_character
        cmp     al,9
        je      convert_line_data
   or      al,al ;<---------------- al == 0 ?
       jnz     symbol_character
    jmp     line_end ;<------------- if al==0 then "end of line"
   ...

    

if zero means the end of line (like 0x0D and/or 0x0A)

then zero must mean the end of line in all cases.

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 20 Aug 2011, 20:29
View user's profile Send private message Send e-mail Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 20 Aug 2011, 20:44
thanks. stickied.
Post 20 Aug 2011, 20:44
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 23 Aug 2011, 14:43

The fasm compiler assumes that "zéro" means the end of line.
(like 0x0D and/or 0x0A)
Code:
;PREPROCE.INC
;------------

control_character:
        cmp     al,1Ah
        je      line_end
        cmp     al,0Dh
        je      cr_character
        cmp     al,0Ah
        je      lf_character
        cmp     al,9
        je      convert_line_data
        or      al,al ;<---------------- al == 0 ?
        jnz     symbol_character
        jmp     line_end ;<------------- if al==0 then "end of line"
        ... 
    
However, after a backslash, it does not work.
The compiler does not take into accont the "zero" as end of line in all cases.
Here is a simple example (attached file).
Code:
db \ ;<--- eol==0
 1    
Try to compile this file,
the result is: "extra characters on line"
why ?
Because the compiler sometimes sees the "zero" as the end of the line,
and sometimes as the end of the file.

(The solution is in my first post)


Description:
Download
Filename: EOL_zero.ASM
Filesize: 7 Bytes
Downloaded: 432 Time(s)


_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 23 Aug 2011, 14:43
View user's profile Send private message Send e-mail Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1622
Location: Toronto, Canada
AsmGuru62 23 Aug 2011, 16:35
The backslash is a LAST character on line by its definition - and FASM 'knows' it perfectly well. Not a bug IMO.
Post 23 Aug 2011, 16:35
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 23 Aug 2011, 18:21
It should in fact treat 0 byte as EOF, but it's been broken because I did not add appropriate check in the parent loop when once (long time ago) restructuring the code. So it started working as EOL only, and that's why there is this inconsistency.
Post 23 Aug 2011, 18:21
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 23 Aug 2011, 18:47

thank you Tomasz for your reply.

Ok, understood.
Maybe it's time to fix this small inconsistency.
Why not ?

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 23 Aug 2011, 18:47
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.