Basically, I've written assembly code which allows a text file to be copied from it's current location through the Com cable onto a destination on another computer. This is the code for the transmitter part ONLY.
#include
<stdio.h> #include <conio.h> #define FEND 0x40
int main (void) {
char wtmode[]= "wb";
char rdmode[]= "rb";
char fname []= "C:\MoveThis.txt";
char pname []= "COM2";
char error1 []= "data file failed to open";
char error2 []= "com port failed to open";
FILE * fileptr;
FILE * portprt;
__asm {
lea eax, rdmode
push eax
lea eax, fname
push eax
call DWORD PTR (fopen) ; open data file for reading
add esp,8
or eax,eax
jnz fileOK
lea eax,error1
push eax
call printf ; fail to open file
add esp,4
jmp endit
fileOK: mov DWORD PTR (fileptr), eax
lea eax,wtmode
push eax
lea eax,pname
push eax
call DWORD PTR (fopen) ; open COM port for writing
add esp,8
or eax, eax
jnz portOK
lea eax, error2
push eax
call DWORD PTR (printf) ; faile to open port
add esp, 4
mov eax, DWORD PTR(fileptr)
push eax
call DWORD PTR (fclose)
add esp,4
jmp endit
portOK: mov DWORD PTR (portptr), eax
more: mov eax, DWORD PTR(fileptr)
push eax
call DWORD PTR (fgetc) ; get next char from data file
add esp,4
cmp eax, EOF ; check for end of data
jz nomore
mov ebx, eax
mov eax, DWORD PTR(portptr)
push eax
push eax
call DWORD PTR (fputc) ; send char to COM port
add esp,8
jmp more
nomore: mov eax, DWORD PTR (fileptr)
push eax ; end of data so
mov eax,FEND ; send terminating sentinal
push eax
call DWORD PTR (fputc)
add esp,8
mov eax, DWORD PTR (fileptr)
push eax
call DWORD PTR (fclose) ; close data file
add esp,4
mov eax, DWORD PTR(portptr)
push eax
call DWORD PTR (fclose) ; flush and close COM port
add esp,4
endit:
} //asm
return 0;
} // main
When I try to debug the file in VC++ 2008, I'm greeted with the following errors:
------ Build started: Project: filetransmit, Configuration: Debug Win32 ------
Compiling...
Filetransmit.c
c:\users\parent\documents\visual studio 2008\projects\filetransmit\filetransmit\filetransmit.c(1) : error C2006: '#include' : expected a filename, found 'newline'
c:\users\parent\documents\visual studio 2008\projects\filetransmit\filetransmit\filetransmit.c(1) : fatal error C1083: Cannot open include file: '': No such file or directory
Build log was saved at "file://c:\Users\Parent\Documents\Visual Studio 2008\Projects\filetransmit\filetransmit\Debug\BuildLog.htm"
filetransmit - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Can someone correct these errors for me as after various attempts I've just hit a dead end. :'(