Re: [fpc-pascal] Interface with NASM

2010-09-16 Thread Felipe Monteiro de Carvalho
Strange, I took a look and no idea why it doesn't work with the linked .o file =) Maybe disassembling what nasm produces could show something, but I don't know which GNU tool could be used for that... The following program works for me: program driver; uses asmio; {$ASMMODE att} procedure

Re: [fpc-pascal] Interface with NASM

2010-09-16 Thread Jonas Maebe
On 14 Sep 2010, at 08:35, leledumbo wrote: segment .text global tes tes: push ebp mov ebp,esp push 65 Check that this puts a 32 bit value on the stack rather than an 8 bit or 16 bit one. You may need push dword 65 or something like that. Jonas

Re: [fpc-pascal] Interface with NASM

2010-09-16 Thread Felipe Monteiro de Carvalho
On Thu, Sep 16, 2010 at 11:44 AM, Jonas Maebe jonas.ma...@elis.ugent.be wrote: Check that this puts a 32 bit value on the stack rather than an 8 bit or 16 bit one. You may need push dword 65 or something like that. I can add that my gdb said that the stack was missaligned, so this has a high

Re: [fpc-pascal] Interface with NASM

2010-09-16 Thread Jeppe Johansen
Pushes/pops on x86/x86_64 are always word sized Den 16-09-2010 11:44, Jonas Maebe skrev: On 14 Sep 2010, at 08:35, leledumbo wrote: segment .text global tes tes: push ebp mov ebp,esp push 65 Check that this puts a 32 bit value on the stack rather than an 8 bit or 16 bit one. You may

Re: [fpc-pascal] Interface with NASM

2010-09-16 Thread Jonas Maebe
On 16 Sep 2010, at 13:26, Jeppe Johansen wrote: Pushes/pops on x86/x86_64 are always word sized push/pop can at least also be 16 bit in 32 bit mode (or 32 bit in 16 bit mode). Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org

Re: [fpc-pascal] Interface with NASM

2010-09-16 Thread Jonas Maebe
On 14 Sep 2010, at 08:35, leledumbo wrote: build command: nasm -f coff test.asm fpc asmio.pas fpc -o test driver.pas As you can see, I didn't use any optimizations because AFAIR FPC would change parameter passing mechanism when a certain optimizations are performed. That's not the case. The

Re: [fpc-pascal] Interface with NASM

2010-09-16 Thread Felipe Monteiro de Carvalho
On Thu, Sep 16, 2010 at 3:19 PM, Jonas Maebe jonas.ma...@elis.ugent.be wrote: It works fine under linux (if you replace the -f coff with -f elf). For me it doesn't work in Mac OS X using -f macho -- Felipe Monteiro de Carvalho ___ fpc-pascal maillist

Re: [fpc-pascal] Interface with NASM

2010-09-16 Thread Jonas Maebe
On 16 Sep 2010, at 15:22, Felipe Monteiro de Carvalho wrote: On Thu, Sep 16, 2010 at 3:19 PM, Jonas Maebe jonas.ma...@elis.ugent.be wrote: It works fine under linux (if you replace the -f coff with -f elf). For me it doesn't work in Mac OS X using -f macho That is normal, Mac OS X/i386

Re: [fpc-pascal] Interface with NASM

2010-09-15 Thread Felipe Monteiro de Carvalho
I changed it to a very similar program, but one which can be built with a single instruction: program driver; uses asmio; {$ASMMODE Intel} procedure tes; assembler; [alias:'tes']; asm push ebp mov ebp,esp mov EAX,65 push EAX call printc leave ret end; begin tes; end. It crashes

[fpc-pascal] Interface with NASM

2010-09-14 Thread leledumbo
I need to teach assembler, and the easiest way would be to create a driver and simple I/O library in high level language that can be called from assembler so that students can focus in programming with assembler more than dealing with system specific features. It's been quite a while since I go

Re: [fpc-pascal] Interface with NASM

2010-09-14 Thread Matthias K.
Hi, I've played around with your code and didn't get usefull results either at first glance. Instead of putting the printc test into driver, I've wrote a pure pascal unit which does the same as your test.asm, compiled it, disassembled it and modfied the nasm program. That worked. I'm on a