* Re: how to insert an asm instruction in C code and how to compile it
2005-06-20 14:58 how to insert an asm instruction in C code and how to compile it Srinivas G.
@ 2005-06-20 14:56 ` Paolo Ornati
2005-06-20 14:57 ` Mads Martin Joergensen
2005-06-20 15:40 ` Richard B. Johnson
2 siblings, 0 replies; 4+ messages in thread
From: Paolo Ornati @ 2005-06-20 14:56 UTC (permalink / raw)
To: Srinivas G.; +Cc: linux-kernel-Mailing-list
On Mon, 20 Jun 2005 20:28:26 +0530
"Srinivas G." <srinivasg@esntechnologies.co.in> wrote:
> Dear All,
>
> I am very sorry for asking such a silly question here.
>
> I have small doubt about ASM code in a C program. Actually I want to
> insert some asm instructions in a C program and after that I want to
> compile the C program.
>
> ...
>
> Please let me know how to do it?
>
> Any links or Howtos are welcome.
> Thanks in advance.
http://www-106.ibm.com/developerworks/library/l-ia.html
--
Paolo Ornati
Linux 2.6.12 on x86_64
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: how to insert an asm instruction in C code and how to compile it
2005-06-20 14:58 how to insert an asm instruction in C code and how to compile it Srinivas G.
2005-06-20 14:56 ` Paolo Ornati
@ 2005-06-20 14:57 ` Mads Martin Joergensen
2005-06-20 15:40 ` Richard B. Johnson
2 siblings, 0 replies; 4+ messages in thread
From: Mads Martin Joergensen @ 2005-06-20 14:57 UTC (permalink / raw)
To: Srinivas G.; +Cc: linux-kernel-Mailing-list
* Srinivas G. <srinivasg@esntechnologies.co.in> [Jun 20. 2005 16:52]:
> I am very sorry for asking such a silly question here.
>
> I have small doubt about ASM code in a C program. Actually I want to
> insert some asm instructions in a C program and after that I want to
> compile the C program.
>
> I want to include the following code in a simple C program and compile
> it.
>
> #define printf DbgPrint
>
> int main()
> {
> printf("Hello world program!\n");
> return 0;
> }
> void DbgPrint(char* str,...)
> {
> volatile USHORT i = 0;
> volatile UCHAR sch;
> while(str[i])
> {
> sch = str[i];
> i ++;
> asm mov ah,0x0E;
> asm mov al,sch;
>
> asm cmp al,0ah
> asm jne test
> asm mov al,0dh //; new line
> asm mov bx,07h
> asm int 10h
> asm mov al,0ah
> test:
> asm mov bx,0x07
> asm int 0x10
> }
> }
>
> Please let me know how to do it?
http://www.int80h.org/
--
Mads Martin Joergensen, http://mmj.dk
"Why make things difficult, when it is possible to make them cryptic
and totally illogical, with just a little bit more effort?"
-- A. P. J.
^ permalink raw reply [flat|nested] 4+ messages in thread
* how to insert an asm instruction in C code and how to compile it
@ 2005-06-20 14:58 Srinivas G.
2005-06-20 14:56 ` Paolo Ornati
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Srinivas G. @ 2005-06-20 14:58 UTC (permalink / raw)
To: linux-kernel-Mailing-list
Dear All,
I am very sorry for asking such a silly question here.
I have small doubt about ASM code in a C program. Actually I want to
insert some asm instructions in a C program and after that I want to
compile the C program.
I want to include the following code in a simple C program and compile
it.
#define printf DbgPrint
int main()
{
printf("Hello world program!\n");
return 0;
}
void DbgPrint(char* str,...)
{
volatile USHORT i = 0;
volatile UCHAR sch;
while(str[i])
{
sch = str[i];
i ++;
asm mov ah,0x0E;
asm mov al,sch;
asm cmp al,0ah
asm jne test
asm mov al,0dh //; new line
asm mov bx,07h
asm int 10h
asm mov al,0ah
test:
asm mov bx,0x07
asm int 0x10
}
}
Please let me know how to do it?
Any links or Howtos are welcome.
Thanks in advance.
Regards,
Srinivas G
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: how to insert an asm instruction in C code and how to compile it
2005-06-20 14:58 how to insert an asm instruction in C code and how to compile it Srinivas G.
2005-06-20 14:56 ` Paolo Ornati
2005-06-20 14:57 ` Mads Martin Joergensen
@ 2005-06-20 15:40 ` Richard B. Johnson
2 siblings, 0 replies; 4+ messages in thread
From: Richard B. Johnson @ 2005-06-20 15:40 UTC (permalink / raw)
To: Srinivas G.; +Cc: linux-kernel-Mailing-list
On Mon, 20 Jun 2005, Srinivas G. wrote:
> Dear All,
>
> I am very sorry for asking such a silly question here.
>
> I have small doubt about ASM code in a C program. Actually I want to
> insert some asm instructions in a C program and after that I want to
> compile the C program.
>
> I want to include the following code in a simple C program and compile
> it.
>
Well, even if you could make the correct assembly, you would
not be able to run the BIOS-based program that you show. As
soon as you execute the interrupt 0x10, your program will seg-fault
because it is an invalid instruction in user-mode code and
would even cause an invalid oprand fault in kernel mode.
The second problem with your code is that __all__ of the assembly
for the entire procedure must be written in one block, not
with seperate "asm" instructions. This is because 'C' isn't
going to preserve the values in the registers between "asm"
blocks.
> #define printf DbgPrint
>
> int main()
> {
> printf("Hello world program!\n");
> return 0;
> }
> void DbgPrint(char* str,...)
> {
> volatile USHORT i = 0;
> volatile UCHAR sch;
> while(str[i])
> {
> sch = str[i];
> i ++;
> asm mov ah,0x0E;
> asm mov al,sch;
>
> asm cmp al,0ah
> asm jne test
> asm mov al,0dh //; new line
> asm mov bx,07h
> asm int 10h
> asm mov al,0ah
> test:
> asm mov bx,0x07
> asm int 0x10
> }
> }
>
> Please let me know how to do it?
>
> Any links or Howtos are welcome.
> Thanks in advance.
>
> Regards,
> Srinivas G
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
Cheers,
Dick Johnson
Penguin : Linux version 2.6.12 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-06-20 15:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-20 14:58 how to insert an asm instruction in C code and how to compile it Srinivas G.
2005-06-20 14:56 ` Paolo Ornati
2005-06-20 14:57 ` Mads Martin Joergensen
2005-06-20 15:40 ` Richard B. Johnson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®