[prog] C help - assembly and ports

Akkana Peck akkana at shallowsky.com
Mon Mar 27 15:48:48 EST 2006


Laylaa writes:
> I was hoping somebody could direct me to appropriate tutorials or
> resources so I can quickly teach myself so I can teach my students.

Since I haven't seen any other answers posted ...

Both of the topics you mentioned (embedded assembly language and
accessing serial/parallel ports) are specific to the compiler and
operating system you're using, and aren't part of the C language
at all. (Which might explain why you don't remember them from your
past C experience.)

Assembly language seems to be compiler specific: I've seen several
different syntaxes for embedding assembly into a C program. I've
never had occasion to do that in VC++, but it's probably documented
(maybe a #pragma directive?)

> The other topic is port access, that is writing programs that do I/O
> to ports. This I have no clue about. It's stuff I wouldn't mind
> learning but I have no idea how etc. I barely remember the difference
> between parallel and serial ports.

On Linux, serial and parallel ports are just devices, accessed via
a pathname in the file system, e.g. /dev/ttyS1 or /dev/lp0 or
whatever. You can read from or write to the resulting file
descriptor (you probably do want to use low-level writes and
file descriptors, not stdio buffered writes and file pointers)
and you can also make some device-specific calls to them, usually
using the ioctl() system call.

But if you're using MSVC++, you aren't using Linux anyway, so what
you're actually asking is how to do this on Windows. I think it's
similar, only you open a different filename (COM1: or LP1: or something
like that? It's been a long long time ...) And I think ioctls work on
Windows too, but the specific codes you pass in might be different.

> Anywayz, I hope this is the appropriate list and I hope somebody can
> help/point me somewhere helpful. I did try googling but sometimes it's
> hard when you're not too sure what you're looking for. I will also try
> looking through the archives...but, are they searchable?

Since you really need Windows specific answers in both cases, I
suspect most of what you find in the Linuxchix archives wouldn't
be terribly helpful. But knowing that much might help you in
constructing more helpful google queries. Good luck!

	...Akkana


More information about the Programming mailing list