The MASM Forum Archive 2004 to 2012

Project Support Forums => GoAsm Assembler and Tools => Topic started by: ramguru on June 12, 2009, 12:54:15 PM

Title: dup doesn't work with labels
Post by: ramguru on June 12, 2009, 12:54:15 PM
I'm making a jump table. The problem is that "dq 400h dup L_WM_DEFAULT" will initialize just one item :(

DATA
; jmp table START
ALIGN 8
msg_table   dq L_WM_CREATE, L_WM_DESTROY, L_WM_DEFAULT, L_WM_SIZE
    dq 400h dup L_WM_DEFAULT

; jmp table END
..
WinProc FRAME hWin, uMsg, wParam, lParam

and    rdx, 03ffh ; rdx -> uMsg

mov    rcx, [msg_table+rdx*8]

jmp    rcx
L_WM_CREATE:
; some code
jmp >>.done
L_WM_DESTROY:
; some code
jmp >>.done
L_WM_DEFAULT:
invoke DefWindowProc, [hWin], [uMsg], [wParam], [lParam]
ret
.done
xor    rax, rax
ret
ENDF


DATA section dump:

data:0000000010002000  0E 12 00 10 00 00 00 00  13 12 00 10 00 00 00 00  ................
data:0000000010002010  DC 12 00 10 00 00 00 00  39 12 00 10 00 00 00 00  ........9.......
data:0000000010002020  DC 12 00 10 00 00 00 00  00 00 00 00 00 00 00 00  ................
data:0000000010002030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
data:0000000010002040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
...
Title: Re: dup doesn't work with labels
Post by: ToutEnMasm on June 12, 2009, 02:58:58 PM
Hello,
The dup operator must be place between the type of varaible and the value they have
Quote
dq   L_WM_DEFAULT dup (400h)
Title: Re: dup doesn't work with labels
Post by: ramguru on June 12, 2009, 03:18:12 PM
Quote from: ToutEnMasm on June 12, 2009, 02:58:58 PM
Hello,
The dup operator must be place between the type of varaible and the value they have
Quote
dq   L_WM_DEFAULT dup (400h)

Now let's see:

TYPE        VALUE                    COUNT
dq      L_WM_DEFAULT    dup (400h)

You really make no sense  :wink
Title: Re: dup doesn't work with labels
Post by: dedndave on June 12, 2009, 03:24:19 PM
i might try this
dq 1024 dup(L_WM_DEFAULT)
Title: Re: dup doesn't work with labels
Post by: ramguru on June 12, 2009, 03:31:22 PM
Thanks I gave a try, but it didn't help - same thing :S
Title: Re: dup doesn't work with labels
Post by: jj2007 on June 12, 2009, 03:46:11 PM
Quote from: dedndave on June 12, 2009, 03:24:19 PM
i might try this
dq 1024 dup(L_WM_DEFAULT)

Is it a size issue? Try one of these:

dd 2*1024 dup(L_WM_DEFAULT)
dd 2*1024 dup(0, L_WM_DEFAULT)
dd 2*1024 dup(L_WM_DEFAULT, 0)
Title: Re: dup doesn't work with labels
Post by: ramguru on June 12, 2009, 04:00:34 PM
Bad news: none of those methods did solve the problem.. also expression like "..dup (x,y)" won't compile, instead "..dup x,y" will do
edit > but wait "..dup x,y" means something else (damn)
Title: Re: dup doesn't work with labels
Post by: ToutEnMasm on June 12, 2009, 04:11:50 PM
Quote
Now let's see:

TYPE        VALUE                    COUNT
dq      L_WM_DEFAULT    dup (400h)

You really make no sense 

Perhaps could you verify what others say to you
This one works perfectly
Quote
number equ 145
.data
chose dq number dup (0ffh)


Title: Re: dup doesn't work with labels
Post by: jj2007 on June 12, 2009, 04:58:28 PM
Quote from: ramguru on June 12, 2009, 12:54:15 PM
I'm making a jump table. The problem is that "dq 400h dup L_WM_DEFAULT" will initialize just one item :(

Is that a GoAsm only problem, or does it fail also in Masm?
Title: Re: dup doesn't work with labels
Post by: ramguru on June 12, 2009, 05:15:41 PM
I suspect it's only goasm related. Since only goasm has full 64bit support & user is not required to mess with stack using it.
Though haven't tested on masm.
Now I'm using immediate value, will wait until this prob gets fixed :}
Title: Re: dup doesn't work with labels
Post by: MichaelW on June 12, 2009, 05:20:42 PM
This works as expected with ML 6.14:

