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

Initial commit

parent bf72e810
No related merge requests found
Alea.s 0 → 100644
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2016 Maxime Schmitt <max.schmitt@math.unistra.fr>
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
# 0. You just DO WHAT THE FUCK YOU WANT TO.
.data
seed: .word 0xfaceb00c, 0xdeadbeef
max_float_alea: .float 2147483647
.text
.globl __start
# Point d'entrée du programme
__start:
li $a0, 0
li $a1, 101
jal nombre_alea_entre_deux_bornes
move $a0, $v0
li $v0, 1
syscall
j exit
# Retourne un nombre aléatoire inclus dans l'intervalle [$a0,$a1[
# Paramètres : a passé dans $a0 et b passé dans $a1
# Pré-conditions : 0 <= $a0 < $a1
# Résultat : le nombre aléatoire dans le registre $v0
nombre_alea_entre_deux_bornes:
# Prologue
subu $sp, $sp, 12
sw $ra, ($sp)
swc1 $f0, 4($sp)
swc1 $f1, 8($sp)
# Corps
jal random_generator
andi $v0, $v0, 0x7fffffff
mtc1 $v0, $f0
cvt.s.w $f0, $f0
lwc1 $f1, max_float_alea
div.s $f0, $f0, $f1
sub $a1, $a1, $a0
mtc1 $a1, $f1
cvt.s.w $f1, $f1
mul.s $f0, $f0, $f1
mtc1 $a0, $f1
cvt.s.w $f1, $f1
add.s $f0, $f0, $f1
cvt.w.s $f0, $f0
mfc1 $v0, $f0
# Épilogue
lw $ra, ($sp)
lwc1 $f0, 4($sp)
lwc1 $f1, 8($sp)
addu $sp, $sp, 12
jr $ra
# Function random_generator
# Retourne un nombre aléatoire entre 0 et 2^32-1
# Paramètres :
# Résultat : Le nombre aléatoire dans $v0
random_generator:
# Prologue
# Corps
lw $t0, seed
andi $t1, $t0, 65535
mulu $t1, $t1, 36969
srl $t2, $t0, 16
addu $t0, $t1, $t2
lw $t1, seed+4
andi $t2, $t1, 65535
mulu $t2, $t2, 18000
srl $t3, $t1, 16
addu $t1 $t2, $t3
sw $t0, seed
sw $t1, seed+4
sll $v0, $t0, 16
addu $v0, $v0, $t1
# Épilogue
jr $ra
exit:
li $v0, 10
syscall
# http://courses.missouristate.edu/kenvollmar/mars/Help/MarsHelpCommand.html
.data
usage: .asciiz "Usage: java -jar Mars4_5.jar arguments.s pa <arg1> <arg2> [arg3]... [argN]"
nb_arg_is: .asciiz "Le nombre d'arguments est "
arg1_is: .asciiz "\nLe premier argument est "
arg2_is: .asciiz "\nLe deuxieme argument est "
.text
__start:
move $t0 $a0 #t0 contient le nombre d'arguments
move $t1 $a1 #t1 contient l'adresse d'un tableau de pointeurs vers les arguments
blt $t0 2 PrintUsage # Erreur si argc < 2
la $a0 nb_arg_is
li $v0 4
syscall # Affichage
move $a0 $t0
li $v0 1
syscall # print(argc)
la $a0 arg1_is
li $v0 4
syscall # Affichage
lw $t2 ($t1)
la $a0 0($t2)
li $v0 4
syscall # print(argv[0])
la $a0 arg2_is
li $v0 4
syscall # Affichage
lw $t2 4($t1)
la $a0 0($t2)
li $v0 4
syscall # print(argv[1])
j Exit
PrintUsage:
la $a0 usage
li $v0 4
syscall
j Exit
Exit:
li $v0 10 # appel système 10 -> fin du programme
syscall
05
29 03 09 03 43
11 10 10 10 10
10 10 10 10 10
10 10 10 10 10
12 04 06 12 06
main.s 0 → 100644
.data:
request: .asciiz "Please enter an N such that 1*10n is your goal: "
result: .asciiz "the result is: "
.text:
main:
li $a0 01101001
continue:
j Exit
cell_lecture_bit:
#the function cell_lecture_bit takes an int coded on 32 bytes,
li $t0, 31
sub $a1, $t0, $a1 # modify the value to get a shift of 31 -I digits
sllv $a0, $a0,$a1
srl $a0, $a0,31
jr $ra
sub_pow_10: #sub function used to init pow_10
li $a1,1
j pow_10
pow_10: #function to get the 10**n for a given n
beq $a0,$zero,continue ##rename for loop later in the code
li $a2, 10
mul $a1, $a1,$a2
addi $a0,$a0,-1
b pow_10
Exit:
li $v0, 10
syscall
1)laby carré de taille n * n
2)chaque cellule a 2,3 ou 4 cellules voisines
3) laby parfait, donc pas plus d'un chemin
4) entrée utilisateur
5) entrée XX sortie 00, @ mur
6)faut verif si c'est
entree
sortie
si voisins sont soit
7) au moins 2 murs possible 3
8)celulles codée sur 8 bits
b7 b6 B5 b4 b3 b2 b1 b0
libre libre fin depart mg mb md mh
9) PASSER IMMEDIATEMENT L'ADDRESSE DU TAB DANS UN SI
addr = baseaddr +(rowindex * colindex +collndex) * 4
10)choix en ligne et non column
1)laby carré de taille n * n
2)chaque cellule a 2,3 ou 4 cellules voisines
3) laby parfait, donc pas plus d'un chemin
4) entrée utilisateur N (taille laby)
5) entrée XX sortie 00, @ mur
6)faut verif si c'est
entree
sortie
si voisins sont soit
7)au moins 2 murs possible 3
8)celulles codée sur 8 bits
b7 b6 B5 b4 b3 b2 b1 b0
libre libre fin depart mg mb md mh
9) PASSER IMMEDIATEMENT L'ADDRESSE DU TAB DANS UN SI
addr = baseaddr +(rowindex * colindex +collndex) * 4
10)choix en ligne et non column
11)
depart en haut a gauche
fin en bas a droite
#!/bin/sh
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2016 Maxime Schmitt <max.schmitt@math.unistra.fr>
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
# 0. You just DO WHAT THE FUCK YOU WANT TO.
if [ $# -ne 1 ]
then
echo "Usage: $0 <maze_file.txt>"
exit 1
fi
awk '
function extract_powerof_two(value, power) {
return int(value/power)%2
}
function has_right(value) {
return extract_powerof_two(value, 2)
}
function has_bottom(value) {
return extract_powerof_two(value, 4)
}
function is_starting_point(value) {
return extract_powerof_two(value, 16)
}
function is_ending_point(value) {
return extract_powerof_two(value, 32)
}
function can_i_go_out_this_way(value) {
return extract_powerof_two(value, 64)
}
NR == 1 { x = $1; for (i=0; i < 3*x+1; ++i) printf "@"; print ""}
NR > 1 {
printf "@"
for (i=1; i<=NF; i++) {
if (is_starting_point($i))
printf "XX"
else
if (is_ending_point($i))
printf "OO"
else
if (can_i_go_out_this_way($i))
printf "░░"
else
printf " "
if (has_right($i))
printf "@"
else
printf " "
}
print ""
for (i=1; i<=NF; i++) {
printf "@"
if (has_bottom($i))
printf "@@"
else
printf " "
}
print "@"
}
' $1
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