Author Topic: Label preceeded symbol %00  (Read 5150 times)

Offline Logman

  • Jr. Member
  • *
  • Posts: 16
  • Country: us
Label preceeded symbol %00
« on: February 08, 2015, 07:13:11 PM »
I have attempted using the %00 symbol in a macro to access the preceeding label. I've read the manual several times and checked for posts on how to correctly implement this directive.

I know I'm missing something simple here. Could someone provide a sample code snippet that shows how to properly define it and invoke it?

Thanks, Logman
« Last Edit: February 08, 2015, 08:10:32 PM by Logman »

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Label preceeded symbol %00
« Reply #1 on: February 09, 2015, 12:12:21 AM »
Something I used to use to convert Masm syntax to Nasm...

Code: [Select]
%macro segment 0
section %00
%endmacro

code segment
nop
data segment
db "foo"


Dunno how useful this is. What are you trying to do, Logman?

Best,
Frank


Offline Logman

  • Jr. Member
  • *
  • Posts: 16
  • Country: us
Re: Label preceeded symbol %00
« Reply #2 on: February 09, 2015, 01:53:44 PM »
I'm writing a manual on how to use inline assembly code in C and BASIC programs for a college course. I am no Kip Irvine or Jeff Duntemann, but have enjoyed teaching beginning programming to students. I think they learn assembly faster by first learning inline assembly where the native high-level language does all the program setup for them. This lets the students mainly focus on the assembly code before they have to get into operating system APIs and so forth.

I was double testing all the code, but couldn't get the %00 directive to work properly. I am simply explaining how all the various macro directives work by providing ample real examples that actually work.

The programs I've chosen use NASM as the underlying assembler. I chose these languages because they use NASM. I have been working with NASM since about 2005 because of its straight-forward syntax.

Thanks for the great assembler by the way, and thank you for taking the time to answer my post.

Logman
« Last Edit: February 09, 2015, 01:56:09 PM by Logman »

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Label preceeded symbol %00
« Reply #3 on: February 09, 2015, 05:44:26 PM »
That's great! What languages let you use Nasm for inline assembly? That's a question that comes up from time to time, and I haven't got an answer to it.

Best,
Frank


Offline Logman

  • Jr. Member
  • *
  • Posts: 16
  • Country: us
Re: Label preceeded symbol %00
« Reply #4 on: February 10, 2015, 05:25:37 AM »
Right now I am using IWBasic from Ionic Wind Software and Code Blocks IDE with MinGW/GNU GCC C/C++ for Windows/Linux. I used to write software for various large government programs, but found most of my clients settling on Windows (98% versus 2% for Linux varieties). Therefore, it makes economical sense for me to spend most of my time developing in the Windows environment. So, although the native assembler used in the Code Blocks/MinGW/GCC environment is GAS, MinGW also utilizes NASM syntax through plugins or switch selection.

What I teach and write about is kind of weird and counter-intuitive because while most colleges focus on C/C++ for their IT students, the majority of my students are science-oriented or hobby programmers. Therefore, I base most of my courses and books on the structured IWBasic programming language. I use IWBasic because it allows inline assembly statements to be placed right in the code and all inline assembly code is passed directly to the underlying NASM assembler. Therefore, all the syntax is NASM, thus my need to get any NASM code I write nailed down with no errors. Since I'm a physicist and program manager by nature and not a programmer by trade, I need to check in now and then to make sure I get all the code right. Nothing breaks your credibility faster than showing incorrect code that doesn't work like it should.

Additionally, I am writing eight volumes on various programming topics that are in the process of being edited, verified, and published over the next year. Volume 6, Compiler Design Technology is a book about how to develop a 64-bit Ada-like language compiler I call Adagé (Ada - Generic Enhancements). The underlying assembler for this compiler is also NASM. All the assembly language syntax is NASM. All the inline assembly statements follow the NASM syntax.

Finally, NASM macros help me reduce the complexity of certain parsing and scanning tasks. All code emitted by the Adagé compiler follows NASM syntax and then is assembled with NASM and linked using GoLink.

Logman
« Last Edit: February 10, 2015, 05:53:32 AM by Logman »