I was browsing the net to find a code to cope contents of one file to another and ended up here...

i will be highly grateful,if you can provide me the code and also give some infn. where i can find more codes which will be helpful for me to understand..
Posted on 2006-04-16 14:13:29 by MoonBear
Hi Moonbear,

You will need to know about a few APIs...


For the actual coding I will leave that up to you, you can check the tutorials to find out how to code it in assembly.
Posted on 2006-04-16 14:33:56 by donkey
i just need to know simple coding for simple files,,,,not about api's,,in code like


#include <asm/unistd.h>
#include <syscall.h>
#define STDOUT 1
  .ascii "hello world\n"
.globl _start
  movl $(SYS_write),%eax
    // SYS_write = 4
movl $(STDOUT),%ebx   
      // fd
  movl $hello,%ecx     
      // buf
  movl $(helloend-hello),%edx 
      // count
  int    $0x80

  movl $(SYS_exit),%eax
  xorl    %ebx,%ebx
  int    $0x80
Posted on 2006-04-16 14:43:06 by MoonBear
You will have to use the Windows API regardless of what you want to do. This is the easiest way...


invoke CopyFile, pszOldFile, pszNewFile, TRUE
Posted on 2006-04-16 14:47:57 by donkey
but i want to do it without window api..
Posted on 2006-04-16 14:49:17 by MoonBear

but i want to do it without window api..

Then go ahead...
Posted on 2006-04-16 14:50:17 by donkey
like i want to implement it like this way


opening a file
reading the first line of the file
reading and writing it
applying a loop until it is finished
close it..

but i don't know how to implement it on the basis of coding like above coz this is the only program i have been told..
Posted on 2006-04-16 14:52:38 by MoonBear
You have the idea, you only need know the functions...
i just need to know simple coding for simple files,,,,not about api's,,in code like

  int    $0x80

That is the api of the Linux kernel, you communicate via the interface at interruption $0x80 ;)... you will use an API regardless of the system that are you running..., even you can use the C wrapper functions for access the system calls, you see one API over another API (application programming interface);).

http://www.lxhp.in-berlin.de/lhpsyscal.html and **By Topic** check, open, read, write.

http://www.die.net/doc/linux/man/man2/syscalls.2.html and there your read syscall wrapped in a C call http://www.die.net/doc/linux/man/man2/write.2.html
perhaps http://www.die.net/doc/linux/man/man2/mmap.2.html fi you are in Linux note that the man pages are also accesible in Konqueror, type in the navigation bar man:read

Posted on 2006-04-16 15:45:18 by rea
Whats with this? I have seen this question asked millions
of times over the years.

Do you think there should be a area made that just explains
a few concepts about win32 programming and one of those
concepts should be that in a win32 app you have to use API's?

The thing newbies need to know is when there app is started it
is set in a memory block and the OS sets that memory with privliage's
that make the CPU INT to a runtine if you even try to run a INT or
mess with seg reg's ect. you have to use the OS API's to get anything
done. otherwize they should move to DOS.


Posted on 2006-04-16 19:43:13 by Zcoder

but i want to do it without window api..

If you do not wish to use DOS, the BIOS or your own operating system code, then you need to adhere to the API provided by the OS you are using.

The Standard I/O (stdio) is apart of the C Library standard and is compatible across many systems, that is about as low-level as you are going to get without writing your own system-level driver.
Posted on 2006-04-16 19:53:04 by SpooK
guys thanks for your suggestions :lol:....i finally got the code and its running...This was the thing i was looking for

Can you please xplain me how its working,,whats actually going on..


buffer: .int 0
.string "fileread.S"
.string "filewrite.S"

.globl _start
movl $(SYS_open), %eax
movl $(fileread), %ebx
movl $(0) ,%ecx
int $0x80

push %eax

movl $(SYS_open), %eax
movl $(filewrite), %ebx
movl $(1), %ecx
int $0x80

push %eax
movl $(SYS_read) ,%eax
movl 4(%esp), %ebx
movl $buffer, %ecx
movl $4 ,%edx
int $0x80

cmp $0, %eax
jle end

movl $(SYS_write) ,%eax
movl  (%esp),%ebx
movl $buffer,%ecx
movl $4,%edx
int $0x80
jmp c1


addl $8, %esp
movl $(SYS_exit),%eax
xorl %ebx,%ebx
int $0x80

Posted on 2006-04-17 07:11:54 by MoonBear
Check the links that I give you, the ones "SYS_read" instead of search that only search "read", also note that the calling convention is the named "fast call" (for understand what is going on with this "interface" a convention of calling can be also thinked as an interface), and see that a balancing of stack is done at the end for the two pushes done.

All that do is like you say, open 2 files one for read one for write, read the first and if sucess write it, then exit, all that is done via  the interface at interruption 0x80 of the kernel, see that this is called "syscalls".

You see, an interface can be any way in that you can interact with other thing, even a natural language can be a interface... a mouse is an interface between human and computer.
Posted on 2006-04-17 09:51:54 by rea