473,671 Members | 2,331 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 1505
no*********@gma il.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*********@gm ail.com"
<no*********@gm ail.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*********@gm ail.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.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.co m> writes:
<no*********@gm ail.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.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_Keit h) 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

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

Similar topics

1
5867
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 the images before inserting them as BLOBs. My problem is that (apart from being new to file stuff) my resize function returns a Resource ID which of course is not the same as the file handler that was passed to it, it's a reference to an image...
0
2424
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, Swedish or English). There are about a dozen tables with columns that need localization. Doing this in the application level was a no-goer. It would have taken far too much time (there is a *lot* of code and unfortunately most of the...
3
6898
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 inserting/deleting rows from a large table. My scenario: Table (lets call it FACT1) with 1000 million rows distributed on 12
2
1744
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 readable by indenting it, but it annoys me intensely. Apart from anything else, it causes extra line wrap as the spaces make the line too long to fit in the window. Can I switch off this, erm "feature"? I haven't found a way yet. Please put me out...
6
2050
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 dataadapter to update the records in database. Records are inserting but all the five records have the same value and that too of that last ones.. More over i tried to use the acceptchanges methods for datatable and dataset but of no use
0
2999
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 not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted. Where Peter is the value entered in the textbox for firstname (fnameTBox) I'm sure the problem is something obvious but I...
0
1632
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 Access instead of SQL Server. Everything works fine until I get to the last step, where I try to insert a record. When I hit the New link it lets me add the new data, but then when I hit Insert, I get the yellow page which I have paseted below. I...
0
2227
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. it urgent i submit this application. when it runs it gives: this OdbcTransaction has completed,it no longer usable. thx toyin here is the code Sub ProcessAllSynchOperations() Dim sSourceURL, sWebSiteIP As String Dim...
5
5043
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 file: //This is my source file //this is where i want to insert a line class Class1
0
8390
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8911
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8819
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8597
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8667
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6222
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4222
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2808
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1806
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.