News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Serial I/O communications (terminal) code

Started by jimg, June 02, 2017, 02:18:51 AM

Previous topic - Next topic

jimg

I've been trying to find some code to write a terminal program to embed in an app I want to write.  After staring at various version of C stuff for a week, I think I'm ready to start.  I read a lot of rhetoric about different ways to implement this.  The problem seems to be that windows nt doesn't have any simple callbacks for i/o routines.  Anyway, I think I'm going to do the 1995 version of things, based upon starting two threads, one to read and one to write (https://msdn.microsoft.com/en-us/library/ms810467.aspx).  It seems the simplest (although, not what I would call simple).

Before I start trying to convert C, I thought I'd see if someone already has masm code for this stashed away somewhere, or if anyone has some other masm code for a terminal program or just some thoughts they would like to share.

anunitu

You might try the wayback machine. There is a LOT of data and old sites now gone. If you are lucky,you might find some old code..I think a lot of the old protocols were done in assembly.

Check here.
https://en.wikipedia.org/wiki/List_of_file_transfer_protocols

Wayback is here.
http://archive.org/web/

Siekmanski

Try this one, if it suits your needs then i'll clean up the code and do some dutch english translations.
Creative coders use backward thinking techniques as a strategy.

jimg

Thanks. Looks like it worked :t
I'd love to have the source!

Siekmanski

Found a later version, check if it works for you. Then I'll translate this one for you.
Creative coders use backward thinking techniques as a strategy.

jimg


Siekmanski

Pffff, done translating to english...  :biggrin:
Here are the sources, have fun with it.

Are you going to use this to communicate with the WiFi esp8266 module?
Creative coders use backward thinking techniques as a strategy.

jimg

That's the plan.  Thanks much, I really appreciate it :t

jimg

I put this here rather than the campus since it came from our good friend Siekmanski's code he just gave us.

I've never used RECORD before, so I spent an hour trying to figure this out.  Other than being entered in the reverse order from what I thought it would be, I don't see anything wrong with the code but I'm getting an error.

DCB_New                 DCB <?>
;  this bitrecord def is from windows.inc
; BITRECORD RECORD fBinary:1,fParity:1,fOutxCtsFlow:1,fOutxDsrFlow:1,fDtrControl:2,fDsrSensitivity:1,
;  fTXContinueOnXoff:1,fOutX:1,fInX:1,fErrorChar:1,fNull:1,fRtsControl:2,fAbortOnError:1,fDummy2:17

        mov     DCB_New.fbits,BITRECORD<NULL,FALSE,RTS_CONTROL_HANDSHAKE,FALSE,FALSE,\
                FALSE,FALSE,FALSE,FALSE,DTR_CONTROL_HANDSHAKE,TRUE,TRUE,NULL,TRUE>

gives:  Error A2150: Missing operator in expression

I've counted 20 times at least, and it looks like the right number of entries.  Anyone see what's wrong with this?  I'm getting the same complaint from all the assemblers from 615 to uasm.

anunitu

Wondering if that backslash is supposed to continue to the next line,might it need to be a forward slash? Might need a space before the BS,might be seeing it as a divide because of the comma first.

jimg

Nope.  All on one line made no difference.

Also tried:
xxxttt BITRECORD  < TRUE, NULL, TRUE, TRUE, DTR_CONTROL_HANDSHAKE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, RTS_CONTROL_HANDSHAKE, FALSE, NULL >

        mov     DCB_New.fbits,xxxttt

and got : Error A2049: Invalid instruction operands

I had to reverse the order in this case because it complained about sizes and it was obvious it was just backward.


p.s.

I really don't need to change all this stuff, so I just copied the original DCB and commented this whole section out and it works just fine.   I would, however, like to know the correct way to code this for future reference.  For now, I'm just pressing on.

Siekmanski

Yeah, it's a bit confusing but the BITRECORD in masm needs to be in reversed order as below. ( it's different as in C )

\ is continue on the next line.

