Re: Slow nasm



volcano wrote:

First let me thank you for everybody. But i see a high tension here.
Thanks dont need this. Somebody is highly emotional about nasm or
knowledge.

Wasn't meant as an offence. Your post just happened at the wrong time.

After reading

But I used HLA to learn assembly.

HLA is a perfect tool for learning how to program in Assembly Language.

and then your statement

The code is working OK for small DLLs but if bigger, application is
freezing. Is (code generated by) nasm so slow

I got the feeling, that again somebody was trapped by HLA. An assembler does
nothing but translate a symbolic representation of a machine instruction
into the binary value of the machine code. So the speed of the executable
generated by the assembler can't depend on the used assembler but _ONLY_
on the source code feed to the assembler. An assembler doesn't do _ANY_
optimization which you didn't ask for (even if Frank calls it stupid when
NASM generates the long form for "add eax,4" it still is the only correct
way for an assembler to do it).

Here a simple NASM program which prints all exported functions of a DLL.
It's a long time since I read the PE specification so I hope there is
no bug (the program does no error checking). I only tested it with
kernel32.dll and user32.dll:

usage: dumpexp < dllfile.dll


; nasm -f bin -O99 -o dumpexp.com dumpexp.asm

%include "mac.inc" ; ftp://137.193.64.130/pub/assembler/xlinux.zip
org $100


bsr.l getw
cmp.w $5a4d,r0 ; "MZ"
bne.l error

move.l $3c,r0
bsr.l fseek
bsr.l getl ; WinHeader
move.l r0,r1
bsr.l fseek
bsr.l getl
cmp.l $00004550,r0 ; "PE"
bne.l error

lea.l [$74+r1],r0
bsr.l fseek
bsr.l getl
move.l r0,r5 ; NumberOfRvaAndSize

bsr.l getl
move.l r0,r2 ; Export Directory

lea.l [$78+8-80+r1+r5*8],r1
_10: lea.l [80+r1],r1 ; next entry in Image Section Header
move.l r1,r0
bsr.l fseek
bsr.l getl
move.l r0,r4 ; size of section
bsr.l getl
move.l r0,r6 ; base of section
cmp.l r0,r2
blo.b _10
add.l r0,r4 ; end of section
cmp.l r4,r2
bhi.b _10

bsr.l getl ; size of raw data
bsr.l getl ; pointer to raw data
sub.l r6,r0
move.l r0,r6 ; virt->phys

lea.l [24+r2+r6],r0
bsr.l fseek
bsr.l getl ; number of names
move.l r0,r2 ; number of names to display
bsr.l getl ; skip num. of entries in Exportt Address Table
bsr.l getl ; RVA pointer to pointer table

lea.l [r6+r0],r0
move.l r0,r4 ; file pointer to pointer table

_50: move.l r4,r0
addq.l 4,r4
bsr.l fseek
bsr.l getl ; RVA pointer to string
lea.l [r6+r0],r0 ; file pointer to string
bsr.l fseek

_30: bsr.l getc
or.b r0,r0
beq.b _40
bsr.l putc
br.b _30
_40: move.b 13,r0
bsr.l putc
move.b 10,r0
bsr.l putc

dbf.l r2,_50

error: bsr.l exit ; terminate



getl: bsr.l getw
move.l r0,-[sp]
bsr.l getw
rol.l 16,r0
or.l r0,[r7]
move.l [sp]+,r0
rts.l

getw: bsr.l getc
move.l r0,-[sp]
bsr.l getc
rol.w 8,r0
or.l r0,[r7]
move.l [sp]+,r0
rts.l



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; OS specific functions: getc, putc, exit, fseek ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; seek stdin to [r0]
fseek: movem.l r0-r7,-[sp]
move.w r0,r1
lsr.l 16,r0
move.w r0,r2
eor.w r3,r3
move.w $4200,r0
trap $21
movem.l [sp]+,r0-r7
rts.l

; write r0.b to stdout
putc: movem.l r0-r7,-[sp]
move.b r0,[.buf]
move.b $40,m0
move.w .buf,r1
move.w 1,r2
move.w 1,r3
trap $21
movem.l [sp]+,r0-r7
rts.l
..buf: dc.b 0

; read byte from stdin -> r0.l
; -1: EOF
getc: movem.l r0-r7,-[sp]
move.b $3f,m0
move.w .buf,r1
move.w 1,r2
eor.w r3,r3
trap $21
bcs.b .10
cmp.w r0,r2
bne.b .10
movem.l [sp]+,r0-r7
move.l [.buf],r0
rts.l
..10: movem.l [sp]+,r0-r7
move.l -1,r0
rts.l
..buf: dc.l 0

; terminate program
; r0: retorn code
exit: move.b $4c,m0
trap $21
.



Relevant Pages

  • Re: Video Mode 13h in windows XP ... impossible?
    ... there is NO problem using mode 13h under XP...if you write a DOS ... terminates so does the "DOS box" and you return to the Windows desktop ... A dedicated assembler (most of which are completely free and available ... NASM, this is _certainty_ that it's okay for you to do so...the people ...
    (alt.lang.asm)
  • Re: Why there are so many assemblers.
    ... But *clearly* the discussion of the creation of NASM predated ... >> reasonable facsimile to the Intel assembler. ... that was in mid-1996), MASM was still a commercial product, TASM was a ... I have a problem with Rene Tournois calling it an "Intel Syntax" ...
    (alt.lang.asm)
  • Re: My pick for the 04 election - None of the above
    ... that would be re-usable for each GPL Assembler. ... NASM, and as RosAsm has _years_ of advance on any other ... GPL Asm Encoder for LuxAsm and for RosAsm, ...
    (alt.lang.asm)
  • Re: Note to "The Wannabee" on religion
    ... > speed and readability, i have choosen readability. ... idea), the latest version of Nasm has been downloaded almost 53,000 ... > of the older NASM users are also switching to FASM. ... > replacing a GPL Assembler, ...
    (alt.lang.asm)
  • Re: The Lib debate
    ... without further support from the assembler. ... nasm is released under an open source-compatible license. ... has enough macro facilities to allow source-portability among OSes. ... and plenty of external libraries. ...
    (alt.lang.asm)