Uniform spacing of labels in MASM32



I'm a recently graduated computer engineer who's been messing around
with assembly for more than 2 years now. (Mostly TASM for basic
hardware drivers and inline asm in MS VC++6.0, the source of
manyheadaches).

I've been working on a hobby project involving an interpreter engine
that uses compiled binaries to allow me to script new functionality in
without having to recompile.

The way I thought of doing this was allocating each binary instruction
(16 bits wide) a 64 byte chunk of code to implement what it had to do.
I've done this before writing text blitters for DirectX (yes, I'm a bit
of an oddball), but I thought that using masm32 to compile the function
in assembly would give me greater control than inline assembly in MS
VC++ 6.0 like the way I used to do things.

Here's what I mean - I've got it to work before, but that has been thru
trial and error and the clever placement of NOP's to space each command
implementation apart. I'm thinking there has to be an easier way.

[MASM32 CODE]

mov ebx, offset Instruction
sub ebx, 2 ; Each instruction is two bytes wide (WORD)

LoopStart:
add ebx, 2
xor edx, edx
mov dx, WORD PTR [ebx]
sal edx, 6
add edx, offset ExecStart
jmp edx

ExecStart:
; Instruction 0x0000 code
jmp LoopStart

ExecStart + 40h:
; Instruction 0x0001 code
jmp LoopStart

[END MASM32 CODE]

....and so on. But, as you might have been able to tell, the assembler
goes nuts on the ExecStart+40h line. Here's the error message:

C:\masm32\projects\FeatureEngine\execfeature.asm(154) : error A2008:
syntax error : +

Other syntax errors and elegance issues aside, is there some other way
to space these code blocks apart easily without having to dump NOP's in
between each?

Thanks for taking a look,

Chris Martens

.



Relevant Pages

  • Re: hla set up for the art of assembly
    ... are using it to teach assembly programming, ... Very assembler like: ... Note that HLA allows a form that lets you specify a constant. ... actually support a MUL or IMUL instruction that has a constant operand. ...
    (alt.lang.asm)
  • Re: Loading single word to a xmm register
    ... Certainly not the types of programming that is being done with SSE ... And keep in mind that if your assembler were running on a CPU prior to ... the advent of the SSE instruction set, then your assember ...
    (alt.lang.asm)
  • Re: HLA v1.86 is now available
    ... Which instruction do they know, when they the first time need ... Most students in the lab *would* be capable of loading a constant into ... you ought to learn Intel syntax and drop nonsense like this. ... Why is it important to "learn how to operate the assembler, ...
    (alt.lang.asm)
  • Re: [OT] On `ad hominem - OS X users
    ... This is as relevant as saying "The CPU may not support the ... language of your assembler files".... ... While an assembler language is supposed to be ... assembler instruction you mean and substitute it". ...
    (comp.lang.perl.modules)
  • Re: softwire for basm?
    ... Not necessarilly, but it definetely makes it more easier for humans to code, and it reduces the overall amount of code you'll have to maintain in the library (even when NOT using a preexisting assembler). ... Assembling is relatively mechanical and straightforward once you have understood the modRM / SIB stuff, remember that the first full-blown assemblers did fit in a dozen kB of code (most of it being instruction tables, rather than code), and the parsed output of a block of ASM is directly the assembled ASM. ... ASM registers are a limited ressource, easily injectable code will involve systematic pushing/popping and extra register traffic which can quickly end more costly than the calls. ...
    (borland.public.delphi.language.basm)