[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c

inline assembly

Jrdman

7/9/2008 5:49:00 PM

i wrote this code
int main(void){
asm("movb $0x00,%ah \n"
"movb $0x0d,%al \n"
"int $0x10");
return 0;
}
to disappair the cursor but when it excutes the program craches with
the message "the memory can not be writen" what's wrong with this
code?
25 Answers

roberson

7/9/2008 5:57:00 PM

0

In article <52203b89-968d-4a8b-be23-20f1288f5c6a@m45g2000hsb.googlegroups.com>,
Jrdman <ahmed.bou23@gmail.com> wrote:
>i wrote this code
>int main(void){
> asm("movb $0x00,%ah \n"
> "movb $0x0d,%al \n"
> "int $0x10");
> return 0;
> }
>to disappair the cursor but when it excutes the program craches with
>the message "the memory can not be writen" what's wrong with this
>code?

inline assembly is not part of the C standard. Whatever your compiler
does with it is compiler specific, and needs to be inquired about
in a newgroup that deals with your development environment.
As far as the C language is concerned, your code is just a normal
framework for main() that contains as its body a call to an
unprototyped routine named 'asm' (that is not part of the
C standard library) that is to be passed in a pointer
to a single static string.

--
"The slogans of an inadequate criticism peddle ideas to fashion"
-- Walter Benjamin

santosh

7/9/2008 6:17:00 PM

0

Jrdman wrote:

> i wrote this code
> int main(void){
> asm("movb $0x00,%ah \n"
> "movb $0x0d,%al \n"
> "int $0x10");
> return 0;
> }
> to disappair the cursor but when it excutes the program craches with
> the message "the memory can not be writen" what's wrong with this
> code?

Better ask in alt.lang.asm or comp.lang.asm.x86.

Bartc

7/9/2008 6:28:00 PM

0


"Jrdman" <ahmed.bou23@gmail.com> wrote in message
news:52203b89-968d-4a8b-be23-20f1288f5c6a@m45g2000hsb.googlegroups.com...
>i wrote this code
> int main(void){
> asm("movb $0x00,%ah \n"
> "movb $0x0d,%al \n"
> "int $0x10");
> return 0;
> }
> to disappair the cursor but when it excutes the program craches with
> the message "the memory can not be writen" what's wrong with this
> code?

This is not a C issue.

Looks like some code that runs under DOS, so even less on-topic. (However
those parameters to INT don't look right; you may want to double check the
0x10, 0x0D, 0x00, and which registers you put those in.)

Might be more familiar to the guys in comp.lang.asm.x86


--
Bartc


Kenneth Brody

7/9/2008 7:20:00 PM

0

Jrdman wrote:
>
> i wrote this code
> int main(void){
> asm("movb $0x00,%ah \n"
> "movb $0x0d,%al \n"
> "int $0x10");
> return 0;
> }
> to disappair the cursor but when it excutes the program craches with
> the message "the memory can not be writen" what's wrong with this
> code?

In addition to what the others have said, consider the possibility
that the arguments to movb may be destination, source. You'll have
to ask in a group that discusses your particular platform and
compiler, however, in order to get any real answers.

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:ThisIsASpamTrap@gmail.com>

CBFalconer

7/9/2008 11:21:00 PM

0

Jrdman wrote:
>
> i wrote this code
> int main(void){
> asm("movb $0x00,%ah \n"
> "movb $0x0d,%al \n"
> "int $0x10");
> return 0;
> }
> to disappair the cursor but when it excutes the program craches
> with the message "the memory can not be writen" what's wrong with
> this code?

The word 'asm' is a syntax error. It doesn't exist in standard C.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.a...
Try the download section.

Richard Heathfield

7/9/2008 11:37:00 PM

0

CBFalconer said:

> Jrdman wrote:
>>
>> i wrote this code
>> int main(void){
>> asm("movb $0x00,%ah \n"
>> "movb $0x0d,%al \n"
>> "int $0x10");
>> return 0;
>> }
>> to disappair the cursor but when it excutes the program craches
>> with the message "the memory can not be writen" what's wrong with
>> this code?
>
> The word 'asm' is a syntax error.

No, it isn't. In the above case, it is being used to call a function named
asm which takes char * (or perhaps const char *) and returns int, and the
syntax looks just fine to me.

> It doesn't exist in standard C.

The failure of a function name to be listed in the standard library is
insufficient to make the use of that name a syntax error.

--
Richard Heathfield <http://www.cpax....
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/goog...
"Usenet is a strange place" - dmr 29 July 1999

user923005

7/10/2008 12:08:00 AM

0

"Richard Heathfield" <rjh@see.sig.invalid> wrote in message
news:h5qdnUBbYdME1-jVnZ2dneKdnZydnZ2d@bt.com...
> CBFalconer said:
>
>> Jrdman wrote:
>>>
>>> i wrote this code
>>> int main(void){
>>> asm("movb $0x00,%ah \n"
>>> "movb $0x0d,%al \n"
>>> "int $0x10");
>>> return 0;
>>> }
>>> to disappair the cursor but when it excutes the program craches
>>> with the message "the memory can not be writen" what's wrong with
>>> this code?
>>
>> The word 'asm' is a syntax error.
>
> No, it isn't. In the above case, it is being used to call a function named
> asm which takes char * (or perhaps const char *) and returns int, and the
> syntax looks just fine to me.
>
>> It doesn't exist in standard C.
>
> The failure of a function name to be listed in the standard library is
> insufficient to make the use of that name a syntax error.

The keyword asm has been a part of the C language for a long time. Exactly
what that keyword does or how it should be used is something more of a
mystery. However, in C99 we have this:

J.5.10 The asm keyword

1 The asm keyword may be used to insert assembly language directly into the
translator output (6.8). The most common implementation is via a statement
of the form:

asm ( character-string-literal );

Page 512 Portability issues §J.5.13




** Posted from http://www.te... **

Richard Heathfield

7/10/2008 2:50:00 AM

0

Dann Corbit said:

> "Richard Heathfield" <rjh@see.sig.invalid> wrote in message
> news:h5qdnUBbYdME1-jVnZ2dneKdnZydnZ2d@bt.com...
>> CBFalconer said:
>>
>>> Jrdman wrote:
>>>>
>>>> i wrote this code
>>>> int main(void){
>>>> asm("movb $0x00,%ah \n"
>>>> "movb $0x0d,%al \n"
>>>> "int $0x10");
>>>> return 0;
>>>> }
>>>> to disappair the cursor but when it excutes the program craches
>>>> with the message "the memory can not be writen" what's wrong with
>>>> this code?
>>>
>>> The word 'asm' is a syntax error.
>>
>> No, it isn't. In the above case, it is being used to call a function
>> named asm which takes char * (or perhaps const char *) and returns int,
>> and the syntax looks just fine to me.
>>
>>> It doesn't exist in standard C.
>>
>> The failure of a function name to be listed in the standard library is
>> insufficient to make the use of that name a syntax error.
>
> The keyword asm has been a part of the C language for a long time.
> Exactly what that keyword does or how it should be used is something more
> of a
> mystery. However, in C99 we have this:
>
> J.5.10 The asm keyword
>
> 1 The asm keyword may be used to insert assembly language directly into
> the translator output (6.8). The most common implementation is via a
> statement of the form:
>
> asm ( character-string-literal );

Right, but of course that's in a non-normative appendix, and the following
text is relevant:

J.5 Common extensions
1 The following extensions are widely used in many systems, but are not
portable to all implementations. The inclusion of any extension that may
cause a strictly conforming program to become invalid renders an
implementation nonconforming. Examples of such extensions are new
keywords, extra library functions declared in standard headers, or
predefined macros with names that do not begin with an underscore.

The asm keyword is /not/ a standard keyword. C99 implementations must be
able to translate the following code correctly:

#include <stdio.h>

int asm(const char *s)
{
puts(s);
}

int main(void)
{
asm("movb $0x00,%ah \n"
"movb $0x0d,%al \n"
"int $0x10");
return 0;
}

<snip>

--
Richard Heathfield <http://www.cpax....
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/goog...
"Usenet is a strange place" - dmr 29 July 1999

CBFalconer

7/10/2008 3:33:00 AM

0

Richard Heathfield wrote:
> CBFalconer said:
>> Jrdman wrote:
>>>
>>> i wrote this code
>>> int main(void){
>>> asm("movb $0x00,%ah \n"
>>> "movb $0x0d,%al \n"
>>> "int $0x10");
>>> return 0;
>>> }
>>> to disappair the cursor but when it excutes the program craches
>>> with the message "the memory can not be writen" what's wrong
>>> with this code?
>>
>> The word 'asm' is a syntax error.
>
> No, it isn't. In the above case, it is being used to call a
> function named asm which takes char * (or perhaps const char *)
> and returns int, and the syntax looks just fine to me.

Yes, nailed in a sloppy statement again. However I maintain the
sloppy one will do a better job of alerting the OP to the real
problem than this one will.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.a...
Try the download section.


John B. Matthews

7/10/2008 7:28:00 AM

0

On 10 Jul 2008 at 3:32, CBFalconer wrote:
> Richard Heathfield wrote:
>> CBFalconer said:
>>> The word 'asm' is a syntax error.
>>
>> No, it isn't.
>
> Yes, nailed in a sloppy statement again. However I maintain the
> sloppy one will do a better job of alerting the OP to the real
> problem than this one will.

It will certainly do a good job of alerting him to the fact that you're
a dick, and that he would to well to ignore all the nonsense you
dribble.