msg_table dq L_WM_CREATE, L_WM_DESTROY, 4 dup(L_WM_DEFAULT)
Title: Re: dup doesn't work with labels
Post by: Mark Jones on June 13, 2009, 02:31:14 AM
If there are any problems, Jeremy is always willing to work with us. That is one of GoAsm's greatest features, IMO.

Also, did we check the documentation for "dup"?
http://www.jorgon.freeserve.co.uk/GoasmHelp/GoAsm.htm#dup
Title: Re: dup doesn't work with labels
Post by: donkey on June 13, 2009, 08:59:41 PM
This seems to work fine for me...

somelabel DB 256 DUP IOCPARM_MASK

Line 149: ### DbgDump 64 bytes (00403029 to 00403068)
00403029:  7F 7F 7F 7F-7F 7F 7F 7F-7F 7F 7F 7F-7F 7F 7F 7F   
00403039:  7F 7F 7F 7F-7F 7F 7F 7F-7F 7F 7F 7F-7F 7F 7F 7F   
00403049:  7F 7F 7F 7F-7F 7F 7F 7F-7F 7F 7F 7F-7F 7F 7F 7F   
00403059:  7F 7F 7F 7F-7F 7F 7F 7F-7F 7F 7F 7F-7F 7F 7F 7F   


As does..

somelabel DB MAX_PATH DUP IOCPARM_MASK

And ...

somelabel CHAR MAX_PATH DUP IOCPARM_MASK

The proper syntax is

LABEL TYPE COUNT DUP VALUE

I am using GoAsm version 0.56.6a
Title: Re: dup doesn't work with labels
Post by: ramguru on June 13, 2009, 09:55:57 PM
Quote from: donkey on June 13, 2009, 08:59:41 PM
This seems to work fine for me...
...
I am using GoAsm version 0.56.6a
Well, that proves only one thing - your "label" is obviously different from mine (I'm using 0.56.6b)
I'm sick of ppl indirectly suggesting me to RTFM, so made an example with my particular case, it's even 32bit :}
Just compile it see for your self, if app runs fine that would mean the problem is related with OS I'm using which is Windows 7 x64 7201 build.


[attachment deleted by admin]
Title: Re: dup doesn't work with labels
Post by: MichaelW on June 14, 2009, 01:08:00 AM
Using GoAsm 0.56.03a I have not been able to find any syntax that will allow DUP to duplicate a label address. DUP does work as expected with a constant.

Edit: Same for 0.56.6b, and using OFFSET in place of ADDR makes no difference.


DATA SECTION
    lbl1 dd junk1, junk2, 4 dup junk3
    ;lbl2 dd ADDR junk1, ADDR junk2, 4 dup ADDR junk3
    ;lbl2 dd ADDR junk1, ADDR junk2, 4 DUP ADDR junk3
    ;lbl2 dd ADDR junk1, ADDR junk2, 4 DUP (ADDR junk3)
    ;lbl2 dd junk1, junk2, 4 DUP (ADDR junk3)
    ;lbl2 dd junk1, junk2, 4 DUP (junk3)
    lbl2 dd junk1, junk2, 4 DUP 12345678h

CODE SECTION

junk1:
nop
nop
nop
nop
junk2:
nop
nop
nop
nop
junk3:

START:

    invoke printf, "%xh%c", ADDR junk1, 10
    add esp, 12
    invoke printf, "%xh%c", ADDR junk2, 10
    add esp, 12
    invoke printf, "%xh%c%c", ADDR junk3, 10, 10
    add esp, 16

    lea esi, lbl1
    mov ebx, 6
  :
    invoke printf, "%xh%c", [esi], 10
    add esp, 12
    add esi, 4
    dec ebx
    jnz <

    lea esi, lbl2
    mov ebx, 6
  :
    invoke printf, "%xh%c", [esi], 10
    add esp, 12
    add esi, 4
    dec ebx
    jnz <

RET


401000h
401004h
401008h

401000h
401004h
401008h
0h
0h
0h
401000h
401004h
12345678h
12345678h
12345678h
12345678h

Title: Re: dup doesn't work with labels
Post by: Yuri on June 17, 2009, 09:12:37 AM
I seem to have found a workaround for this problem:

ProcAddr STRUCT
DD 0
ENDS


DATA SECTION

Table ProcAddr 400h DUP <Start>


CODE SECTION

Start:
xor eax,eax
ret

Title: Re: dup doesn't work with labels
Post by: ramguru on June 17, 2009, 10:28:07 AM
WOW! that worked  :clap: thanks  :U