Skip to content
Snippets Groups Projects
Commit 28f80162 authored by ACIKBAS TUNA's avatar ACIKBAS TUNA
Browse files

no commentary code

parent 66477a03
No related merge requests found
......@@ -5,15 +5,14 @@
main:
li $a0,1010101
li $a1,1#stocker dans a1 le i=3, c'est a dire on met le bit d'index 3 de 0 a 1
jal cell_lecture_bit
li $a0,29
li $a1,7#stocker dans a1 le i=3, c'est a dire on met le bit d'index 3 de 0 a 1
jal changer_bit
move $a0 $v0
li $v0 1
syscall
j continue
#coucou tuna
continue:
j Exit
......@@ -24,9 +23,10 @@ continue:
cell_lecture_bit:
srlv $a0,$a0,$a1
li $t0,2
div $a0,$t0
move $t0, $a0
srlv $t0,$t0,$a1
li $t1,2
div $t0,$t1
mfhi $v0 #moves from hi register: le registre lo contient le quotient de la divison, et le registre hi contient le reste de la division entière
#lw $ra,0($sp)
jr $ra
......@@ -38,37 +38,6 @@ cell_lecture_bit:
# modify the value to get a shift of 31 -I digits
cell_mettre_bit_a1:
#a1 contains the value of i, which is the index of the bit we want to change into one or into zero
#a0 contains the number of the cell
#v0 contains the result
li $t1,1 #store 1 in t1
sllv $t1,$t1,$a1
add $a0,$a0,$t1
move $v0,$a0
jr $ra
cell_mettre_bit_a0:
li $t1,1
sllv $t1,$t1,$a1
sub $a0,$a0,$t1
move $v0,$a0
sub_pow_10: #sub function used to init pow_10
li $a1,1
li $a0 4
jal sub_pow_init
move $a0 $v1
j Exit
changer_bit:
......@@ -77,17 +46,16 @@ changer_bit:
addi $sp $sp -8
sw $ra 0($sp)
beq $a1, $zero, bit_a1
jal cell_lecture_bit
move $a2, $v0
beq $a2, $zero, bit_a1
j bit_a0
bit_a0:
jal sub_pow_init
move $t0 $v0 #t1 contient la valeur a soustraire
li $v1 1
syscall
j Exit
li $t0,1
sllv $t0,$t0, $a1
#a1 : indice de decalage
sub $a0, $a0, $t0
move $v0 $a0
j retour_main
......@@ -96,31 +64,16 @@ bit_a0:
bit_a1:
jal sub_pow_init
move $t0 $v0 #t1 contient la valeur a soustraire
li $t0,1
sllv $t0,$t0, $a1
add $a0, $a0, $t0
move $v0 $a0
j retour_main
sub_pow_init:
sw $ra 4($sp)
li $v0, 1
pow_10: #function to get the 10**n for a given n
#prolog
#mettre l'addresse de Ra dans la pile sp
beq $a1,$zero,retour_fonc##rename for loop later in the code
li $a2, 10
mul $v0, $v0,$a2 #retourene la puissance de 10 dans v0
addi $a1,$a1,-1
b pow_10
retour_main:
lw $ra 0($sp)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment