Menu

Assembly code in dev c++ - Parallel interface

AAA sddd
2008-11-06
2012-09-26
  • AAA sddd

    AAA sddd - 2008-11-06

    Hi, my name is mattia and i'm a venice student. My english is not very good so don't be worried about mistakes! I'm trying to interface my dev c++ program with the serial port. So I decided to write a part of this program in assembly language because it's easier. Is it a good idea?

    asm("mov portadress,%dx);
    asm("val,%dx");

    how can i specify a parameter in the assebly?
    like: mov al, int i.
    thanks for help!
    Mattia

     
    • cpns

      cpns - 2008-11-06

      > So I decided to write a part of this program in
      > assembly language because it's easier.

      Easier,... Really!? You have got to be kidding!

      Your title mentions Parallel interface, but your question refers to the serial port. Which is it?

      > Is it a good idea?

      No.

      > asm("mov portadress,%dx);
      >
      asm("val,%dx");

      I have no idea what you intended that to do, but if you do not know x86 assembler it is hardly going to be easier is it! Two things you need to know.

      1) Neither the serial nor the parallel port are memory mapped, they are I/O mapped, so you need in/out instructions, not mov instructions.

      2) In modern operating systems, user level code does not have direct access to I/O or memory mapped hardware - for good reason, in a multitasking OS these things need to be controlled.

      If you really want still want to try (against advice), then the in-line assembler syntax is described at http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html

      But it would be far better if you simply took a step back and told us what it is you are actually attempting to do with the port, which ever one it is, and then we will be able to give best advice on how to proceed.

      Not much wrong with your English by the way - except not spelling it with a capital ;-)

      Clifford

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.