flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > What's wrong with this code?

Author
Thread Post new topic Reply to topic
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
FASM CODE:
Code:
format MS COFF
include '%fasminc%\win32a.inc'
public _crypt
section '.text' code readable executable
proc _crypt, text:DWORD
lea eax,dword[text]
push eax
lop:
xor byte[eax],8
inc eax
cmp byte[eax],0
jnz lop
pop eax
ret
endp
    


C CODE:
Code:
#include <stdio.h>

int main() {
char *text="hello";
crypt(text);
puts(text);
system("Pause>nul");
return 0;
}
    


to build:
fasm crypt.asm
gcc -c prog.c
gcc prog.o crypt.obj -o prog.exe

What I'm trying to do is making a procedure in fasm to call from C to crypt texts. But it seems that I don't know how to get the address or something. Could you check this out for me, please?
Sometimes it gives me memory error and sometimes doesn't, but never works.

Thanks!
Post 14 Sep 2005, 13:22
View user's profile Send private message Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy
use cproc in fasm, or specifiy in c that u're not using the c calling convention...
Post 14 Sep 2005, 16:55
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.