[fpc-pascal] getlastoserror giving wrong value?

Marc Santhoff M.Santhoff at t-online.de
Sat Dec 22 15:20:26 CET 2007


Hi,

I'm really stuck here, meanwhile I made the testing program look exactly
the same in structure like the code sequence in question, forced both to
use AnsiStrings and stared at the assembler code - to no avail, because
I do not understand enough x86 asm. ;)

The string variable is holding the same directory name and path in both
cases, of course. For the code look into my previous mail, please.

Can someone comment on these snippets:

<original>
# [457] fpaccess((*ExpandFileName*) tmp , R_OK);
	movl	$4,%ebx
	movl	-192(%ebp),%eax
	call	FPC_ANSISTR_INCR_REF
	leal	-520(%ebp),%eax
	call	FPC_ANSISTR_DECR_REF
	movl	-192(%ebp),%eax
	movl	%eax,-520(%ebp)
	movl	%ebx,%edx
	movl	-520(%ebp),%eax
	testl	%eax,%eax
	jne	.L583
	movl	$FPC_EMPTYCHAR,%eax
.L583:
	call	FPC_SYSC_ACCESS
# [458] n := getlastoserror;
	call	SYSUTILS_GETLASTOSERROR$$LONGINT
	movl	%eax,-120(%ebp)
# [459] writeln(n);
	call	fpc_get_output
</original>

<test>
# [11] res := fpaccess(tmp, R_OK);
	movl	$4,%ebx
	movl	U_P$STAT_TMP,%eax
	call	FPC_ANSISTR_INCR_REF
	leal	-44(%ebp),%eax
	call	FPC_ANSISTR_DECR_REF
	movl	U_P$STAT_TMP,%eax
	movl	%eax,-44(%ebp)
	movl	%ebx,%edx
	movl	-44(%ebp),%eax
	testl	%eax,%eax
	jne	.L24
	movl	$FPC_EMPTYCHAR,%eax
.L24:
	call	FPC_SYSC_ACCESS
	movw	%ax,U_P$STAT_RES
# [13] res := getlastoserror;
	call	SYSUTILS_GETLASTOSERROR$$LONGINT
	movw	%ax,U_P$STAT_RES
# [14] writeln(res);
</test>

For me the look structurally identical, but some differences like the
$XXX-variables(?) don't.

Marc





More information about the fpc-pascal mailing list