Hello,
I cannot accomplish one simple task, can anyone help?
; I have the following block of data that should appear at least 15 times in data section
win_st \
dd 00010000h,00010000h,0
dd 00020000h,00020000h,0
dd 00100000h,00100000h,0
dd 00200000h,00200000h,0
dd 00800000h,00800000h,0
dd 02000000h,02000000h,0
dd 04000000h,04000000h,0
dd 08000000h,08000000h,0
dd 10000000h,10000000h,0
dd 40000000h,40000000h,0
.data
UDS_DW \
dd 00000001h,00000001h,0
dd 00000002h,00000002h,0
dd 00000004h,00000004h,0
dd 00000008h,00000008h,0
dd 00000010h,00000010h,0
dd 00000020h,00000020h,0
dd 00000040h,00000040h,0
dd 00000080h,00000080h,0
dd 00000100h,00000100h,0
win_st ; instead of writing ten lines of dd statements I want one reference
ACS_DW \
dd 00000001h,00000001h,0
dd 00000002h,00000002h,0
dd 00000004h,00000004h,0
dd 00000008h,00000008h,0
win_st
; and so on
I tried to put win_st in macro statement, but it didn't work, I tried to put win_st block in STRUCT statement, but compiler claimed that it doesn't allow initialized data, I tried to put win_st block in .cont section (win_st equ...), it compiled OK, but it didn't work as expected... :(
One quick way would be to use a macro-
win_st macro
dd 00010000h,00010000h,0
dd 00020000h,00020000h,0
dd 00100000h,00100000h,0
dd 00200000h,00200000h,0
dd 00800000h,00800000h,0
dd 02000000h,02000000h,0
dd 04000000h,04000000h,0
dd 08000000h,08000000h,0
dd 10000000h,10000000h,0
dd 40000000h,40000000h,0
endm
Yes, indeed it works :U thanks
Initially I thought that macro may not work in other than code section (and defined macro same way as struct, so it didn't work then)
ramguru,
If you don't have to change the values in the .DATA section, why not have only 1 copy and simply change the addresses so they all point to the same data ?
I agree hutch your suggestion sounds logic, but it would make everything ten times harder, maybe impossible. I access values by index:
mov esi, ptr_to_one_of_block
mov ecx, index_of_one_value_in_block
lea ecx, [ecx*2+ecx]
mov eax, DWORD PTR [esi+ecx*4]
Now if I had separate block1 & block2
I had to check if index is not out of block1 bounds (and I actually have no idea about bounds, the number of values in block is unknown), if yes load block2...
What's wrong with this way?
.data
Align 4
BlockHead Struct
dd 00010000h,00010000h,0
dd 00020000h,00020000h,0
dd 00100000h,00100000h,0
dd 00200000h,00200000h,0
dd 00800000h,00800000h,0
dd 02000000h,02000000h,0
dd 04000000h,04000000h,0
dd 08000000h,08000000h,0
dd 10000000h,10000000h,0
dd 40000000h,40000000h,0
BlockHead Ends
win_st BlockHead<>
ACS_DW BlockHead<>
Microsoft (R) Macro Assembler Version 6.14.8444 05/15/07 16:19:36
C:\Masm32\Basic\Basic.asm Page 1 - 1
00000340 00010000 win_st BlockHead<>
00010000
00000000
00020000
00020000
00000000
00100000
00100000
00000000
00200000
00200000
00000000
00800000
00800000
00000000
02000000
02000000
00000000
04000000
04000000
00000000
08000000
08000000
00000000
10000000
10000000
00000000
40000000
40000000
00000000
Regards, P1 :8)
Nothing wrong, except that compiler gives an error message:
warning: No support for: 'init expression'. :boohoo: :8)
Note: Added listing to previous post.
So I don't understand the assembler error your getting.
You are assembling with what version?
Regards, P1 :8)
Block.asm demo concept.
; #########################################################################
; Name v1.0.0.0 by P1, Pone@ecad.org
; A MASM32 program to description.
; #########################################################################
.386
.model flat, stdcall
option casemap :none ; case sensitive
; #########################################################################
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
; #########################################################################
.data
Align 4
BlockHead Struct
dd 00010000h,00010000h,0
dd 00020000h,00020000h,0
dd 00100000h,00100000h,0
dd 00200000h,00200000h,0
dd 00800000h,00800000h,0
dd 02000000h,02000000h,0
dd 04000000h,04000000h,0
dd 08000000h,08000000h,0
dd 10000000h,10000000h,0
dd 40000000h,40000000h,0
BlockHead Ends
win_st BlockHead<>
ACS_DW BlockHead<>
; #########################################################################
.data?
Align 4
; #########################################################################
.code
Align 4
start:
invoke GetModuleHandle, NULL
The_End:
invoke ExitProcess,NULL
; #########################################################################
end start
I checked more than twice :U
Same error message, I'm assembling with poasm 1.00.35