Re: Question about jumps



Evenbit wrote:
Frank Kotler wrote:

Evenbit wrote:

...

; nasm -f elf -l stk2.lst -Xvc -O8 -o stk2.o stk2.asm

Odd combination of switches... Is there a reason you're asking for
VC-style error messages, or is that just carried over from what you use
in Windows?



No, it isn't a hold-over, just a perversion. I can spot the line
numbers just fine using the default reporting. However, the format
seems to be designed for machine-reading (as in an IDE parses it), so I
selected the Xvc form because it 'looks' like it is meant to be human
digestible. ;)

Interesting. Actually the "-Xvc" form was added to be "machine-readable" by Visual Studio. If you like it better, too, that's an unexpected bonus!

The -l is vestigial -- because I am accustomed to having the results of
HLA's hindquarters available if I need to verify that things are being
assembled the way I think they should be.

Many people swear by a listing file. Personally, I'd rather disassemble the thing to see what "really" got assembled. I think some assemblers dump the symbol table with the listing file, which Nasm doesn't do... Might make it more useful...

The -O is left-overs from an
earlier brain-fart. NASM was vomitting at some multiple-parameter
nested macros I had cooked. BURURURURR! Wrong! That was one of the
most nucking futty ideas I've ever dreamed up. [note to self:
pre-processor directives are there for a *reason*, Nathan, *use them*!]
;)

Well, in addition to doing the "optimization", the "-O" switch handles some forward references better... so that just might work in some cases. (there is *no* penalty for using a good big number as a parameter to the "-O" switch. 8 should be enough for *most* files...)

On that note, it occurs to me that if one were to continue to build up
a nice "cut-and-paste" style 'library' of code (as I've suggested in
this thread), they would eventually want to move it to a more
maintainable static library + include file collection. The "asmutils"
package is ripe with resources to that end. Probably would want to
scale it down a good bit to make a "Linux NASM Beginner Kit" package.
But if one's goal is "Any *NIX (including BSD) Standard Library", then
the "asmutils" includes seem to provide that portability. There is no
mention of OS X, so I wonder if anyone has tried to build this package
there?

I'm not aware of any activity on the OS X assembly "scene". It probably exists, and could probably be folded into that package. If "nasm64" ever appears (possible, but it doesn't look too likely), we'll want macros so that "sys_exit 0" will generate:

mov rdi, 0
mov rax, 1 ; maybe just eax?
syscall

instead of:

mov ebx, 0
mov eax, 1
int 80h

They've really thrown us a curve ball with that 64-bit stuff. Porting any "hand written" code to 64-bit is going to mean a major rewrite! Using "sys_..." macros would help.

Best,
Frank
.



Relevant Pages

  • Re: which book to start with...?
    ... mov eax, 4 ... just installed nasm 16 bit and 32 bit bins under dosemu. ... .bss wont accept initialisations while .data will but no garantee for modification at runtime. ... Section .bss is nominally "uninitialized" data, but is in fact cleard to zero. ...
    (alt.lang.asm)
  • Re: The Advantage of Macros
    ... macros (I couldn't figure out how to use his macro library - Nathan ... mov eax, ... locals counter, name ...
    (alt.lang.asm)
  • Re: Why is my nasm program killing itself?
    ... Nasm is like a sewer, Phil - what you get out of it depends on what you put in. ... If you pour source code suitable for a dos .com file into Nasm, you'll get a dos .com file out. ... orig equ $08048000 ... mov byte,49;working once ...
    (alt.lang.asm)
  • Re: newbie questions
    ... MOV AH,4EH; ... instruction operands must be the same size" this error is in line " INT 21H", because it points everything whats after mov dx, offset mask. ... X86 addresses *always* involve a segment register, ... The examples in your book will need some alteration to work with Nasm. ...
    (alt.lang.asm)
  • Re: NASM macros
    ... > mov ebx, %1 ... > sys_write 1, ecx, edx ... I want to wrap the Linux syscalls in macros so as to permit a ...
    (alt.lang.asm)