flat assembler
Message board for the users of flat assembler.

Index > Windows > error: value out of range.

Author
Thread Post new topic Reply to topic
jiangfasm



Joined: 08 Mar 2015
Posts: 58
jiangfasm
D:\msys64\home\jack\fasm\source\ide\fasmw\fasmw.asm

;fasmw.asm

include 'encoding/utf8.inc' ; add utf8
include 'win32wx.inc' ;win32ax.inc -> win32wx.inc

---------------------------
jack@JACK-PC MINGW64 ~/fasm/source/ide/fasmw
$ fasm fasmw.asm
flat assembler version 1.71.48 (1048576 kilobytes memory)
fasmw.asm [3481]:
menuitem '&Redo' _ 'Ctrl+Shift+Z',IDM_REDO
D:\msys64\home\jack\fasm\include/macro/resource.inc [161] menuitem [2]:
du string,0
D:\msys64\home\jack\fasm\include/encoding/utf8.inc [72] du [67]:
dw arg
error: value out of range.


why? who is tall me?
Post 25 Nov 2015, 11:02
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17267
Location: In your JS exploiting you and your system
revolution
Are you trying to make fasmw a Unicode application? Or a UTF8 application? Or something else?
Post 25 Nov 2015, 14:09
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17267
Location: In your JS exploiting you and your system
revolution
The problem can be reduced to this:
Code:
include 'encoding/utf8.inc'
du <'abc',0>    
The UTF8 encoder fails to recognise the input as a string.
Post 25 Nov 2015, 14:21
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7718
Location: Kraków, Poland
Tomasz Grysztar
revolution wrote:
The problem can be reduced to this:
Code:
include 'encoding/utf8.inc'
du <'abc',0>    
The UTF8 encoder fails to recognise the input as a string.
This is a bit different problem. The above is not a valid syntax for DU directive and since the "du" macro from encoding package just re-defines the directive, it does not need to handle any syntax that the original directive could not. However in this case there is this definition:
Code:
 _ equ ,09h,    
that causes problems, because the original DU handles the following code correctly, while "du" macro does not:
Code:
du '&Redo' _ 'Ctrl+Shift+Z'    
This is because symbolic constant gets replaced too late for the macro processor to notice that there are commas. Probably the only solution would be to create additional "du" wrapper containing "match" to force evaluation of symbolic constant before proceeding to split the parameters.
Post 25 Nov 2015, 15:09
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
Tomasz Grysztar
Quote:
Probably the only solution would be to create additional "du" wrapper containing "match" to force evaluation of symbolic constant before proceeding to split the parameters.

I don't see any reason, why you process the arguments in a forward block. common or even the ampersand feature seems like the most suitable solution.

P.S. Sorry, disregard the comment. I just took a short look at the macro without putting any understanding into the problem.

_________________
Faith is a superposition of knowledge and fallacy
Post 25 Nov 2015, 15:21
View user's profile Send private message Reply with quote
jiangfasm



Joined: 08 Mar 2015
Posts: 58
jiangfasm
I finally found the reason.
'&Redo' _ 'Ctrl+Shift+Z' -> By Du macros as not a string.

You must write 2 characters, put dw.

'&Redo' _ 'Ctrl+Shift+Z' -> '&R' _ 'Ct'
Can compile.
Post 27 Nov 2015, 04:15
View user's profile Send private message Visit poster's website Reply with quote
jiangfasm



Joined: 08 Mar 2015
Posts: 58
jiangfasm
Quote:
_ equ ,09h,

menu main_menu
menuitem '&File',0,MFR_POPUP
menuitem '&New' _ 'Ctrl+N',IDM_NEW
menuitem '&Open...' _ 'Ctrl+O',IDM_OPEN
menuitem '&Save' _ 'Ctrl+S',IDM_SAVE
menuitem 'Save &as...',IDM_SAVEAS
menuseparator
menuitem 'E&xit' _ 'Alt+X',IDM_EXIT,MFR_END
menuitem '&Edit',0,MFR_POPUP
menuitem '&Undo' _ 'Ctrl+Z',IDM_UNDO
menuitem '&Redo' _ 'Ctrl+Shift+Z',IDM_REDO
menuseparator


Why the preceding code without warning?
Post 27 Nov 2015, 05:10
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17267
Location: In your JS exploiting you and your system
revolution
jiangfasm wrote:
I finally found the reason.
'&Redo' _ 'Ctrl+Shift+Z' -> By Du macros as not a string.

You must write 2 characters, put dw.

'&Redo' _ 'Ctrl+Shift+Z' -> '&R' _ 'Ct'
Can compile.
But that is not the reason. See above for the discussion.
Post 27 Nov 2015, 06:18
View user's profile Send private message Visit poster's website Reply with quote
jiangfasm



