473,513 Members | 2,469 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inserting Assembally into C source

Hello everyone. I was wondering if there was anyway to put some
assembally into C source code so that the assembally would be evaluated
exactly as it was written. I'm looking for some sort of standard
function or feature here so I am relitively sure that I am on topic (I
know some people that read this news group can be slightly brutal about
off topic posts). Anyways I'm just looking for a way to put a bit of
assembally into my code to take care of things that I would not be able
to otherwise. Thanks in advanced for any answers.
Nori

May 10 '06 #1
12 1490
no*********@gmail.com wrote:
Hello everyone. I was wondering if there was anyway to put some
assembally into C source code so that the assembally would be
evaluated exactly as it was written.


There's no portable way, so it would be off-topic. You'll need to find
a group dedicated to your hardware/compiler combination.


Brian
--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
May 10 '06 #2
On 10 May 2006 14:35:56 -0700, "no*********@gmail.com"
<no*********@gmail.com> wrote:
Hello everyone. I was wondering if there was anyway to put some
assembally into C source code so that the assembally would be evaluated
exactly as it was written. I'm looking for some sort of standard
function or feature here so I am relitively sure that I am on topic (I
know some people that read this news group can be slightly brutal about
off topic posts). Anyways I'm just looking for a way to put a bit of
assembally into my code to take care of things that I would not be able
to otherwise. Thanks in advanced for any answers.
Nori


The question is on-topic, but the answer is no. There is no standard
way of embedding assembly language in C source. Your implementation
may provide extensions to do it, but you'd have to ask in a forum
which discusses that particular implementation.

--
Al Balmer
Sun City, AZ
May 10 '06 #3

<no*********@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
Hello everyone. I was wondering if there was anyway to put some
assembally into C source code so that the assembally would be evaluated
exactly as it was written. I'm looking for some sort of standard
function or feature here so I am relitively sure that I am on topic (I
know some people that read this news group can be slightly brutal about
off topic posts). Anyways I'm just looking for a way to put a bit of
assembally into my code to take care of things that I would not be able
to otherwise. Thanks in advanced for any answers.
The only "standard" way is to put it in an external routine. Actually I am
not even sire this is standard, but it has to be external.

Given you had some hex machine code could you put that in a string, (or
other array, say ints if you needed word alignment), cast the address of a
string to the address of a function and call the function?
Nori

May 10 '06 #4
"David Wade" <g8***@yahoo.com> writes:
<no*********@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
Hello everyone. I was wondering if there was anyway to put some
assembally into C source code so that the assembally would be evaluated
exactly as it was written. I'm looking for some sort of standard
function or feature here so I am relitively sure that I am on topic (I
know some people that read this news group can be slightly brutal about
off topic posts). Anyways I'm just looking for a way to put a bit of
assembally into my code to take care of things that I would not be able
to otherwise. Thanks in advanced for any answers.


The only "standard" way is to put it in an external routine. Actually I am
not even sire this is standard, but it has to be external.

Given you had some hex machine code could you put that in a string, (or
other array, say ints if you needed word alignment), cast the address of a
string to the address of a function and call the function?


Most C compilers provide some kind of extension that allows you to
write inline assembly code. Your proposed method uses only standard C
features, but it uses them in an *entirely* non-portable manner.
Using a compiler extension is no less portable, and is *far* more
likely to work and to be maintainable.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
May 11 '06 #5
Yes, you can do it in C programming for microcontroller. Assembly code
can be inserted at any portion of the C code. You can try it in
microcontroller programming. Here is the link for some help:
www.electronics.netmyne.com

May 11 '06 #6
Dheroyan2006 wrote:
Yes, you can do it in C programming for microcontroller.
Do what? Please include context when posting. Google is most definitely
*not* Usenet. See the Google part of
http://clc-wiki.net/wiki/Intro_to_clc for information about it, and the
rest of the page for more about this group.
Assembly code
can be inserted at any portion of the C code.
Not standard C it can't, and the way the extensions work vary from
implementation to implementation.
You can try it in
microcontroller programming. Here is the link for some help:
www.electronics.netmyne.com


Well, going through the tutorial I found, "In any real program, you will
use the gets or fgets functions instead to read text a line at a time."
on page http://www.electronics.netmyne.com/cprogramming7.html

Any tutorial that suggests using gets in real programs should be treated
with a degree of caution.

Going further I see:
int Main()

{

void Display(); // we called function Display

}

C is case sensitive, so using Main rather than main is not going to help
(if the linker is case insensitive, which it is allowed to be, it could
work by luck). Having a function named Main as well as one named main
would be legal, but I would consider it to be very bad practice.

There are other stupid errors as well. So having got further through it,
I would strongly recommend *against* that site.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
May 11 '06 #7
Thants not all...oh no thats not all. This is some of the worst
programming style and structure I have ever seen. Anyplace that writes
source like this: (note: not actually copied)
#include <stdio.h>
main(){
char chr;
printf("hello\n");
for(;;){
scanf("%c", &chr); /* in "real" programs we don't use this */
if(chr==a)
break;
}
}
CANNOT BE TRUSTED!!!

May 11 '06 #8
>Thants not all...oh no thats not all. This is some of the worst
programming style and structure I have ever seen. Anyplace that writes
source like this: (note: not actually copied)
#include <stdio.h>
main(){
char chr;
printf("hello\n");
for(;;){
scanf("%c", &chr); /* in "real" programs we don't use this */
if(chr==a)
break;
}
}
CANNOT BE TRUSTED!!!

