as86 help needed!
Guys... I'm trying to take on rather insignificant portion of C code with assembler in it to a piece of linux executable. This is the code:
#define ASM_START #asm #define ASM_END #endasm int main() { printf("Hello!"); ASM_START xor ax, ax ASM_END } suppose It's called hello.c What are the steps I have to follow in order to get from this code to hello (the executable) using as86? |
That's a C program, not an assembly program. You'd use gcc to compile it, but I don't think #asm and #endasm are the correct markers. It's something like _asm { assembly code }
Here, I found this using google: Code:
int main(int argc, char *argv[]) If you want to keep the program the same and change only the #defines, then change them to this: #define ASM_START __asm__ { #define ASM_END }; edit: Actually, I'm getting compile errors with that. Maybe someone with more knowledge than me can help out :) |
First, if you are going to use a C shell with inline assembly, you cant compile that with as86. C code has to be compiled with GCC, (unless you use a different compiler, but unlikely) and for inline code GCC uses its GAS assembler. Second, for such a simple program I dont see why you couldnt just write the whole thing in assembly in the first place. Second, may I ask you why you are using as86 anyway, and not a better assembler like NASM or GAS?
|
you are soooo right
well, man..... I am trying to get myself started in assembly with C.... so I'm looking at my posibilities.
I just started as86... and at the same time looked at nasm.... in fact I found a nasm tutorial yesterday... let's see how it goes. Is it possible to embed assmbly code in C using nasm? what I've seen is making complete asm code (with no embedding). PS... oh, and I made it simple just to get to compile it.... once I see how it's done, I'll go on with more difficult stuff. |
When you embed assembly code into your C code, all you are doing is instructing your C compiler to use your own assembly code instead of constructing its own. You cant choose to use one assembler over another (at least not with gcc), because the compiler uses its own assembler to create the executable. I suggest reading dr paul carter's assembly book, which is free for download at drpaulcarter.com
|
well... call me lucky or something.... it's the tutorial I told you about yesterday. :D
|
oh!, well thats how I originally started out with assembly! Its a very good book.
|
I'm having troubles running a BIOS int 0x13. I get segmentation faults. This interruption is used to get low level HD access. Could it be a kernel security restriction?
|
Yes, you cant use the bios interrupts under linux because the kernel takes care of all of that.
If you want to mess around with bios interupts youll either have to write a bootable program, or write a Dos program and use a dos emulator running as root. I can help you with either one of those things. |
All times are GMT -5. The time now is 02:11 AM. |