Page 1 of 1

[Solved] Tysila + REX prefix = invalid in i586 mode

Posted: Wed Sep 11, 2013 10:09 pm
by mahibak
Greetings,

I did the Bare Bones C# tutorial with success on an Ubuntu VM. I can successfully launch QEMU, and display text. I did some modifications, then Tysila told me the following:

Code: Select all

Error: REX prefix invalid in i586 mode
I was confused, took a look at the wiki, found nothing that could help me. I then proceeded to remove all possible code that wasn't useful to reproduce the error. I got the following:

kernel.cs:

Code: Select all

namespace OS
{
    class Program
    {
        unsafe static void Main()
        {
            string s3 = "s3";
        }
    }
}
Compiling with GMCS or Tybuild won't change anything. My loader.asm, linker.ld, grub.cfg is like in the Bare Bones tutorial.

Here's my batch file to compile the project and launch emulation:

Code: Select all

#!/bin/bash
nasm -felf -o bin/loader.o source/loader.asm
gmcs /target:exe /out:bin/kernel.exe /unsafe source/*.cs
tysila2.exe --arch i586-elf-tysos -fno-rtti -o bin/kernel.o bin/kernel.exe
ld -m elf_i386 -T source/linker.ld -o iso/kernel.bin bin/loader.o bin/kernel.o
grub-mkrescue -o bin/barebones.iso iso
qemu-system-i386 -cdrom bin/barebones.iso
I get the following output in the terminal:

Code: Select all

source/kernel.cs(7,20): warning CS0219: The variable `s3' is assigned but its value is never used
Compilation succeeded - 1 warning(s)
Assembling Method: static void Main()
  in Type: OS.Program
Error: REX prefix invalid in i586 mode
What can I do to remove this error? Thanks!

Re: Tysila + REX prefix = invalid in i586 mode

Posted: Wed Sep 11, 2013 10:37 pm
by dozniak
Hmm, looks like it generates 64 bit code in gmcs?

Re: Tysila + REX prefix = invalid in i586 mode

Posted: Wed Sep 11, 2013 10:45 pm
by mahibak
The GMCS manual says that the Mono runtime can only emit code for x86 and anycpu assembles (specified with the -platform argument). I added -platform x86, the error is still there.

Re: Tysila + REX prefix = invalid in i586 mode

Posted: Thu Sep 12, 2013 3:49 am
by jnc100
Thanks, I'll look into it.

Regards,
John.



edit: I've fixed the error you found and updated the code and binaries in the repository. The i586 port is still a work in progress and sometimes still incorrectly ouputs x86_64 code. The REX error you've seen is basically a message to me saying 'at some point in the code an x86_64 opcode was outputted incorrectly'. I'd imagine if you want to still use 32 bit code then you may find more errors like this: in which case please let me know and I'll try and fix them. You can contact me directly rather than using the boards if you like.

Regards,
John.