Vous pouvez copier (copy & paste) les algos en Language Machine et les faire fonctioner dans l'Applet Java du simulateur de LMC donne sur la page Web du cours; soit celle de Petter Higginson ou soit celle de 101computing. Dans les deux applets il faut remplacer: IN par INP BR par BRA BZ par BRZ BP par BRP STO par STA ATTENTION : l'instruction STA telle qu'ell a ete definie dans le cours n'EXISTE PAS dans ces deux applets (ni les instructions MUL ET DIV) ! L'instruction STA, dans ces deux applets, est l'instruction STO vu en cours. ================= Final IFT1215 H07 ================= ------------ Question I.1 ------------ INP STA bornesup LDA valn OUT LDA valnp1 OUT loop LDA valnp1 ADD valn OUT STA temp LDA valnp1 STA valn LDA temp STA valnp1 LDA bornesup SUB valnp1 SUB un BRP loop end HLT valn DAT 0 valnp1 DAT 1 temp DAT 1 bornesup DAT 0 un DAT 1 ------------ Question I.2 ------------ INP STA nb INP STA cmp loop LDA res OUT ADD three OUT SUB two OUT STA res SUB cmp BRZ end LDA cpt ADD one STA cpt SUB nb BRP loop end HLT nb DAT 0 cmp DAT 0 three DAT 3 two DAT 2 one DAT 1 res DAT 1 cpt DAT 0 ------------ Question I.3 ------------ J'ai remplace dans ce programme l'instruction STA (qui n'EXISTE PAS dans ces deux applets) par deux instructions equivalentes (dans ce cas particulier) telle qu'il a ete dit dans la correction de l'examen INP STA ad1 INP STO ad2 LDA ad1 loop ADD trcen STA dtinst loop LDA zero dtinst STA tem LDA ad1 ADD one STA ad1 SUB ad2 BRZ stop LDA ad1 BRA loop stop HLT ad1 DAT 0 ad2 DAT 0 one DAT 1 zero DAT 0 tem DAT 0 trcen DAT 300 ------------- Question II.1 ------------- #! /bin/bash # CompressPS.sh script find -name \*.ps | while read line; do echo $line file=${line##/*/} dvifile=${file%.*}.dvi if [ -f $dvifile ]; then echo je pourrais compresser $file fi done #! /bin/BAsh # CompressPS2.sh script find -name \*.ps | while read line do nom=`echo $line | cut -d . -f2 | cut -d "/" -f 2-`.dvi file=`ls $nom` if [ $file ]; then echo je pourrais compresser $file fi done -------------- Question II.2 -------------- #! /bin/bash # ExtractGAM-SNR.sh script File=$1 if [ -f tmp.dat ] then rm tmp.dat fi if [ -f tmp2.dat ] then rm tmp2.dat fi cpt=1 grep "Gamma = " $File | cut -d "=" -f 2 > tmp.dat grep "BEST-MAP" $File | cut -d "=" -f 2 | cut -d "d" -f 1 > tmp2.dat cat tmp.dat | while read line do secondline=`head -n $cpt tmp2.dat | tail -n 1` echo $line $secondline let cpt=cpt+1 done #! /bin/bash # ExtractGAM-SNR2.sh script cat $1 | while read line; do a1=`echo $line | grep Gamma | cut -d = -f 2` a2=`echo $line | grep BEST | cut -d = -f 2 | cut -d d -f 1` if [ $a1 ]; then echo -n $a1 fi if [ $a2 ]; then echo " $a2" fi done #! /bin/bash # ExtractGAM-SNR3.sh script cat $1 | while read line; do for nm in Gamma BEST; do coord=`echo $line | grep $nm | cut -d = -f 2 | cut -d d -f 1` if [ $coord ]; then echo -n " $coord" && if [ $nm == BEST ]; then echo "" fi fi done done