I apologize for my unquoted context.
I was refering to:
Well, going through the tutorial I found, "In any real program, you will
use the gets or fgets functions instead to read text a line at a time."
on page http://www.electronics.netmyne.com/cprogramming7.html

Any tutorial that suggests using gets in real programs should be treated
with a degree of caution.
Going further I see:
int Main()
{
void Display(); // we called function Display

}
C is case sensitive, so using Main rather than main is not going to help
(if the linker is case insensitive, which it is allowed to be, it could
work by luck). Having a function named Main as well as one named main
would be legal, but I would consider it to be very bad practice.

There are other stupid errors as well. So having got further through it,
I would strongly recommend *against* that site.


May 11 '06 #9
On 2006-05-11, Flash Gordon <sp**@flash-gordon.me.uk> wrote:
C is case sensitive, so using Main rather than main is not going to
help (if the linker is case insensitive, which it is allowed to be, it
could work by luck). Having a function named Main as well as one named
main would be legal, but I would consider it to be very bad practice.


Actually, that would not be 'legal' unless one or both of them are
static. A program containing multiple external identifiers that are the
same (case-insensitive) in the first six characters is not strictly
conforming.
May 11 '06 #10
Jordan Abel wrote:
On 2006-05-11, Flash Gordon <sp**@flash-gordon.me.uk> wrote:
C is case sensitive, so using Main rather than main is not going to
help (if the linker is case insensitive, which it is allowed to be, it
could work by luck). Having a function named Main as well as one named
main would be legal, but I would consider it to be very bad practice.


Actually, that would not be 'legal' unless one or both of them are
static. A program containing multiple external identifiers that are the
same (case-insensitive) in the first six characters is not strictly
conforming.


I meant would be legal if the link phase was case sensitive, which it is
allowed to be. Not strictly conforming, I agree.

The important thing being it should not be done, and a site doing it in
examples is definitely one to avoid using.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
May 11 '06 #11
Keith Thompson wrote:
"David Wade" <g8***@yahoo.com> writes:
<no*********@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
Hello everyone. I was wondering if there was anyway to put some
assembally into C source code so that the assembally would be evaluated
exactly as it was written. I'm looking for some sort of standard
function or feature here so I am relitively sure that I am on topic (I
know some people that read this news group can be slightly brutal about
off topic posts). Anyways I'm just looking for a way to put a bit of
assembally into my code to take care of things that I would not be able
to otherwise. Thanks in advanced for any answers.

The only "standard" way is to put it in an external routine. Actually I am
not even sire this is standard, but it has to be external.

Given you had some hex machine code could you put that in a string, (or
other array, say ints if you needed word alignment), cast the address of a
string to the address of a function and call the function?


Most C compilers provide some kind of extension that allows you to
write inline assembly code. Your proposed method uses only standard C
features, but it uses them in an *entirely* non-portable manner.
Using a compiler extension is no less portable, and is *far* more
likely to work and to be maintainable.

We did have systems nearly 30 years ago which required this style of
(octal) code to access system clock and the like. I never heard anyone
lament the advent of more portable ways, or saw anyone go back.
May 11 '06 #12
Jordan Abel <ra*******@gmail.com> writes:
On 2006-05-11, Flash Gordon <sp**@flash-gordon.me.uk> wrote:
C is case sensitive, so using Main rather than main is not going to
help (if the linker is case insensitive, which it is allowed to be, it
could work by luck). Having a function named Main as well as one named
main would be legal, but I would consider it to be very bad practice.


Actually, that would not be 'legal' unless one or both of them are
static. A program containing multiple external identifiers that are the
same (case-insensitive) in the first six characters is not strictly
conforming.


In C90; in C99, the limit is 31 characters, and upper and lower case
are distinct.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
May 11 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5848
by: Mat | last post by:
Hi, I have a system that uploads images as BLOBs in a database. I also have a function that I use to resize uploaded images before saving as files. I would like to combine these two by resising...
0
2419
by: Marko Poutiainen | last post by:
Situation: We had to make our SQLServer 2000 database multi-lingual. That is, certain things (such as product names) in the database should be shown in the language the user is using (Finnish,...
3
6832
by: Joachim Klassen | last post by:
Hi all, first apologies if this question looks the same as another one I recently posted - its a different thing but for the same szenario:-). We are having performance problems when...
2
1739
by: Alan Silver | last post by:
Hello, VWD Express seems obsessed with inserting loads of spaces at the start of each line whenever you drag controls into the source view. I guess this is MS' idea of making the source code...
6
2034
by: Pushpendra Vats | last post by:
Hi , I am trying to insert records into database. I am trying to write the following code. On button1 click event i am inserting five records and after that i am calling the update method of...
0
2990
by: pd123 | last post by:
I'm new to C# and .net and I'm trying to create a form that will register users in a sql server database. I have the following code but when I run the code I get an error " The name 'Peter' is...
0
1626
by: tom c | last post by:
I am going through "Walkthrough: Editing and Inserting Data in Web Pages with the DetailsView Web Server Control" found at http://msdn2.microsoft.com/en-us/library/sdba1d59.aspx I am using...
0
2216
by: toyin | last post by:
hello, pls help look through this code its not inserting the record in dataset into the another database. i want to insert the row in the dataset into another table in another database. pls help....
5
5029
by: pramodkh | last post by:
Hi All I am trying to match a pattern in a file and insert a line. If the pattern matches then insert a line before the matching pattern line. for example, I have the following content in a...
0
7259
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7380
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5085
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.