feat: Initial commit
This commit is contained in:
46
Laboratorio7/Esercizio2.asm
Normal file
46
Laboratorio7/Esercizio2.asm
Normal file
@@ -0,0 +1,46 @@
|
||||
.data
|
||||
num: .word 3141592653
|
||||
p: .asciiz "Il numero è palindromo"
|
||||
np: .asciiz "Il numero non è palindromo"
|
||||
|
||||
.text
|
||||
.globl main
|
||||
.ent main
|
||||
main:
|
||||
move $t0, $sp
|
||||
addi $t0, $t0, -4
|
||||
|
||||
read_str:
|
||||
li $v0, 12
|
||||
syscall
|
||||
|
||||
beq $v0, '\n', fine # smetto di saltare quando ho raggiunto un newline
|
||||
addi $sp, $sp, -4
|
||||
sw $v0, 0($sp)
|
||||
j read_str
|
||||
|
||||
fine:
|
||||
|
||||
print:
|
||||
lw $t1, 0($sp)
|
||||
lw $t2, 0($t0)
|
||||
bne $t1, $t2, non_p
|
||||
addi $sp, $sp, 4
|
||||
addi $t0, $t0, -4
|
||||
|
||||
bgt $t0, $sp, print
|
||||
|
||||
la $a0, p
|
||||
li $v0, 4
|
||||
syscall
|
||||
|
||||
j f
|
||||
non_p:
|
||||
la $a0, np
|
||||
li $v0, 4
|
||||
syscall
|
||||
|
||||
f:
|
||||
li $v0, 10
|
||||
syscall
|
||||
.end main
|
||||
Reference in New Issue
Block a user