Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stdlib weird errors wont let me assemble.

Status
Not open for further replies.

leben2

Programmer
Aug 1, 2006
3
GB
I am teaching myself ASM, I operate on Windows XP.

While assembling the second thing I have tried to assemble ( With TASM ) I got these errors and warnings. The ASM has stdlib included, and that seems to be the source of the problems. Maybe the stdlib package that I downloaded isn't right for my system/needs - maybe it's a problem with my programming - maybe it's I used the wrong arguments to pass into TASM32.exe - maybe it's something else.

Here is the output from TASM:
Code:
prompt>TASM32 /iC:\downloads\ASM\stdlib\INCLUDE
Turbo Assembler  Version 5.0  Copyright (c) 1988, 1996 Borland International

Assembling file:   exe-id.ASM
*Warning* C:\downloads\ASM\stdlib\LIB\stdlib.lib(3) ADDSTR(3) Pass-dependent construction encountered: SL_ADDSTR
**Error** C:\downloads\ASM\stdlib\LIB\stdlib.lib(3) SLCALL(1) Code or data emission to undeclared segment
**Error** C:\downloads\ASM\stdlib\LIB\stdlib.lib(3) SLCALL(2) Code or data emission to undeclared segment
**Error** C:\downloads\ASM\stdlib\LIB\stdlib.lib(6) Unknown character
**Error** C:\downloads\ASM\stdlib\LIB\stdlib.lib(7) Unknown character
**Error** C:\downloads\ASM\stdlib\LIB\stdlib.lib(10) Unknown character
**Error** C:\downloads\ASM\stdlib\LIB\stdlib.lib(11) Unknown character
*Warning* C:\downloads\ASM\stdlib\LIB\stdlib.lib(14) APPEND(3) Pass-dependent construction encountered: SL_APPEND
**Error** C:\downloads\ASM\stdlib\LIB\stdlib.lib(14) SLCALL(1) Code or data emission to undeclared segment
**Error** C:\downloads\ASM\stdlib\LIB\stdlib.lib(14) SLCALL(2) Code or data emission to undeclared segment
**Error** C:\downloads\ASM\stdlib\LIB\stdlib.lib(15) Unknown character
**Error** C:\downloads\ASM\stdlib\LIB\stdlib.lib(16) Unknown character
**Error** C:\downloads\ASM\stdlib\LIB\stdlib.lib(18) Unknown character
**Error** C:\downloads\ASM\stdlib\LIB\stdlib.lib(19) Unknown character
**Fatal** C:\downloads\ASM\stdlib\LIB\stdlib.lib(20) Line too long
Error messages:    13
Warning messages:  2
Passes:            1

Here is the source code:
Code:
.386
.model flat
.stack
	include	stdlib.a
	include	C:\downloads\ASM\stdlib2\stdlib.lib
.data
Arg	word	0
Findx	db	0
badFMsg	db	"Bad file name or other problem. Ending program.",0
notMSG	db	"The file is not an executable.",0
isMSG	db	"The file is an executable.",0
.code

ReadF	proc
	cmp	ax, 0		; seek.
	je	ReadF1
	mov	ax, 42h
	mov	al, 0
	mov	bx, FHndl
	pop	cx
	pop	dx
	int	21h
	
ReadF1:
	pop	Findx
ReadF2:
	mov	ah, 3Fh		; read a byte of file.
	mov	bx, FHndl
	mov	cx, 1
	mov	dx, FBuf
	int	21h
	jc	Wrong
	cmp	ax, cx
	jne	Wrong
	mov	si, offset FBuf
        add	si, 1
	cmp	[si], Findx
	jne	ReadF2

	sub	[si], Findx
	add	[si], 1
	push	si
	ret

main	proc
	meminit
	mov	ax, 1		; get arg.
	argc
	jcxz	Wrong
	
	mov	ah, 3Dh		; open file.
	mov	dx, di
	mov	al, 0
	int	21h
	jc	Wrong
				; read the MX signiture.
	push 	2		; bytes to read.
	push	0		; first byte of seek.
	puch	0		; second byte of seek.
	call	ReadF
	pop	si		; check to see if the MX signature is valid.
	cmp	si, 4Dh
	add	si, 1
	cmp	[si], 58h
	xor	si, si
	
	push	2		; get the offset of the PE header(e_lfanew).
	push	60
	push	0
	call	ReadF
	
	push	2		; read the PE header signature.
	pop	si
	push	[si]
	add	si, 1
	push	[si]
	xor	si, si
	call	ReadF
	pop	si		; check to see if PE header signature is vaild.
	cmp	[si], 50
	jne	Not
	add	si, 1
	cmp	[si], 45
	jne	Not
	jmp	Is
	
Not:
	mov	ah, 09
	lea	dx, notMsg
	int	21h
	jmp	End

Is:
	mov	ah, 09
	lea	dx, isMsg
	int	21h
	jmp	End	
	
Wrong:
	mov	ah, 09
	lea	dx, badFMsg
	int	21h
	jmp	end

FHndl	db	2 dup (?)
FBuf	db	2 dup (?)
End:
main	endp
end main

The purpose of the program is to Identify PE executables by reading their PE signatures - just an exercise I did to prove to myself I could read from files. The stdlib is only used for the argc stuff.
If there's something fantastically obvious not that I showed you that please point it out. Otherwise the problem will be much deeper. If you've don't know the problem please could you point me in the direction of a stdlib package that i can download that is suitable for me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top