In order to compile the program on the computer composition and design-hardware/software interface, however, GCC on UbuntuX86 can only be compiled into the X86 assembly.
Sourcery codebench out a gcc toolchain for compiling to the MIPS assembler.
Our usual compilation, called Local compilation, is compiled into a compilation under the current platform. Instead, cross-compilation can be compiled into other platforms (the platform of the compiled platform is not the same as that of the compiled program)
Sourcery Codebench has paid version and free version, I use the free version.
Https://sourcery.mentor.com/GNUToolchain/subscription3537?lite=MIPS
Find here to download the latest version.
Available in two versions: Gnu/linux version and Elf version
I downloaded the https://sourcery.mentor.com/GNUToolchain/release3133.
Reference Document: Https://sourcery.mentor.com/GNUToolchain/doc22952/getting-started.pdf
Two version differences see bottom note 1.
Right-click on the executable permission.
Command line execution
$./mips-2015.11-32-mips-linux-gnu.bin
But it can't be done. Ask for a variety of documents and questions. Find a solution: https://sourcery.mentor.com/GNUToolchain/kbentry62
Since 12.04 Ubuntu introduced Multi Arch (https://wiki.ubuntu.com/MultiarchSpec) and removed ia32-libs ia32-libs-gtk pack Ages from the repository. To install 32-bit Libs your need the run the following command line
Ubuntu removed the 32-bit library after 12.04, so we had to install
The command line is as follows:
$ sudo dpkg--add-architecture i386
$ sudo apt-get update
$ sudo apt-get install libgtk2.0-0:i386 libxtst6:i386 GT k2-engines-murrine:i386 lib32stdc++6 libxt6:i386 libdbus-glib-1-2:i386 libasound2:i386
If it is not possible to install, "Hash checksum does not match" or "failure occurs, this may be the reason that a package is required to maintain the status quo." , skip to the last note, 2.
After installing the 32-bit library, we can open the file to the bin.
Then follow the instructions to install it. Ubuntu words, cancel the build icon on the desktop.
If you fail to quit, run again, and install in the same directory.
After installation, restart, command line input mips-linux-gnu-gcc-v can see the results.
mips-parameters are visible https://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html
#include <stdio.h>
int main () {
printf ("Hello");
}
. File 1 "hello.c"
. Section. mdebug.abi32
. Previous
. Nan legacy
. module fp=32
. Module oddspreg
. abicalls.
option pic0
. Rdata
. Align 2
$LC 0:
. ASCII "hello\000"
. Text
. Align 2
. Globl main
. Set nomips16
. Set nomicromips
ent main
. Type Main, @function
main:
. Frame $fp, 32,$31 # vars= 0, regs= 2/0, args=, gp= 8
. Mask 0xc0000000,-4
. Fmask 0x00000000,0
. Set noreorder
. Set nomacro
addiu $sp, $SP, -32
SW $31,28 ($SP)
SW $fp, ($SP)
move $fp, $sp
lui $2,%hi ($LC 0)
addiu $4,$2,%lo ($LC 0)
Jal printf
NOP
Move $2,$0
move $sp, $fp
LW $31,28 ($sp)
LW $fp, ($SP)
Addiu $sp, $sp,
J $31
nop
. Set macro
. Set reorder
. End Main
. Size Main,.-main
. Ident "GCC: (sourcery codebench Lite 2015.11-32) 5.2.0"
Reference: https://sourcery.mentor.com/GNUToolchain/release3136
Http://askubuntu.com/questions/463457/how-to-find-packages-when-updating-ubuntu-and-creating-standard-source-list-file
Http://www.tuicool.com/articles/nAJJVj
Http://www.cnblogs.com/zhangpengshou/archive/2009/12/05/1617719.html
http://imgtec.eetrend.com/forum/2371
Note one:
Note 2: This happens because of the wall. Re-select the new source and refer to this second http://www.cnblogs.com/memory4young/p/ubuntu-apt-get-update-error-hash-sum-mismatch.html
Finally, he gave me the choice of a Hong Kong source. I don't know if it's the reason I modified the hosts.