; FlowControle == None
        mov     DCB_New.fbits,BITRECORD <\
                NULL,\  ; fDummy2:17
                FALSE,\ ; fAbortOnError:1
                RTS_CONTROL_DISABLE,\   ; fRtsControl:2
                FALSE,\ ; fNull:1
                FALSE,\ ; fErrorChar:1
                FALSE,\ ; fInX:1
                FALSE,\ ; fOutX:1
                FALSE,\ ; fTXContinueOnXoff:1
                FALSE,\ ; fDsrSensitivity:1
                DTR_CONTROL_DISABLE,\   ; fDtrControl:2
                FALSE,\ ; fOutxDsrFlow:1
                FALSE,\ ; fOutxCtsFlow:1
                NULL,\  ; fParity:1
                TRUE>   ; fBinary:1 Always TRUE !!!

        or      DCB_New.fbits,00000000000000000000000000000010b   ; here I set the right bit for: "fParity"

You can set every bit by hand of course...
Creative coders use backward thinking techniques as a strategy.

mineiro

Quote from: jimg on June 02, 2017, 02:22:11 PM
I would, however, like to know the correct way to code this for future reference.
Quote from: jimg on June 02, 2017, 12:56:28 PM
I've never used RECORD before,
hello jimg, below is a simple example about how to deal with record, not sure if helps but this is my intention.

descritor RECORD one:1=0,two:3,three:2,four:2      ;0 ??? ?? ??

.data
descr_1 descritor <>            ;0 ??? ?? ??
descr_2 descritor <1,2,3,2>         ;1 010 11 10

.code
or descr_1,( 3 shl two + 1 shl three)      ;0 011 01 ??
mov al,descr_2         ;1 010 11 10
mov bl,width two      ;bits size of field two == 3
and al,mask two         ;mask to deal with that field == 0 111 00 00
mov cl,two         ;displacement of field two inside that record structure == 2+2(four+three) == 4
shr al,cl         ;rotating to get only that value, al=2
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

jimg

Thanks mineiro.

Everyone else, my apologies.   The Record stuff works in ml614 and ml615.  My system for switching between ml and xxwasm was broken, the error is just in wasm and decendants.

jimg

S-

Using masm 6.15-

this line is not acceptable, and is the same order as in the program.

yy1 BITRECORD <NULL,FALSE,RTS_CONTROL_HANDSHAKE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,DTR_CONTROL_HANDSHAKE,TRUE,TRUE,NULL,TRUE>

I get the errors-
: error A2071:  : fOutxCtsFlow
: error A2071:  : fErrorChar
   So it knows the sizes are wrong


this is is accepted, so masm want them specified in the same order as the record definition.

yy4 BITRECORD <TRUE,0,TRUE,TRUE,DTR_CONTROL_HANDSHAKE,0,0,0,0,0,0,RTS_CONTROL_HANDSHAKE,0,0>


   Both of these lines are acceptable to Masm, which means it is a masm bug,
     it should have caught the size error in the first line here also.

mov DCB_New.fbits,BITRECORD<NULL,FALSE,RTS_CONTROL_HANDSHAKE,FALSE,FALSE,\
                FALSE,FALSE,FALSE,FALSE,DTR_CONTROL_HANDSHAKE,TRUE,TRUE,NULL,TRUE>
               
mov DCB_New.fbits,BITRECORD<TRUE,0,TRUE,TRUE,DTR_CONTROL_HANDSHAKE,0,0,0,0,0,0,RTS_CONTROL_HANDSHAKE,0,0>


       In fact, if I try to force an error by entering a value too big, like this-

mov     DCB_New.fbits,BITRECORD<132000,FALSE,RTS_CONTROL_HANDSHAKE,FALSE,FALSE,\
                FALSE,FALSE,FALSE,FALSE,DTR_CONTROL_HANDSHAKE,TRUE,TRUE,NULL,TRUE>
               
mov DCB_New.fbits,BITRECORD<TRUE,0,TRUE,TRUE,DTR_CONTROL_HANDSHAKE,0,0,0,0,0,0,RTS_CONTROL_HANDSHAKE,0,132000>

      Both are still accepted by masm.


   I really think the second one is the correct one, and the ones in the program are incorrectly reversed,
     but I can't get the program to fail either way, so I don't know how to test it.