The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: MazeGen on April 19, 2007, 03:07:27 PM

Title: Code in data section assembly problem
Post by: MazeGen on April 19, 2007, 03:07:27 PM
It seems that MASM supports sort of code in data section. I can't get working direct jumps and labels however.

Standard way doesn't work at all:
.686
.MODEL FLAT, STDCALL

.DATA
mov eax, ebx
datalabel1:
jmp datalabel2
ja datalabel1
datalabel2:

.CODE
Start:
mov eax, ebx
END Start


Jumps return "cannot have implicit far jump or call to near label", Labels return "error A2108: use of register assumed to ERROR"

If I try to change label declaration to "datalabel LABEL NEAR", I get the same errors.

I've tried also "datalabel LABEL DWORD", but it doesn't work too since MASM tries to compile indirect jumps in this case (jmp [datalabel]).

Tested with ML 6.14.8444 and 8.00.50727.42
Title: Re: Code in data section assembly problem
Post by: japheth on April 19, 2007, 03:58:49 PM

Hi,

    "assume cs:_DATA" after ".DATA" seems to help.
Title: Re: Code in data section assembly problem
Post by: MazeGen on April 19, 2007, 04:09:29 PM
It works well! Thanks, japheth.
Title: Re: Code in data section assembly problem
Post by: asmfan on April 20, 2007, 07:41:54 PM
Bad code anyway - DEP won't allow it. I experienced one problem with one media player which rejected to run - finally i turned DEP off and it ran wery well. I think they fixed it finally.
Title: Re: Code in data section assembly problem
Post by: MazeGen on April 23, 2007, 07:42:33 AM
I don't want to execute that code directly - that's why I put it to the data section (at run-time, that code are real data).