delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/11/30/15:13:08

Date: Thu, 30 Nov 1995 17:35:26 +0000 (GMT)
From: Andy Molyneux <molyneua AT cs DOT man DOT ac DOT uk>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: assembler

On Thu, 30 Nov 1995, Werner Drescher wrote:

> Hello
> 
> I've some question about assmbler code in a normal C-function.
> The function is like that :
> 
> void dma_smp(void)
> {
>  asm ( cli
>        movb 0x308,%dx 
>        ...
>       );
> }
> The first question is : is the Syntas asm(   ); correct or must I use asm 
> ("   ");
> 
No it isn't correct - you must use the quotes.

> The next is  I want to write more than one instruction , but when I use 
> ";" to seperate them I get a error-message
>
Should work if you leave the quotes in. It's not necessary to use ';' 
between instructions if you have a newline; ie
  asm ("cli
        movb 0x308,%dx
        ...
     ");
is valid.

> I use the instruction movb 0x308,%dx and get a segmentation violent
error > why ? > Two things to remember: the operands are the "wrong" way
round in an asm() statement - where you're used to writing "mov ax,dx" to 
copy dx to ax, you need to write "movw %dx,%ax".  Assuming you know this, 
the problem is probably that you want to have "$0x308" instead of just 
"0x308". I can't remember whether that's it exactly, but email me if it's 
still unclear and I'll send you a big sample of code.

- Andy

| Andrew Molyneux            Internet: molyneua AT cs DOT man DOT ac DOT uk
| University of Manchester   Tel     : (+44)161-485-3291
| REAL programmers write  a=b!=4?b%2?c:d:e  without even
| thinking about it :-)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019