Difference between "move" and "li" in MIPS assembly language

user2492270

I was practicing converting C code into MIPS assembly language, and am having trouble understanding the usage of move and li in variable assignment.

For example, to implement the following C line in MIPS:

int x = 0;

If I understand it correctly (I highly doubt this, though), it looks like both of these work in MIPS assembler:

move $s0, $zero
li $s0, $zero

Am I wrong? What is the difference between these two lines?

duskwuff -inactive-

The move instruction copies a value from one register to another. The li instruction loads a specific numeric value into that register.

For the specific case of zero, you can use either the constant zero or the zero register to get that:

move $s0, $zero
li   $s0, 0

There's no register that generates a value other than zero, though, so you'd have to use li if you wanted some other number, like:

li $s0, 12345678

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Difference between ISA (e.g. MIPS) and Assembly language

From Dev

Difference between ISA (e.g. MIPS) and Assembly language

From Dev

Difference between "addi" and "add" for pseudoinstruction "move" in MIPS?

From Dev

MIPS Assembly language traversing an array

From Dev

Converting C code to MIPS Assembly Language

From Dev

Move Li between <ul>

From Dev

Converting from C Loop to MIPS assembly language (bad address error)

From Dev

MIPS assembly language - temporary register vs saved registers

From Dev

Why do we use .globl main in MIPS assembly language?

From Dev

How do you define constants in the MIPS assembly language?

From Dev

What is the difference between assembly language of x86 and x64 architecture?

From Dev

Difference Between ? and ! in Swift Language?

From Dev

What is the difference between assembly on mac and assembly on linux?

From Dev

what is the difference/similarity between MIPS and FLOPS?

From Dev

Difference between adding 0 and moving a register in MIPS

From Dev

Difference between assembly zero and equal

From Dev

Difference between increment and add in assembly

From Dev

Difference between two assembly code

From Dev

Difference Between Assembly Name, Assembly Information Title, and Assembly Information Product?

From Java

What is the difference between `|_| async move {}` and `async move |_| {}`

From Dev

Difference between the move assignment operator and move constructor?

From Dev

Is there in difference in parsing an assembly language and a high-level programming language?

From Dev

Move li tag between sortable programmatically

From Dev

difference between meta language and markup language?

From Dev

Assembly language IA32 - move char to int

From Dev

Assembly language IA32 - move char to int

From Dev

Assembly Files: Difference between .a .s .asm

From Dev

Difference between label and fuction in assembly - Intel syntax

From Dev

what is the difference between SETA and EQU in arm assembly?

Related Related

  1. 1

    Difference between ISA (e.g. MIPS) and Assembly language

  2. 2

    Difference between ISA (e.g. MIPS) and Assembly language

  3. 3

    Difference between "addi" and "add" for pseudoinstruction "move" in MIPS?

  4. 4

    MIPS Assembly language traversing an array

  5. 5

    Converting C code to MIPS Assembly Language

  6. 6

    Move Li between <ul>

  7. 7

    Converting from C Loop to MIPS assembly language (bad address error)

  8. 8

    MIPS assembly language - temporary register vs saved registers

  9. 9

    Why do we use .globl main in MIPS assembly language?

  10. 10

    How do you define constants in the MIPS assembly language?

  11. 11

    What is the difference between assembly language of x86 and x64 architecture?

  12. 12

    Difference Between ? and ! in Swift Language?

  13. 13

    What is the difference between assembly on mac and assembly on linux?

  14. 14

    what is the difference/similarity between MIPS and FLOPS?

  15. 15

    Difference between adding 0 and moving a register in MIPS

  16. 16

    Difference between assembly zero and equal

  17. 17

    Difference between increment and add in assembly

  18. 18

    Difference between two assembly code

  19. 19

    Difference Between Assembly Name, Assembly Information Title, and Assembly Information Product?

  20. 20

    What is the difference between `|_| async move {}` and `async move |_| {}`

  21. 21

    Difference between the move assignment operator and move constructor?

  22. 22

    Is there in difference in parsing an assembly language and a high-level programming language?

  23. 23

    Move li tag between sortable programmatically

  24. 24

    difference between meta language and markup language?

  25. 25

    Assembly language IA32 - move char to int

  26. 26

    Assembly language IA32 - move char to int

  27. 27

    Assembly Files: Difference between .a .s .asm

  28. 28

    Difference between label and fuction in assembly - Intel syntax

  29. 29

    what is the difference between SETA and EQU in arm assembly?

HotTag

Archive