Re: External Modem Emulator

new topic     » goto parent     » topic index » view thread      » older message » newer message

EU>>From: JJProg at CYBERBURY.NET
EU>>Reply-To: Euphoria Programming for MS-DOS <EUPHORIA at LISTSERV.MUOHIO.EDU>
EU>>To: EUPHORIA at LISTSERV.MUOHIO.EDU
EU>>Subject: Re: External Modem Emulator
EU>>Date: Wed, 26 Jan 2000 19:00:46 EST
EU>>
EU>>EU>--Modem emulator...fools computer on other end of serial cable, into
EU>>EU>thinking
EU>>EU>--it owns an external modem.
EU>>
EU>>EU>--Anything that comes in com2 is sent out com1, and anything that comes
EU>>in
EU>>EU>--com1 is sent out com2.
EU>>EU>--Some concepts are taken from E-TERM.EX--Thanks to PJB Systems
EU>>EU>--Pressing any key breaks out of the program.
EU>>
EU>>EU>without type_check
EU>>
EU>>EU>include serial.e
EU>>
EU>>EU>integer key,data,rcnt
EU>>EU>sequence rBuffer    rBuffer = {}
EU>>
EU>>EU>clear_screen()
EU>>EU>puts(1,"Modem Emulator in operation...press a key to terminate...")
EU>>
EU>>EU>SetPortBPDS(1,19200,0,8,1)  --Configure the ports
EU>>EU>SetPortBPDS(2,19200,0,8,1)
EU>>
EU>>EU>rcnt = 0
EU>>EU>key = -1
EU>>EU>while key < 0 do
EU>>EU>    data = GetSerialByte(2)  --See if modem has sent any data
EU>>EU>    if data > 0 then
EU>>EU>        rBuffer &= data  --Yes, so put it in buffer
EU>>EU>        rcnt = 200   --This must be 200 in order not to lose data
EU>>EU>    else
EU>>EU>        rcnt = rcnt -1
EU>>EU>    end if
EU>>EU>    if rcnt < 1 then
EU>>EU>        rcnt = 0
EU>>EU>        key = get_key()   --If user has pressed a key, then exit prog
EU>>EU>        if length(rBuffer) > 0 then   --If there's anything in buffer,
EU>>EU>            for i = 1 to length(rBuffer) do --Send it out
EU>>EU>                SendSerialByte(1,rBuffer[i]) --com1
EU>>EU>            end for
EU>>EU>            rBuffer = {}  --Empty the buffer
EU>>EU>        end if
EU>>EU>        data = GetSerialByte(1) --Get data from com1 (remote 'puter)
EU>>EU>        if data > 0 then    --If any data was waiting,
EU>>EU>            SendSerialByte(2,data) --send it to modem
EU>>EU>        end if
EU>>EU>    end if
EU>>EU>end while
EU>>EU>puts(1,"\n\nDone.\n")
EU>>
EU>>EU>Thanks in advance,
EU>>
EU>>EU>Ben
EU>>
EU>>EU>Get Your Private, Free Email at http://www.hotmail.com
EU>>
EU>>Try writing as much in assembly as possible, so that it goes faster.
EU>>For example, try this:
EU>>
EU>>push edx        ; Save the registers
EU>>push eax
EU>>mov dx, 765     ; COM2 data ready
EU>>in al, dx
EU>>and al, 1
EU>>cmp al, 0       ; Is data ready?
EU>>je noMoreData   ; No
EU>>mov dx, 760     ; COM2 input
EU>>in al, dx
EU>>mov dx, 1016    ; COM1 output
EU>>out dx, al
EU>>noMoreData:
EU>>pop eax         ; Restore registers and return
EU>>pop edx
EU>>ret
EU>>
EU>>I haven't tested it, though.
EU>>
EU>>Jeff

EU>Looks like it will work, but I'm not sure how to implement it in Euphoria.
EU>In particular, how do I know what address to poke in for a label when I
EU>don't know where it will be loaded into memory.  I looked at Pete's asm.e,
EU>but will it resolve the addresses?

EU>Also, do you think that the assembly language code will be fast enough, that
EU>I can eliminate the buffer?  If not, how do I add a byte to the sequence
EU>(rBuffer in the above code) from the asm routine?

EU>Thanks again,

EU>Ben
EU>______________________________________________________
EU>Get Your Private, Free Email at http://www.hotmail.com

Well, it's certainly a lot faster than Euphoria, and all the code is
inlined. I don't see much of an advantage to using a buffer since then
you might loose data while it is sending everything. I'm not sure how
you do labels with asm.e. You might want to inline some keyboard
routines in the assembly code so it goes even faster, then put it in a
loop so pretty much all of the program is in Assembly. You might take a
look at keyread.e. I'd write some more example code, but I really have
to work on some other stuff right now. I'll try writing some when I get
some time.

Jeff

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu