From: volcano on
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.

Again thanks to everybody to only want to help. I will try suggestions.

From: Herbert Kleebauer on
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
From: volcano on
Thank you Herbert. I didn't mean you. Anyway, i was supposed to learn
new and possibly specific to nasm. Because the tasm version is almost
the same. Only syntax differencies. Especially in circle. Also the
code is not mine. The original coder is in first link and suppose know
this assembler well. But not important from now on. I have a working
one(not nasm). Problem is not to have a dll export list.

In addition, i can not understand from HLA syntax. But again thank you
very much for giving your time for help. Best regards.