English 中文(简体)
显示数字负数,因为导致MIPS
原标题:Show negative number as substraction result in MIPS

I m coding a small program in MIPS assambler. Given my age the program do the 4 mathematical operations (addition, substraction...).

如果年龄(29岁),结果应为——7岁(2-9=-7),但显示为7岁。

我如何使科索沃警察部队显示次行动中的负面数字?

提前感谢。

    .globl main

    .data
mensaje:    .asciiz "Hola, mi nombre es Angel Pérez.
Hasta hace poco mi edad era 29 años.
¿Que pasa si aplico las 4 operaciones matematicas a esos dos numeros...?

"
suma:       .asciiz "2 mas 9 es igual a: "
resta:      .asciiz "2 menos 9 es igual a: "
multiplicacion: .asciiz "2 por 9 es igual a: "
division:   .asciiz "2 entre 9 es igual a: "
nueva_linea:    .asciiz "
"
.text

main:
     la $a0, mensaje
     li $v0, 4
     syscall

     la $a0, suma
     li $v0, 4
     syscall

     li $t1, 2
     li $t2, 9

     li $v0, 1
     add $t0,$t2,$t1
     move $a0,$t0
     syscall

     la $a0, nueva_linea
     li $v0, 4
     syscall

     la $a0, resta
     li $v0, 4
     syscall

     li $v0, 1
     sub $t0,$t2,$t1
     move $a0,$t0
     syscall

     la $a0, nueva_linea
     li $v0, 4
     syscall

     la $a0, multiplicacion
     li $v0, 4
     syscall

     li $v0, 1
     mul $t0,$t2,$t1
     move $a0,$t0
     syscall

     li $v0, 10
     syscall
最佳回答

后继命令是错误的:

sub $t0,$t2,$t1

阁下,9-2

sub $t0,$t1,$t2

is what you need.

问题回答

你们期望9-2返回的是什么? <代码>下的两条操作录用。 其他业务也无意中演奏,但它们是互换的。





相关问题
List of suspected Malicious patterns

I am doing an anti-virus project by disassembling its code and analyzing it. So I want a list of the Suspected Malicious pattern codes, so I can observe which is suspected and which is not? So I want ...

Prefetch for Intel Core 2 Duo

Has anyone had experience using prefetch instructions for the Core 2 Duo processor? I ve been using the (standard?) prefetch set (prefetchnta, prefetcht1, etc) with success for a series of P4 ...

How are mutex and lock structures implemented?

I understand the concept of locks, mutex and other synchronization structures, but how are they implemented? Are they provided by the OS, or are these structures dependent on special CPU instructions ...

Installing GNU Assembler in OSX

No matter how hard I google, I can t seem to find a (relatively) easy-to-follow instruction on how to install the GNU Assembler on a mac. I know I can use gcc -c (Apple Clang on a Mac) to assemble .s ...

8086 assembler,INT 16,2

I got stuck at this thing,I want to see if right shift button has been pressed,so I have this assambler code: mov ah,2 int 16h ;calling INT 16,2 - Read Keyboard Flags interrupt mov ah,...

Translate a FOR to assembler

I need to translate what is commented within the method, to assembler. I have a roughly idea, but can t. Anyone can help me please? Is for an Intel x32 architecture: int secuencia ( int n, ...

热门标签