Newbie question about NASM 
Author Message
 Newbie question about NASM

I am a newbie of NASM. the following piece of code is my problem.
NASM will always give me an error message on the "org" directive, MASM
won't have this problem.
How to solve it ?

 segment  .bss
buffer1 resb 100       ;a storage buffer  used by 1st procedure
 org buffer1                ; NASM give error message on this line
buffer2 resb 500       ; a storage buffer used by 2nd procedure , but

                                      ; should share same memory with
                                      ; buffer1 to save memory usage .




Wed, 07 Aug 2002 03:00:00 GMT  
 Newbie question about NASM

Quote:

> I am a newbie of NASM. the following piece of code is my problem.
> NASM will always give me an error message on the "org" directive, MASM
> won't have this problem.
> How to solve it ?

>  segment  .bss
> buffer1 resb 100       ;a storage buffer  used by 1st procedure
>  org buffer1                ; NASM give error message on this line
> buffer2 resb 500       ; a storage buffer used by 2nd procedure , but
>                                       ; should share same memory with
>                                       ; buffer1 to save memory usage .

Nasm allows one - and only one - "org" (origin) statement. You could do:

segment .bss
    buffer1
    buffer2 resb 500     ; make it big enough for largest one!

Or you could call it "temp_buffer" in both procedures. This might make
it clearer (for future modifications) that "buffer1" gets clobbered by
"procedure 2", and vice-versa. Re-using the memory isn't any problem,
but I'd be afraid that calling it different names each time might lead
to confusion...

Best,
Frank



Wed, 07 Aug 2002 03:00:00 GMT  
 Newbie question about NASM

Quote:

> I am a newbie of NASM. the following piece of code is my problem.
> NASM will always give me an error message on the "org" directive, MASM
> won't have this problem.
> How to solve it ?

>  segment  .bss
> buffer1 resb 100       ;a storage buffer  used by 1st procedure
>  org buffer1                ; NASM give error message on this line
> buffer2 resb 500       ; a storage buffer used by 2nd procedure , but

>                                       ; should share same memory with
>                                       ; buffer1 to save memory usage .

  "ORG" has a different meaning in NASM than in MASM.  There
is no way in NASM to do what ORG does in MASM.

  In this case there is no reason to.

  segment .bss
buffer1         ;buffer1 is the first 100 bytes of buffer2
buffer2 resb 500

  NASM has no need to know the length of buffer1.  If you want
your code to show the length of buffer1, you do that with a
comment as I did above.

  If you want two labels on the same address, you just put
two labels on the same address.  There is no need to use
ORG.

[emailed and posted]
--
http://www.erols.com/johnfine/
http://www.geocities.com/SiliconValley/Peaks/8600/



Wed, 07 Aug 2002 03:00:00 GMT  
 Newbie question about NASM
AFAIK NASM supports *only one* "ORG" directive. Check your source. There
might be another one in the code segment, I think.

Good Luck.
Alexei A. Frounze

Quote:

> I am a newbie of NASM. the following piece of code is my problem.
> NASM will always give me an error message on the "org" directive, MASM
> won't have this problem.
> How to solve it ?

>  segment  .bss
> buffer1 resb 100       ;a storage buffer  used by 1st procedure
>  org buffer1                ; NASM give error message on this line
> buffer2 resb 500       ; a storage buffer used by 2nd procedure , but

>                                       ; should share same memory with
>                                       ; buffer1 to save memory usage .





Wed, 07 Aug 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. NASM help for newbie on NASM

2. Serious Newbie Nasm question.

3. Serious Newbie Nasm question.

4. Serious Newbie Nasm question.

5. Newbie questions. Hello world with Nasm

6. Newbie question about segments and NASM...

7. Half-newbie NASM question

8. Newbie: CD-Player + Nasm question

9. NASM and nasm.sl for JED editor mode question

10. Newbie Question (Was: Newbie Question...)

11. Newbie-dll's and NASM

12. Newbie - Help Linker Error/Warning (NASM + ld)

 

 
Powered by phpBB® Forum Software