Joined: 08 Mar 2015
Posts: 58
jiangfasm
Code:
macro du [arg]
 { local current,..input,char
   virtual at 0
    ..input::
    du arg
    count = $
   end virtual
   current = 0
   while current < count
    load char byte from ..input:current+1
    if char = 0
     load char byte from ..input:current
     wide = char
     current = current + 1*2
     if char > 0C0h
      if char < 0E0h
       wide = char and 11111b
       load char byte from ..input:current
       wide = wide shl 6 + (char and 111111b)
       current = current + 1*2
      else if char < 0F0h
       wide = char and 1111b
       load char byte from ..input:current
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+1*2
       wide = wide shl 6 + (char and 111111b)
       current = current + 2*2
      else if char < 0F8h
       wide = char and 111b
       load char byte from ..input:current
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+1*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+2*2
       wide = wide shl 6 + (char and 111111b)
       current = current + 3*2
      else if char < 0FCh
       wide = char and 11b
       load char byte from ..input:current
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+1*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+2*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+3*2
       wide = wide shl 6 + (char and 111111b)
       current = current + 4*2
      else
       wide = char and 1
       load char byte from ..input:current
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+1*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+2*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+3*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+4*2
       wide = wide shl 6 + (char and 111111b)
       current = current + 5*2
      end if
     end if
    else
     wide = char shl 8
     load char byte from ..input:current
     wide = wide + char
     current = current + 1*2
    end if
    if wide < 10000h
     dw wide
    else
     dw 0D7C0h + wide shr 10,0DC00h or (wide and 3FFh)
    end if
   end while }
    

Final method!!

Edit by revolution: Used code tags
Post 28 Dec 2015, 04:51
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 595
Roman
jiangfasm how use you macro ?
Show example.
Post 28 Dec 2015, 14:58
View user's profile Send private message Reply with quote
jiangfasm



Joined: 08 Mar 2015
Posts: 58
jiangfasm
Sorry Roman, macro I feel a little bug, let me think about it!
Post 31 Dec 2015, 14:44
View user's profile Send private message Visit poster's website Reply with quote
jiangfasm



Joined: 08 Mar 2015
Posts: 58
jiangfasm
newest modification

Code:
macro du [arg]
 { local current,..input,char
   virtual at 0
    ..input::
    du arg
    count = $
   end virtual
   current = 0
   while current < count
    load char byte from ..input:current+1
    if char = 0
     load char byte from ..input:current
     wide = char
     current = current + 1*2
     if char > 0C0h
      if char < 0E0h
       wide = char and 11111b
       load char byte from ..input:current
       wide = wide shl 6 + (char and 111111b)
       current = current + 1*2
      else if char < 0F0h
       wide = char and 1111b
       load char byte from ..input:current
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+1*2
       wide = wide shl 6 + (char and 111111b)
       current = current + 2*2
      else if char < 0F8h
       wide = char and 111b
       load char byte from ..input:current
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+1*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+2*2
       wide = wide shl 6 + (char and 111111b)
       current = current + 3*2
      else if char < 0FCh
       wide = char and 11b
       load char byte from ..input:current
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+1*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+2*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+3*2
       wide = wide shl 6 + (char and 111111b)
       current = current + 4*2
      else
       wide = char and 1
       load char byte from ..input:current
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+1*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+2*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+3*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+4*2
       wide = wide shl 6 + (char and 111111b)
       current = current + 5*2
      end if
     end if
     if wide < 10000h
      dw wide
     else
      dw 0D7C0h + wide shr 10,0DC00h or (wide and 3FFh)
     end if
    else
     wide = char shl 16
     load char byte from ..input:current
     wide = wide + char
     current = current + 1*2
     dd wide
    end if
   end while }
    


example
Quote:

include 'encoding\utf8.inc'

_ equ ,09h,
;'pass' _ 'test' ---- The old version will be as (not string together)
du 'pass' _ 'test',0 ; 'pass' _ 'test' -> 'pass' ,09h, 'test'

;The old version can't compile 2014h
du 'pass',2014h,'test',0 ;2014h -> 14h,20h


Quote:

$ fasm hello.asm
flat assembler version 1.71.49 (1048576 kilobytes memory)
1 passes, 42 bytes.
Post 31 Dec 2015, 15:18
View user's profile Send private message Visit poster's website Reply with quote
jiangfasm



Joined: 08 Mar 2015
Posts: 58
jiangfasm
jiangfasm wrote:
Code:
macro du [arg]
 { local current,..input,char
   virtual at 0
    ..input::
    du arg
    count = $
   end virtual
   current = 0
   while current < count
    load char byte from ..input:current+1
    if char = 0
     load char byte from ..input:current
     wide = char
     current = current + 1*2
     if char > 0C0h
      if char < 0E0h
       wide = char and 11111b
       load char byte from ..input:current
       wide = wide shl 6 + (char and 111111b)
       current = current + 1*2
      else if char < 0F0h
       wide = char and 1111b
       load char byte from ..input:current
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+1*2
       wide = wide shl 6 + (char and 111111b)
       current = current + 2*2
      else if char < 0F8h
       wide = char and 111b
       load char byte from ..input:current
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+1*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+2*2
       wide = wide shl 6 + (char and 111111b)
       current = current + 3*2
      else if char < 0FCh
       wide = char and 11b
       load char byte from ..input:current
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+1*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+2*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+3*2
       wide = wide shl 6 + (char and 111111b)
       current = current + 4*2
      else
       wide = char and 1
       load char byte from ..input:current
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+1*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+2*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+3*2
       wide = wide shl 6 + (char and 111111b)
       load char byte from ..input:current+4*2
       wide = wide shl 6 + (char and 111111b)
       current = current + 5*2
      end if
     end if
    else
     wide = char shl 8
     load char byte from ..input:current
     wide = wide + char
     current = current + 1*2
    end if
    if wide < 10000h
     dw wide
    else
     dw 0D7C0h + wide shr 10,0DC00h or (wide and 3FFh)
    end if
   end while }
    

Final method!!

Edit by revolution: Used code tags


I'm sure this is correct.
Post 01 Jan 2016, 04:05
View user's profile Send private message Visit poster's website 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-2020, Tomasz Grysztar.

Powered by rwasa.