|
Home > Archive > Unix Programming > October 2006 > Why the below code cannot be compile?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Why the below code cannot be compile?
|
|
| zhengda 2006-09-29, 1:52 pm |
| Hello.
I tried to compile the following code with gcc 3.3.6
unsigned eflags;
asm volatile("
jmp 1f
1: jmp 1f
1: jmp 1f
1: pushfl
jmp 1f
1: jmp 1f
1: jmp 1f
1: popl %0" : "=r" (eflags));
It seems that I have to add \ in the end of every line.
Does gcc have some options which make it compile the code correctly?
This code is from oskit-20020317
With regards
Zheng Da
| |
| mingyanguo 2006-09-30, 1:46 am |
| zhengda wrote:
> Hello.
> I tried to compile the following code with gcc 3.3.6
> unsigned eflags;
> asm volatile("
> jmp 1f
> 1: jmp 1f
> 1: jmp 1f
> 1: pushfl
> jmp 1f
> 1: jmp 1f
> 1: jmp 1f
> 1: popl %0" : "=r" (eflags));
> It seems that I have to add \ in the end of every line.
> Does gcc have some options which make it compile the code correctly?
> This code is from oskit-20020317
>
> With regards
> Zheng Da
you can do it this way
asm volatile("jmp 1f; "
"1: jmp 1f; "
"1: jmp 1f; "
"1: pushfl; "
"jmp 1f; "
"1: jmp 1f; "
"1: jmp 1f; "
"1: popl %0;"
: "=r"(eflags));
C does NOT allow strings to span several lines.
Regards,
MingyanGuo
| |
| zhengda 2006-10-02, 1:43 am |
| mingyanguo wrote:
> zhengda wrote:
>
>
> you can do it this way
> asm volatile("jmp 1f; "
> "1: jmp 1f; "
> "1: jmp 1f; "
> "1: pushfl; "
> "jmp 1f; "
> "1: jmp 1f; "
> "1: jmp 1f; "
> "1: popl %0;"
> : "=r"(eflags));
> C does NOT allow strings to span several lines.
>
> Regards,
> MingyanGuo
>
I try to compile oskit, but get some problems.
But I failed to subscribe its mailing list, and it seems there is no one
on its list. So I hope I can turn here for help.
I compile it, and get the error like:
gcc -c -o base_console_init.o -MD -DHAVE_CONFIG_H -DOSKIT_X86
-DOSKIT_X86_PC -DINDIRECT_OSENV=1 -I. -I../kern/x86 -I../kern/x86/pc
-I../kern/x86/dos -I../kern/x86/i16 -I../kern/x86/pc/i16
-I../kern/x86/dos/i16 -I../kern -I- -I../oskit/c -I.. -I.. -nostdinc
-Wall -fno-strict-aliasing -O2 -g ../kern/x86/pc/base_console_init.c
/tmp/cc5ijuWX.s: Assembler messages:
/tmp/cc5ijuWX.s:155: Error: junk `jmp 1f 1:' after register
I preprocessed base_console_init.c.
cpp kern/x86/pc/base_console_init.c -I. -o tmp.c
I searched in tmp.c and found there were two place having "jmp 1f 1:".
extern __inline void paging_enable(oskit_addr_t pdir)
{
set_cr3(pdir);
asm volatile(" movl %0,%%cr0 jmp 1f 1: " : : "r" (get_cr0()
| 0x80000000));
}
# 179 "oskit/x86/paging.h"
extern __inline void paging_disable(void)
{
asm volatile(" movl %0,%%cr0 jmp 1f 1: " : : "r" (get_cr0()
& ~0x80000000));
set_cr3(0);
}
So what does the error mean?
| |
| mingyanguo 2006-10-16, 1:36 am |
| zhengda wrote:
> mingyanguo wrote:
> I try to compile oskit, but get some problems.
> But I failed to subscribe its mailing list, and it seems there is no one
> on its list. So I hope I can turn here for help.
> I compile it, and get the error like:
> gcc -c -o base_console_init.o -MD -DHAVE_CONFIG_H -DOSKIT_X86
> -DOSKIT_X86_PC -DINDIRECT_OSENV=1 -I. -I../kern/x86 -I../kern/x86/pc
> -I../kern/x86/dos -I../kern/x86/i16 -I../kern/x86/pc/i16
> -I../kern/x86/dos/i16 -I../kern -I- -I../oskit/c -I.. -I.. -nostdinc
> -Wall -fno-strict-aliasing -O2 -g ../kern/x86/pc/base_console_init.c
> /tmp/cc5ijuWX.s: Assembler messages:
> /tmp/cc5ijuWX.s:155: Error: junk `jmp 1f 1:' after register
> I preprocessed base_console_init.c.
> cpp kern/x86/pc/base_console_init.c -I. -o tmp.c
> I searched in tmp.c and found there were two place having "jmp 1f 1:".
> extern __inline void paging_enable(oskit_addr_t pdir)
> {
> set_cr3(pdir);
> asm volatile(" movl %0,%%cr0 jmp 1f 1: " : : "r" (get_cr0()
> | 0x80000000));
> }
> # 179 "oskit/x86/paging.h"
> extern __inline void paging_disable(void)
> {
> asm volatile(" movl %0,%%cr0 jmp 1f 1: " : : "r" (get_cr0()
> & ~0x80000000));
> set_cr3(0);
> }
> So what does the error mean?
change it this way, and have a try
asm volatile("movl %0, %%cr0;"
"jmp 1f; "
"1:"
::"r"(get_cr0() & ~0x8000000));
| |
| Zheng Da 2006-10-21, 1:31 pm |
| I found
asm volatile("movl %0, %%cr0\r\n"
"jmp 1f\r\n"
"1:"
::"r"(get_cr0() & ~0x8000000));
is OK, too. But the problem is that I fixed these problems, I still
can't compile successfully.
Has anyone compile it successfully in Linux?
It seems that the group who developed OSKIT doesn't continue to develop
their project, and there are no people in its mailing list.
mingyanguo write:
> zhengda wrote:
> change it this way, and have a try
>
> asm volatile("movl %0, %%cr0;"
> "jmp 1f; "
> "1:"
> ::"r"(get_cr0() & ~0x8000000));
|
|
|
|
|