News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

dup doesn't work with labels

Started by ramguru, June 12, 2009, 12:54:15 PM

Previous topic - Next topic

ramguru

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  ................
...

ToutEnMasm

Hello,
The dup operator must be place between the type of varaible and the value they have
Quote
dq   L_WM_DEFAULT dup (400h)

ramguru

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

dedndave

i might try this
dq 1024 dup(L_WM_DEFAULT)

ramguru

Thanks I gave a try, but it didn't help - same thing :S

jj2007

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)

ramguru

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)

ToutEnMasm

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)



jj2007

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?

ramguru

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 :}

MichaelW

This works as expected with ML 6.14:

msg_table dq L_WM_CREATE, L_WM_DESTROY, 4 dup(L_WM_DEFAULT)
eschew obfuscation

Mark Jones

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
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

donkey

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
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ramguru

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]

MichaelW

#14
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

eschew obfuscation