Unscoped re-usable labels and #defines (Macros)

Started by Citric, May 12, 2005, 11:38:31 PM

Previous topic - Next topic

Citric

Hi All, Again

If I have two #defines(Macros) with a Unscoped re-usable label L1: in the first and a jump to the Unscoped re-usable label L1 in the second, the assembler complains

Quote
There was a backward short jump to nowhere:-
jnz <L1

But if i modify the code to have one #define(Macro) i am able to jump to L1, but this i cannot use.

I dont normally use #define(macros) as for me they dont make the code more readable to effective.

Attached is a text program, with both cases.

[attachment deleted by admin]

MichaelW

Hi Citric,

This demonstrates one method of doing what I think you are trying to do with the label. The variable names should be unusual enough that no sane programmer would be likely to duplicate them.

; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
; test0.asm
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

DATA SECTION
    _test_address_  dd 0
    _test_counter_  dd 0
CODE SECTION

;--------------------------------------

#define labeltest1() = \
    mov   D[_test_counter_],4 \
  L1: \
    mov   D[_test_address_],addr L1

;--------------------------------------

#define labeltest2() = \
    dec   D[_test_counter_] \
    jz    >  \
    jmp   D[_test_address_] \
  :

;--------------------------------------

; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
Start:
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««   

    labeltest1()   
      invoke _cprintf,"%c%s",10,"looping"
      add   esp,12
    labeltest2()

    labeltest1()   
      invoke _cprintf,"%c%s",10,"looping again"
      add   esp,12
    labeltest2()

    invoke _cprintf,"%c%s",10,"press any key to exit..."
    add   esp,12
  :
    call  _kbhit
    or    eax,eax
    je    <
    ret

; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««


GoAsm /l test0.asm
pause
GoLink /console test0.obj kernel32.dll msvcrt.dll
pause

eschew obfuscation

Citric

Cheers Michael

That was my last piece of the puzzle i should have it finished real soon!!!