Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly x86 > Re: NASM %defin...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 4 Topic 4640 of 4728
Post > Topic >>

Re: NASM %define %ifdef %include - Converting C to NASM

by s_dubrovich <spamtrap@[EMAIL PROTECTED] > May 3, 2008 at 08:50 PM

On May 3, 2:01 pm, Frank Kotler  <spamt...@[EMAIL PROTECTED]
> wrote:
> Jim Carlock wrote:
>
> ...
>
> > In the end, I seek to include ONLY ONE file, by using
> > the %include directive more than once.
>
> ???
>
> ...
>
> > I don't see a %exit directive nor a %jump directive.
>
> I don't know, Jim. Seems to me you're trying to treat included material
> as a "program", when it's essentially an "automated cut and paste".
> Define "WHAT_I_WANT", %ifdef WHAT_I_WANT, %endif... and the rest of it
> won't be included - nothing to %jump over, nothing to %exit. Even easier
> is to *not* combine everything into one file, and %include the ones you
> need... perhaps "collecting" them:
>
> %include "thisprogram.inc"
> ...
> ; the program
> ;----------
>
> ; thisprogram.inc:
> %include "stdio.inc"
> %include "sockets.inc"
> ...
>
> But you should be able to do it like:
>
> %include "everything.inc"
> %define NEED_STDIO
> %define NEED_SOCKETS
> ...
>
> I've seen Windows include files that work like that. I didn't understand
> what the point was then, either :) (actually, the point was to speed up
> Nasm!)
>
> You can specify "-d", "-p" and "-I" options on the command line, or as
> an environment variable, to control what gets included, if that helps.
>
> I don't see the need for "execution"-type directives... but maybe I
> don't understand what you're trying to do...
>
> Best,
> Frank

I'm confused to, as to what Jim is after, exactly.  Also, I wasn't
sure if nasm sup****ted nested include's but it does.  Perhaps the
following will do it, or give further ideas:
btw, nasm also sup****ts nested %IF's as well...

;; myinc.nsm test includes
;; -f bin -l myinc.lst -o myinc.bin myinc.nsm

;;----Conditional Equates----
TRUE	equ	1
FALSE	equ	TRUE-TRUE  ;;conditionals test for Z,NZ

CS1 equ TRUE ;; desired state flags
CS2 equ TRUE
CS3 equ TRUE

%include "CS.INC"

;; the rest

;; =- EOF=-

;; CS.INC
;; CS Include more files

%IF CS1
  %INCLUDE "CS1.H"
%ENDIF

%IF CS2
  %INCLUDE "CS2.H"
%ENDIF

%IF CS1
  %INCLUDE "CS3.H"
%ENDIF

;; -= eof =-

;; CS1.h

db 'this is CS1'

;; -= eof =-

;; CS2.H

db 'this is CS2'

;; -= eof =-

;; CS3.H

db 'this is CS3'

;; -= eof =-

= = = = =

     1                                  ;; myinc.nsm test includes
     2                                  ;; -f bin -l myinc.lst -o
myinc.bin myinc.nsm
     3
     4                                  ;;----Conditional Equates----
     5                                  TRUE	equ	1
     6                                  FALSE	equ	TRUE-
TRUE  ;;conditionals test for Z,NZ
     7
     8                                  CS1 equ TRUE ;; desired state
flags
     9                                  CS2 equ TRUE
    10                                  CS3 equ TRUE
    11
    12                                  %include "CS.INC"
    13                              <1> ;; CS Include more files
    14                              <1>
    15                              <1> %IF CS1
    16                              <1>   %INCLUDE "CS1.H"
    17                              <2> ;; CS1.h
    18                              <2>
    19 00000000 746869732069732043- <2> db 'this is CS1'
    20 00000009 5331                <2>
    21                              <1> %ENDIF
    22                              <1>
    23                              <1> %IF CS2
    24                              <1>   %INCLUDE "CS2.H"
    25                              <2> ;; CS2.H
    26                              <2>
    27 0000000B 746869732069732043- <2> db 'this is CS2'
    28 00000014 5332                <2>
    29                              <2>
    30                              <1> %ENDIF
    31                              <1>
    32                              <1> %IF CS1
    33                              <1>   %INCLUDE "CS3.H"
    34                              <2> ;; CS3.H
    35                              <2>
    36 00000016 746869732069732043- <2> db 'this is CS3'
    37 0000001F 5333                <2>
    38                              <2>
    39                              <1> %ENDIF
    40                              <1>
    41                              <1> ;; -= eof =-
    42
    43                                  ;; the rest
    44
    45                                  ;; =- EOF=-

hth,
Steve
 




 4 Posts in Topic:
NASM %define %ifdef %include - Converting C to NASM
"Jim Carlock"   2008-05-01 10:26:53 
Re: NASM %define %ifdef %include - Converting C to NASM
Henry <spamtrap@[EMAI  2008-05-01 18:13:06 
Re: NASM %define %ifdef %include - Converting C to NASM
Frank Kotler <spamtra  2008-05-03 19:01:36 
Re: NASM %define %ifdef %include - Converting C to NASM
s_dubrovich <spamtrap@  2008-05-03 20:50:56 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 0:29:24 CDT 2008.