Assember error: junk `%dx' after register

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
DeepakRaj
Posts: 4
Joined: Thu Nov 29, 2012 3:23 am

Assember error: junk `%dx' after register

Post by DeepakRaj »

Hi

I'm following Bran's Kernel Development Tutorials.

I have done with the bare bone start up file in assembly, a linker script and a main.c file for basic functions, a batch file to compile and link.

Problem : When I run the batch file build.bat it shows the following assembler message:

main.c:49:6: warning: return type of 'main' is not 'int' [-Wmain]
/tmp/ccobm6mp.s: Assembler messages:
/tmp/ccobm6mp.s:121: Error: junk `%al' after register
/tmp/ccobm6mp.s:137: Error: junk `%dx' after register

Command that are there in build.bat are as following

$: nasm -f elf -o start.o start.asm
$: i586-elf-gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c
$: i586-elf-ld -T link.ld -o kernel.bin start.o

Help with the error. Please.
I'm a trying the kernel development for the first time. And I know that there may be several flaws in the code. Please suggest what kind of improvement can be made on the same.
I'll be thankful for all the suggestions.
Attachments
link.ld
(358 Bytes) Downloaded 60 times
main.c
(926 Bytes) Downloaded 54 times
start.asm
(1.93 KiB) Downloaded 40 times
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Assember error: junk `%dx' after register

Post by Brendan »

Hi,
DeepakRaj wrote:Problem : When I run the batch file build.bat it shows the following assembler message:

main.c:49:6: warning: return type of 'main' is not 'int' [-Wmain]
/tmp/ccobm6mp.s: Assembler messages:
/tmp/ccobm6mp.s:121: Error: junk `%al' after register
/tmp/ccobm6mp.s:137: Error: junk `%dx' after register
You failed to cut & paste properly.

From the tutorial itself:

Code: Select all

   __asm__ __volatile__ ("inb %1, %0" : "=a" (rv) : "dN" (_port));
And:

Code: Select all

    __asm__ __volatile__ ("outb %1, %0" : : "dN" (_port), "a" (_data));
From your "main.c":

Code: Select all

	__asm__ __volatile__("inb %1 %0" : "=a" (res) : "Nd" (_port));
And:

Code: Select all

	__asm__ __volatile__("outb %1 %0" : : "Nd" (_port), "a" (_data));
The missing commas are what the assembler is complaining about. It's a bit like doing "foo(first second);" in C when you meant "foo(first, second);".


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
DeepakRaj
Posts: 4
Joined: Thu Nov 29, 2012 3:23 am

Re: Assember error: junk `%dx' after register

Post by DeepakRaj »

Brendan wrote:Hi,
DeepakRaj wrote:Problem : When I run the batch file build.bat it shows the following assembler message:

main.c:49:6: warning: return type of 'main' is not 'int' [-Wmain]
/tmp/ccobm6mp.s: Assembler messages:
/tmp/ccobm6mp.s:121: Error: junk `%al' after register
/tmp/ccobm6mp.s:137: Error: junk `%dx' after register
You failed to cut & paste properly.

From the tutorial itself:

Code: Select all

   __asm__ __volatile__ ("inb %1, %0" : "=a" (rv) : "dN" (_port));
And:

Code: Select all

    __asm__ __volatile__ ("outb %1, %0" : : "dN" (_port), "a" (_data));
From your "main.c":

Code: Select all

	__asm__ __volatile__("inb %1 %0" : "=a" (res) : "Nd" (_port));
And:

Code: Select all

	__asm__ __volatile__("outb %1 %0" : : "Nd" (_port), "a" (_data));
The missing commas are what the assembler is complaining about. It's a bit like doing "foo(first second);" in C when you meant "foo(first, second);".


Cheers,

Brendan
Thanks Brendan.
I guessed it would be something silly like this. Actually I typed it rather than coping.
Thanks once again for the help.
Post Reply