Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 05-19-2004, 08:18 PM   #1 (permalink)
Amaranthine
Registered User
 
Amaranthine's Avatar
 
Join Date: May 2004
Posts: 47
Amaranthine is on a distinguished road
programming for linux

I decided to start learning some C/C++ and (the incredibly small difference of) assembly on linux.

I have been compiling stuff under g++. I wanted to do some inline assembly so I tried using __asm{ } hoping that would work, but it didn't. Can any of you tell me how to do this? Also I came across what looked like an assembler directive:
.byte <some offset such as 0x01>
or
.long
what is this?

And lastly I assume $ = hex number and % = binary number, but I am not positive so I might as well check. (example: mov al,$10 or mov al,%00000011)

(also, what can I use to assemble not-so-inline assembly?)

And I'm not sure if this matters but I am running RedHat 9.0
Amaranthine is offline   Reply With Quote
Old 05-19-2004, 10:13 PM   #2 (permalink)
joe_bruin
LOAD "*",8,1
 
Join Date: Feb 2003
Location: la.ca.us
Posts: 254
joe_bruin is on a distinguished road
since you didn't specify your architecture, i'll assume you're talking about an x86 machine. i've never really worked with x86 assembly, but i'll give it a shot.

the $(number) most likely means "immediate value".
the % is probably "indirect value".

gcc will assemble files with extension .s or .S (it actually calls the system assembler, "as", but it's much easier through gcc). gcc can also generate assembly code from c. just run gcc -S myfile.c and it will create myfile.s.
joe_bruin is offline   Reply With Quote
Old 05-20-2004, 07:42 PM   #3 (permalink)
Amaranthine
Registered User
 
Amaranthine's Avatar
 
Join Date: May 2004
Posts: 47
Amaranthine is on a distinguished road
Yeah I was referring to x86. Thankyou.
And you said you weren't familiar with x86, are you a RISC assembly programmer?

I am very interested in RISC machines (and RISC assembly for that matter) and hopefully by the end of this summer I will be able to purchase a b2600 (hp-ux risc machine).

Do you happen to know how to write inline assembly straight into a cpp or c file(on linux with gcc)?
Amaranthine is offline   Reply With Quote
Old 05-20-2004, 09:18 PM   #4 (permalink)
joe_bruin
LOAD "*",8,1
 
Join Date: Feb 2003
Location: la.ca.us
Posts: 254
joe_bruin is on a distinguished road
in my work i end up writing bits of assembly here and there, usually for risc processors or dsps. but i try to keep it to a minimum. why anyone would buy a pa-risc machine is beyond me, though. if you want to learn something useful, mips (some would say the purest risc architecture) or powerpc are probably in the lead. sparc machines and alphas are good buys on ebay nowadays, too. and all of those run linux better than hppa.

for inline assembly:
Code:
void my_function()
{
  // some c code
  asm("pushl   %ebp
       movl    %esp, %ebp");
  // some more c code
}
note that the above code does nothing (except cause a segfault).
joe_bruin is offline   Reply With Quote
Old 05-21-2004, 03:29 PM   #5 (permalink)
Amaranthine
Registered User
 
Amaranthine's Avatar
 
Join Date: May 2004
Posts: 47
Amaranthine is on a distinguished road
thanks again.
I was thinking about a mips(I have heard very good things, and the b2600 isn't exactly cost efficient), but I can't find anywhere that sells them (even the official site). If you know some place that does sell them if you could tell me I would really appreciate it.
Amaranthine is offline   Reply With Quote
Old 02-20-2006, 11:29 AM   #6 (permalink)
Hamlin
Jedi Master
 
Hamlin's Avatar
 
Join Date: Feb 2006
Location: Denver, CO
Posts: 15
Hamlin is on a distinguished road
This one also seems finished.
Hamlin is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparison of Different Programming Languages Punch-M6.net All Other Coding Languages 23 04-19-2007 01:34 PM
Windows Programming Help Amaranthine Standard C, C++ 4 05-14-2004 12:48 PM
CLI for noobies: shell programming sde Code Newbie News 0 03-15-2004 12:33 PM
What to use for Programming a gaming engine? L06@N Standard C, C++ 30 01-10-2004 10:04 PM
For those who have Learned C from "The C Programming Lanuage" DemosthenesB Standard C, C++ 5 07-13-2003 12:22 AM


All times are GMT -8. The time now is 08:12 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting