龙芯的 Helloworld :)

国际惯例,学习一门新的语言,要从 Hello World 开始,下面我们用龙芯的汇编编写一个Hello world程序,代码用gcc编译:

.text                   
    .globl main  
    .ent    main  
main:                   
    lui     $4, %hi(cmd) 
    addiu $4, $4, %lo(cmd) 

    lui     $5, %hi(argv)  
    addiu $5, $5, %lo(argv) 

    move $6, $0            
    li      $2, 4011       
    syscall                

    move $2, $0       
    jr      $31            

.end main        

    .data              
cmd:    
    .asciiz "/bin/echo"
msg:
      .asciiz "Hello world!"

argv:
  .word   cmd
  .word   msg 
  .word   0x0
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License