Trois code en motorola x68k, sparc et en mips r3000

Soyez le premier à donner votre avis sur cette source.

Snippet vu 10 006 fois - Téléchargée 26 fois

Contenu du snippet

bah , voila s code est le fruit d'un travail mono ki je v1 de le realise
il y a 3 code ecrie dans les 3 assembleur
le premier fais la fonction de Akermane recurssive, la raçine avec une methode simple celle de Newton Raffessone, et le dernier est celui d'un converteur entre base 10,16 et 2 (binaire)
il veux faus les 3 simulateur et je veus assure k'ils sont disponible
il simple et poure n'importe kistion je suis la inform113@hotmail.com

Source / Exemple :


.text#akremann en r3000
main:
#----------------------------------------
 la $a0 msg1
 jal affichemsg
#----------------------------------------
while_m_negative:
 
 la $a0 msg3 
 jal affichemsg

 jal lecturenbre

 bgez $v0 m_positive

 la $a0 msg4
 jal affichemsg

 b while_m_negative
#-----------------------------------------
m_positive:
 move $t2 $v0        #$t2=M
#------------------------------------------
while_n_negative:
 
 la $a0 msg2
 jal affichemsg
 
 jal lecturenbre
 
 bgez $v0 n_positive

 la $a0 msg4
 jal affichemsg
 
 b while_n_negative
#-------------------------------------------
n_positive:
 move $t1 $v0         #t1=N
#------------------------------------------
 la $a0 msg5
 jal affichemsg
 
 move $a0 $t2
 jal affichenbre
 
 la $a0 msg6
 jal affichemsg
 
 move $a0 $t1
 jal affichenbre
 
 la $a0 msg7
 jal affichemsg
 
 li $t3 0
 jal ack             #$t3=Ack(m,n)

 move $a0 $t3
 jal affichenbre
 
 la $a0 msg8
 jal affichemsg

 li $ra 0
 li $v0 10
 syscall
#-----------Fin de programme---------------------
#------------Procedures--------------------------
affichenbre:
 li $v0 1
 syscall
 j $ra 

affichemsg:
 li $v0 4
 syscall
 j $ra

lecturenbre:
 li $v0 5
 syscall
 j $ra

ack:
 beqz $t2 fin 

 beqz $t1 test 

 addi $sp $sp -12
 sw $t1 0($sp)
 sw $t2 4($sp)
 sw $ra 8($sp)
 
 subu $t1 $t1 1
 
 jal ack
 
 lw $ra 8($sp)
 lw $t2 4($sp)
 lw $t1 0($sp)
 
 move $t1 $t3
 subu $t2 $t2 1

 jal ack

 lw $ra 8($sp)
 lw $t2 4($sp)
 lw $t1 0($sp)
 addi $sp $sp 12
 
 j $ra

test:
 sub $sp $sp 4
 sw $ra 0($sp)

 subu $t2 $t2 1 
 li $t1 1
 
 jal ack
 
 lw $ra 0($sp)
 addu $sp $sp 4
 add $t2 $t2 1
 li $t1 0
 j $ra

fin:
 addu $t3 $t1 1
 j $ra
#**********************************************
.data 
 msg1:.asciiz "---------------Fonction de Ackerman----------\n"
 msg2:.asciiz "\nEntree la valeur de N="
 msg3:.asciiz "\nEntree la valeur de M="
 msg4:.asciiz "\nLa valeur doit etre positive au nul"
 msg5:.asciiz "Ack("
 msg6:.asciiz ","
 msg7:.asciiz ")="
 msg8:.asciiz "\n----------------Fin--------------------------\n"

# racine 
.data
mot :.asciiz "entree x="
mot1:.asciiz "la racine est :"
sautligne:.asciiz "\n"
ff:.float 2.00000000
fff:.float 0.00000001
d:.float -1.00000000
dd:.float 0.00000000
ddd:.float 1.00000000
#---------------------------------------
.text
main:
 li $v0 4
 la $a0 mot
 syscall
 li $v0 6
 syscall
 mov.s $f4 $f0
#---------------------------------------
 sub.s $f6 $f6 $f6
 lwc1 $f7 d
 lwc1 $f2 dd
 sub.s $f0 $f0 $f0
#---------------------------------------
loop1:
 mul.s $f8 $f0 $f0
 sub.s $f8 $f8 $f4 
 mov.s $f6 $f0
 c.lt.s $f2 $f8 
 bc1t loop2
 c.eq.s $f8 $f2 
 bc1t fin 
 lwc1 $f9 ddd
 add.s $f7 $f7 $f9
 add.s $f0 $f0 $f9
 b loop1
#---------------------------------------
loop2:
 lwc1 $f5 ff
 mov.s $f0 $f6 
 lwc1 $f6 fff
loop3:
 mul.s $f1 $f0 $f5  #f'(x)
 mul.s $f2 $f0 $f0
 sub.s $f2 $f2 $f4  #f(x)
 div.s $f3 $f2 $f1
 sub.s $f3 $f0 $f3
 sub.s $f7 $f0 $f3
 c.lt.s $f7 $f6  
 bc1t fin1
 mov.s $f0 $f3
 b loop3
fin1:
 mov.s $f12 $f3
 b fink
fin:
 mov.s $f12 $f0
fink:
 li $v0 4
 la $a0 mot1
 syscall
 li $v0 2
 syscall
 la $a0 sautligne
 li $v0 4
 syscall 
 li $v0 10
 syscall
 
#converteur
.text
main:
 la $a0 msg1
 jal affichemsg
lec:
 la $a0 msg2
 jal affichemsg
 jal lecturenbre
 move $s1,$v0
 beq $v0 10 base
 beq $v0 16 base
 beq $v0 2 base
 la $a0 msg5
 jal affichemsg
 b lec
base:
 la $a0 msg3
 jal affichemsg
 jal lecturemsg
 beq $s1 10 base10
 beq $s1 16 base16
#*************************************************
#-------------base 2 comme base de depart----
base2:
 la $t0 nbre
 li $t4 0
 sub $t0 $t0 1
 li $t6 1
#-------------verification de nbre----------- 
vrif2:
 addu $t0 $t0 1
 lb $t1 ($t0)
 beqz $t1 trait2
 beq $t6 8 trait2
 beq $t1 10 trait2  #10=code de \n
 subu $t1 $t1 48
 add $t6 $t6 1
 beq $t1 1 vrif2
 beq $t1 0 vrif2
 la $a0 msg6
 jal affichemsg
 b base
#------------debut de traitment sur le nbre--
trait2:
 la $t0 nbre
 li $t6 1
fin2:
 lb $t1 ($t0)
 beqz $t1 ffin2
 beq $t6 8 ffin22
 addu $t0 $t0 1
 add $t6 $t6 1
 b fin2
ffin22:
 add $t0 $t0 2
ffin2:
 subu $t0 $t0 2
baseres: 
 la $a0 msg7
 jal affichemsg
 jal lecturenbre
 beq $v0 10 to10
 beq $v0 16 to16
 la $a0 msg5
 jal affichemsg
 b baseres
#-----------base 10 comme base de resultat---
to10:
 la $s3 nbre
 move $s4 $s3
 jal convert2to10 
 la $a0 msg8
 jal affichemsg
 move $a0 $t9
 jal affichenbre
 b exit
#----------base 16 comme base de resultat---
to16:
 la $s3 nbre
 jal convert2to16
 la $a0 msg8
 jal affichemsg
 la $a0 res 
 jal affichemsg
 b exit
#*****************************************************
#----------base 10 comme base de depart------------ 
base10:
 sub $a0 $a0 1
 li $t1 0
#-------------verification de nbre-----------------
taille10:
 add $a0 $a0 1
 add $t1 $t1 1
 beq $t1 9 fintaille10   #on a besoi que  de 8 chiffres
 lb $a1 ($a0)
 beqz $a1 fintaille10
 beq $a1 10 fintaille10  #10=code \n
 beq $a1 46 taille11     #46=code . vergule
 
 sub $a1 $a1 48          #pour le vrai nbre
 bgt $a1 -1 taille10    
 blt $a1 10 taille10
 la $a0 msg6
 jal affichemsg
 b base
taille11:
 move $t8 $t1
 li $t7 1
 b taille10
fintaille10:
 bne $t7 1 nonvergule
 move $t1 $t8
nonvergule:
 la $a0 nbre
 li $s7 0
 sub $t1 $t1 2
lm:
 lb $a1 ($a0)
 beq $a1 46 flm
 sub $a1 $a1 48
 beq $t1 -1 flm
 move $s1 $t1
 jal puissance
 sub $t1 $t1 1
 add $a0 $a0 1
 mul $t5 $a1 $t6
 add $s7 $s7 $t5
 b lm
flm: 
 move $s0 $s7
baseres10: 
 la $a0 msg7
 jal affichemsg
 jal lecturenbre
 beq $v0 2 to102
 beq $v0 16 to1016
 la $a0 msg5
 jal affichemsg
 b baseres10 
#------------base 2 comme la base de resultat------- 
to102:
 jal convert10to2
 la $a0 msg8
 jal affichemsg
 la $a0 res
 jal affichemsg
 b exit
#-----------base 16 comme la base de resultat-------
to1016: 
 jal convert10to2
 la $s3 res
 sub $t0 $a1 1
 jal convert2to16
 la $a0 msg8
 jal affichemsg
 la $a0 res
 jal affichemsg
 b exit
#***************************************************
#----------base 16 comme base de depart------------
base16:
#----------vrification de nbre---------------------
 sub $a1 $a1 1
verif16:
 lb $s0 ($a0) 
 beqz $s0 baseres16
 beq $s0 10 baseres16
 blt $s0 48 nonvalide
 bgt $s0 70 nonvalide
 add $a0 $a0 1
 sub $a1 $a1 1
 bne $a1 1 verif16
baseres16: 
 la $a0 msg7
 jal affichemsg
 jal lecturenbre
 beq $v0 2 to162
 beq $v0 10 to1610
 la $a0 msg5
 jal affichemsg
 b baseres16  
nonvalide:
 la $a0 msg6
 jal affichemsg
 b base 
#-----------base 2 comme la base de resultat------
to162:
 la $t0 nbre
 jal convert16to2
 la $a0 msg8
 jal affichemsg
 la $a0 res 
 jal affichemsg
 b exit
#---------base 10 comme la base de resultat------ 
to1610: 
 la $t0 nbre 
 jal convert16to2
 la $a0 res 
dd:
 lb $a1 ($a0)
 beqz $a1 fdd
 add $a0 $a0 1
 b dd
fdd:
 la $s4 res
 sub $t0 $a0 1
 jal convert2to10
 la $a0 msg8
 jal affichemsg
 move $a0 $t9
 jal affichenbre
#***************************************************
exit:
 li $ra 0
 li $v0 10
 syscall
#***************************************************
convert16to2:
  la $s1 res
  la $t1 nbre 
  li $t2 1     
 bv:
  lb $t3 ($t1)
  beq $t3 10 fbv1
  beq $t2 8 fbv0
  add $t2 $t2 1
  add $t1 $t1 1
  b bv
 fbv1:
  sub $t2 $t2 1
 fbv0:
  la $t1 nbre
  add $t1 $t1 $t2

 convchar1:
  beq $t1 $t0 fintrai
  lb $a1 ($t0)   
  add $t0 $t0 1
  bgt $a1 57 convchar2
  sub $a1 $a1 48  
  j eclate

 convchar2:
  sub $a1 $a1 55 
 eclate:
  li $t3,4            
 retour:
  beq $t3,0,convchar1
  and $t2,$a1,8
  bnez $t2,bit1
 bit0:   
  li $a0 48
  sb $a0 ($s1)
  add $s1 $s1 1 
  sll $a1 $a1 1
  sub $t3 $t3 1
  j retour 
 bit1:
  li $a0 49
  sb $a0 ($s1)
  add $s1 $s1 1 
  sll $a1 $a1 1
  sub $t3 $t3 1
  j retour   
 fintrai:
  li $a0 0
  sb $a0 ($s1)
  j $ra
#***************************************************
convert2to16:
  move $s7 $sp
  li $s2 2
 booo:
  li $t5 1
  move $s5 $t0
 tr:
  beq $t5 4 fff 
  beq $s5 $s3 fff
  sub $s5 $s5 1
  add $t5 $t5 1
  b tr
 fff:
  move $s4 $s5
  sub $sp $sp 4
  sw $ra 0($sp)
  jal convert2to10
  lw $ra 0($sp)
  add $sp $sp 4
  bgt $t9 9 fd
  add $t9 $t9 48 
 ss:
  sub $sp $sp 4
  sw $t9 ($sp)
  beq $s5 $s3 sort
  sub $t0 $s5 1
  b booo
 fd:
  beq $t9 10 A
  beq $t9 11 B 
  beq $t9 12 C
  beq $t9 13 D
  beq $t9 14 E
  beq $t9 15 F
  b sort
 A:li $t9 65
   b ss
 B:li $t9 66
   b ss
 C:li $t9 67
   b ss
 D:li $t9 68
   b ss
 E:li $t9 69
   b ss
 F:li $t9 70
   b ss
 sort:
  la $a0 res
 zz:
  lw $t9 ($sp)
  sb $t9 ($a0)
  add $a0 $a0 1
  add $sp $sp 4
  bgt $s7 $sp zz
  li $t7 0
  sb $t7 ($a0)
  j $ra
#***************************************************
convert10to2:
  move $s2 $sp
 trait10:
  rem $s1 $s0 2
  sub $sp $sp 4
  sw $s1 0($sp)
  div $s0 $s0 2
  bgt $s0 0 trait10
  la $a1 res
 loope:
  lw $a0 0($sp)
  add $sp $sp 4
  add $a0 $a0 48
  sb $a0 ($a1)
  add $a1 $a1 1
  bgt $s2 $sp loope
  li $a0 0
  sb $a0 ($a1)
  j $ra
#***************************************************
convert2to10:
  li $t5 0
  li $t9 0
 loop2:
  li $t6 1
  lb $t7 ($t0)
  sub $t7 $t7 48
  beq $t7 0 suiv
  rol $t6 $t6 $t5
  add $t9 $t9 $t6
 suiv:
  add $t5 $t5 1
  beq $t0 $s4 fi
  sub $t0 $t0 1
  b loop2
 fi:
  j $ra
#****************************************************
puissance:
  li $s2 10
  li $t6 1
 pui: 
  sub $s1 $s1 1
  blt $s1 0 finpui
  mul $t6 $t6 $s2
  b pui
 finpui:
  j $ra
#****************************************************
affichemsg:
 li $v0 4
 syscall
 j $ra 
lecturenbre:
 li $v0 5
 syscall
 j $ra
affichenbre:
 li $v0 1
 syscall
 j $ra
lecturemsg:
 la $a0 nbre
 li $a1 9
 li $v0 8
 syscall
 j $ra
#****************************************************
.data
msg1:.asciiz "\n------tp d'Architecture ---------"
msg2:.asciiz "\nEntree la base de depart: "
msg3:.asciiz "\nEntree le nbre: "
msg4:.asciiz "Entree la base d'arrivee: "
msg5:.asciiz "-----Base erronee--------------"
msg6:.asciiz "\n-----Le nbre est erronee-------"
msg7:.asciiz "\nEntree la base d'arrivee: " 
msg8:.asciiz "\nDans la nouvelle base le nbre est: "  
nbre:.space 33
res:.space 33
#moto x60k

  • Program Name : ACK
  • Author : NABIL
  • Date : 15/03/2006
  • Time : 22:15:59
  • Description About The Program
  • Location Declarations
ORG $1000 Start At Address 1000 in HEX
  • Main Program
  • ============
START LEA MSG1,A1 MOVE.W #9,D1 MOVE.B #1,D0 TRAP #15 MOVE.B #4,D0 TRAP #15 MOVE.W D1,D3
  • -------------------------
LEA MSG2,A1 MOVE.W #9,D1 MOVE.B #1,D0 TRAP #15 MOVE.B #4,D0 TRAP #15 MOVE.W D1,D2
  • -------------------------
BSR ACK LEA MSG3,A1 MOVE.W #5,D1 MOVE.B #1,D0 TRAP #15 MOVE.W RACK,D1 MOVE.B #3,D0 TRAP #15 STOP #$2700 Stop the program
  • ----------------------------
ACK CMP.W #0,D3 BEQ FIN CMP.W #0,D2 BEQ TRAI
  • ========================
MOVE.W D2,-(A7) MOVE.W D3,-(A7) SUB.W #1,D2 BSR ACK MOVE.W (A7)+,D3 MOVE.W (A7)+,D2
  • -----------------------
MOVE.W D4,D2 SUB.W #1,D3 MOVE.W D2,-(A7) MOVE.W D3,-(A7) BSR ACK MOVE.W (A7)+,D3 MOVE.W (A7)+,D2 RTS
  • ========================
TRAI: MOVE.W D3,-(A7) SUB.W #1,D3 MOVE.W #1,D2 BSR ACK MOVE.W (A7)+,D3 MOVE.W #1,D2 RTS
  • ========================
FIN: MOVE.W D2,D4 ADD.W #1,D4 MOVE.W D4,RACK RTS
  • ----------------------------
MSG1 DC.B 'ENTREE M=' MSG2 DC.B 'ENTREE N=' MSG3 DC.B 'ACK =' RACK DS.W 1 END $1000 End of assembly
  • Program Name : NOMBRE
  • Author : NABIL
  • Date : 18/03/2006
  • Time : 22:27:32
  • Description About The Program
  • Location Declarations
ORG $1000 Start At Address 1000 in HEX
  • Main Program
  • ============
START LEA MSG,A1 MOVE.W #65,D1 MOVE.B #0,D0 TRAP #15 LEA BASEED,A1 MOVE.W #25,D1 MOVE.B #1,D0 TRAP #15 MOVE.B #4,D0 TRAP #15 MOVE.W D1,D2 LEA BASEEA,A1 MOVE.W #27,D1 MOVE.B #1,D0 TRAP #15 MOVE.B #4,D0 TRAP #15 MOVE.W D1,D3 LEA NBRE,A1 MOVE.W #16,D1 MOVE.B #1,D0 TRAP #15 CMP.W #2,D2 BEQ BIN CMP.W #10,D2 BEQ DEC CMP.W #16,D2 BEQ HEX BRA ERREUR
  • ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
BIN: CMP.W #16,D3 BEQ BINHEX CMP.W #10,D3 BEQ BINDEC BRA ERREUR DEC: CMP.W #2,D3 BEQ DECBIN CMP.W #16,D3 BEQ DECHEX BRA ERREUR HEX: CMP.W #10,D3 BEQ HEXDEC CMP.W #2,D3 BEQ HEXBIN BRA ERREUR
  • ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
BINDEC: BSR LECTMSG LEA IN,A1 BSR BIN2DEC CMP.W #0,D3 BEQ ERREURN MOVE.W D1,D5 LEA RES,A1 MOVE.W #28,D1 MOVE.B #1,D0 TRAP #15 MOVE.W D5,D1 MOVE.B #3,D0 TRAP #15 BSR SAUT BRA FIN
  • --------------------------------------------------------------------------------
BINHEX: BSR LECTMSG LEA IN,A1 BSR BIN2DEC CMP.W #0,D3 BEQ ERREURN MOVE.W D1,D2 LEA HEXOUT,A2 BSR DEC22HEX LEA RES,A1 MOVE.W #28,D1 MOVE.B #1,D0 TRAP #15 LEA HEXOUT,A1 MOVE.W #8,D1 MOVE.B #0,D0 TRAP #15 BRA FIN
  • ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DECBIN: BSR LECTMSG LEA IN,A1 BSR STR2DEC CMP.W #0,D3 BEQ ERREURN MOVE.L D1,D3 LEA BINOUT,A1 BSR DEC2BIN LEA RES,A1 MOVE.W #28,D1 MOVE.B #1,D0 TRAP #15 LEA BINOUT,A1 MOVE.W #32,D1 MOVE.B #0,D0 TRAP #15 BRA FIN
  • -------------------------------------------------------------------------------
DECHEX: BSR LECTMSG LEA IN,A1 BSR STR2DEC CMP.W #0,D3 BEQ ERREURN MOVE.L D1,D2 LEA HEXOUT,A2 BSR DEC2HEX LEA RES,A1 MOVE.W #28,D1 MOVE.B #1,D0 TRAP #15 LEA HEXOUT,A1 MOVE.W #8,D1 MOVE.B #0,D0 TRAP #15 BRA FIN
  • ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
HEXBIN: BSR LECTMSG LEA IN,A1 BSR HEX2DEC CMP.W #0,D3 BEQ ERREURN MOVE.L D1,D3 LEA BINOUT,A1 BSR DEC2BIN LEA RES,A1 MOVE.W #28,D1 MOVE.B #1,D0 TRAP #15 LEA BINOUT,A1 MOVE.W #32,D1 MOVE.B #0,D0 TRAP #15 BRA FIN
  • --------------------------------------------------------------------------------
HEXDEC: BSR LECTMSG LEA IN,A1 BSR HEX2DEC CMP.W #0,D3 BEQ ERREURN MOVE.L D1,D3 LEA RES,A1 MOVE.W #28,D1 MOVE.B #1,D0 TRAP #15 MOVE.L D3,D1 MOVE.B #3,D0 TRAP #15 BSR SAUT BRA FIN
  • +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ERREUR: LEA ERREURRB,A1 MOVE.W #72,D1 MOVE.B #0,D0 TRAP #15 BRA FIN
  • +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ERREURN: LEA ERREURRN,A1 MOVE.W #45,D1 MOVE.B #0,D0 TRAP #15 FIN:
  • +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
STOP #$2700 Stop the program
  • +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SAUT LEA SSAUT,A1 MOVE.W #1,D1 MOVE.B #0,D0 TRAP #15 RTS
  • ######################LECTURE D"UNE CHAINE DE CARACTERES#########################
LECTMSG MOVE.W #0,D4 LEA IN,A1 LECT3: CMP.W #8,D4 BEQ FINLEC3 MOVE.B #5,D0 TRAP #15 CMP.B #13,D1 BEQ FINLEC3 MOVE.B D1,(A1)+ ADD.W #1,D4 BRA LECT3 FINLEC3: MOVE.W D4,LANG RTS
  • ###################BASE BINAIRE VERT DECIMAL OU HEXADECIMAL#######################
BIN2DEC MOVE.W #0,D1 MOVE.W LANG,D2 SUB.W #1,D2 BOUCLE: MOVE.B (A1)+,D6 EXT.W D6 SUB.W #48,D6 CMP.W #0,D6 BLT ERR CMP.W #1,D6 BGT ERR MOVE.W D6,D4 ASL.W D2,D4 ADD.W D4,D1 SUB.W #1,D2 CMP.W #0,D2 BGT BOUCLE BEQ BOUCLE MOVE.W #1,D3 RTS ERR: MOVE.W #0,D3 RTS
  • -----------------------------------------------------------------------------------
DEC22HEX MOVE.W #0,(A4) MOVEA A7,A3 BOUCLE62: MOVE.W D2,D4 ASR.W #4,D4 MOVE.W D4,D6 ASL.W #4,D6 MOVE.W D2,D0 SUB.W D6,D0 CMP.W #9,D0 BGT HEXA22 ADD.B #48,D0 BRA NORMAL22 HEXA22: ADD.B #55,D0 NORMAL22: ADD.W #1,(A4) MOVE.B D0,-(A7) MOVE.W D4,D2 CMP.W #0,D2 BNE BOUCLE62 BOUCLE72: CMP.W #8,(A4) BEQ FIFIF2 MOVE.B #48,-(A7) ADD.W #1,(A4) BRA BOUCLE72 FIFIF2: MOVE.B (A7)+,(A2)+ CMPA A7,A3 BEQ FIF2 BRA FIFIF2 FIF2: RTS
  • ##################BASE DECIMAL VERT BINAIRE OU HEXADECIMAL########################
STR2DEC MOVE.L #0,D1 MOVE.W LANG,D6 BOUCLE3: MOVE.B (A1)+,D3 SUB.B #48,D3 CMP.B #0,D3 BLT ERREUR3 CMP.B #9,D3 BGT ERREUR3 MOVE.B D3,D4 EXT.L D4 MULU #10,D1 ADD.L D4,D1 SUB.W #1,D6 CMP.W #0,D6 BEQ FF BRA BOUCLE3 FF: MOVE.W #1,D3 RTS ERREUR3: MOVE.W #0,D3 RTS
  • -----------------------------------------------------------------------------------
DEC2BIN MOVEA A7,A2 MOVE.W #0,(A3) BOUCLE4: MOVE.L D3,D1 ASR.L #1,D1 MOVE.L D1,D5 ASL.L #1,D5 MOVE.L D3,D4 SUB.L D5,D4 ADD.B #48,D4 MOVE.B D4,-(A7) ADD.W #1,(A3) MOVE.L D1,D3 CMP.L #0,D3 BNE BOUCLE4 BOUCLE5: CMP.W #32,(A3) BEQ FIFIF1 MOVE.B #48,-(A7) ADD.W #1,(A3) BRA BOUCLE5 FIFIF1: MOVE.B (A7)+,(A1)+ CMPA A7,A2 BEQ FIF1 BRA FIFIF1 FIF1: RTS
  • ----------------------------------------------------------------------------------
DEC2HEX MOVE.W #0,(A4) MOVEA A7,A3 BOUCLE6: MOVE.L D2,D4 ASR.L #4,D4 MOVE.L D4,D6 ASL.L #4,D6 MOVE.L D2,D0 SUB.L D6,D0 CMP.L #9,D0 BGT HEXA2 ADD.B #48,D0 BRA NORMAL2 HEXA2: ADD.B #55,D0 NORMAL2: ADD.W #1,(A4) MOVE.B D0,-(A7) MOVE.L D4,D2 CMP.L #0,D2 BNE BOUCLE6 BOUCLE7: CMP.W #8,(A4) BEQ FIFIF MOVE.B #48,-(A7) ADD.W #1,(A4) BRA BOUCLE7 FIFIF: MOVE.B (A7)+,(A2)+ CMPA A7,A3 BEQ FIF BRA FIFIF FIF: RTS
  • ###############BASE HEXADECIMAL VERT BINAIRE OU DECIMAL ###########################
HEX2DEC MOVE.L #0,D1 MOVE.W #8,D0 SUB.W LANG,D0 MULU #4,D0 MOVE.W #28,D5 SUB.W D0,D5 BOUCLE2: MOVE.B (A1)+,D2 SUB.B #48,D2 EXT.L D2 CMP.L #0,D2 BLT ERRU CMP.L #9,D2 BGT HEXQ BRA NORMALL HEXQ: SUB.L #7,D2 CMP.L #10,D2 BLT ERRU CMP.L #15,D2 BGT ERRU NORMALL: MOVE.L D2,D3 ASL.L D5,D3 ADD.L D3,D1 SUB.W #4,D5 CMP.W #0,D5 BGE BOUCLE2 MOVE.W #1,D3 RTS ERRU: MOVE.W #0,D3 RTS
  • ####################################################################################
IN DC.B ' ' ;8 DECOUT DC.B ' ' ;10 HEXOUT DC.B ' ' ;8 BINOUT DC.B ' ' ;32 MSG DC.B '---------TP N1 ARCHITECTURE II:REPRESENTATION DES NBRE-----------' ;46 BASEED DC.B 'ENTREE LA BASE DE DEPART:' ;25 BASEEA DC.B 'ENTREE LA BASE DE RESULTAT:' ;27 NBRE DC.B 'ENTREE LE NBRE :' ;16 RES DC.B 'LA CONVERTION DE NBRE DONNE:' ;28 ERREURRB DC.B 'VOUS AVEZ CHOISI UNE DASE ERRONNE,OU LA BASE DE DEPART=CELLE DE RESULTAT' ;72 ERREURRN DC.B 'LE NBRE QUE VOUS AVEZ CHOISI N"EST PAS VALIDE' ;45 SSAUT DC.B ' ' LANG DS.W 1
  • ----------------------------------------------------------------
END $1000 End of assembly
  • Program Name : RACINE
  • Author : NABIL
  • Date : 13/03/2006
  • Time : 17:26:56
  • Description About The Program
  • Location Declarations
ORG $1000 Start At Address 1000 in HEX
  • Main Program
  • ============
START LEA MSG1,A1 MOVE.W #9,D1 MOVE.B #1,D0 TRAP #15
  • -------------------------------------------------------------
MOVE.B #4,D0 TRAP #15 MOVE.L D1,NN ;LECTURE DE NBRE N MOVE.L #1,D2
  • -------------------------------------------------------------
BSR DOMAINE MOVE.L D2,NBRE1 ;LE RESULTAT DANS D2=X0 MOVE.L #0,SIMEN1 CMP.L #1,D1 BEQ FINTRAIT
  • --------------------------------------------------------------
TRAIT: MOVE.L NBRE1,NBRE2 MOVE.L SIMEN1,SIMEN2 BSR MULTFL ;CALCULE DE X*X
  • --------------------------------------------------------------
MOVE.L REST,D3 MOVE.L RSIM,D4 MOVE.L NN,D5 SUB.L D6,D6 BSR SUSTRAFL ;CALCULE DE F_X=(X*X)-N MOVE.L REST,F_XRES MOVE.L RSIM,F_XSIM
  • ---------------------------------------------------------------
MOVE.L #2,NBRE2 MOVE.L #0,SIMEN2 BSR MULTFL ;CALCULE DE 2*X
  • ---------------------------------------------------------------
MOVE.L REST,F__XRES MOVE.L RSIM,F__XSIM ;ON A F__X=2*X
  • ----------------------------------------------------------------
MOVE.L F_XRES,D3 MOVE.L F_XSIM,D4 MOVE.L F__XRES,D5 MOVE.L F__XSIM,D6 BSR DIVISIONFL ;CALCULE DE RAPORT=F_X/F__X MOVE.L REST,RAPORT_RES MOVE.L RSIM,RAPORT_SIM
  • -----------------------------------------------------------------
MOVE.L RAPORT_RES,D5 MOVE.L RAPORT_SIM,D6 MOVE.L NBRE1,D3 MOVE.L SIMEN1,D4 BSR SUSTRAFL ;ON A X DANS LA NEW ETAT MOVE.L REST,NBRE2 MOVE.L RSIM,SIMEN2
  • ------------------------------------------------------------------
FINTRAIT: MOVE.L NBRE1,D1 MOVE.B #3,D0 TRAP #15 LEA VERG,A1 MOVE.W #1,D1 MOVE.B #1,D0 TRAP #15 MOVE.L SIMEN1,D6 MOVE.L #1000,D5 AFF: MOVE.L D6,D2 DIVU D5,D2 EXT.L D2 MOVE.L D2,D1 MOVE.B #3,D0 TRAP #15 MULU D5,D2 SUB.L D2,D6 DIVU #10,D5 EXT.L D5 CMP.L #0,D5 BEQ FINP BRA AFF FINP: MOVE.L RAPORT_SIM,D2 CMP.L #100,D2 BLE FINPGM TER: MOVE.B #0,D0 MOVE.W #0,D1 TRAP #15
  • ---------------------------------------------------------------
MOVE.L NBRE2,NBRE1 MOVE.L SIMEN2,SIMEN1 SUB.L D1,D1 BRA TRAIT
  • ---------------------------------------------------------------
FINPGM: MOVE.B #0,D0 MOVE.W #0,D1 TRAP #15 LEA FMSG,A1 MOVE.W #17,D1 MOVE.B #0,D0 TRAP #15
  • ---------------------------------------------------------------
STOP #$2700 Stop the program
  • ----------------------------------------------------------------
DOMAINE LOOP1: MOVE.L D2,D3 MULS D2,D3 SUB.L D1,D3 CMP #0,D3 BGT FLOOP1 BEQ FLOOPE ADD.L #1,D2 BRA LOOP1 FLOOP1: RTS FLOOPE: MOVE.L #1,D1 RTS
  • ----------------------------------------------------------------
MULTFL MOVE.L NBRE1,D3 MOVE.L SIMEN1,D4 MOVE.L NBRE2,D5 MOVE.L SIMEN2,D6 MOVE.L D3,D1 MULU D5,D1 MULU D6,D3 MULU D4,D5 ADD.L D5,D3 MULU D6,D4 DIVU #10000,D4 EXT.L D4 ADD.L D4,D3 MOVE.L D3,D6 DIVU #10000,D3 EXT.L D3 ADD.L D3,D1 MOVE.L D1,REST MOVE.L D3,D2 ;POUR SAVOIRE LA SIMENTIQUE MULU #10000,D2 SUB.L D2,D6 MOVE.L D6,RSIM RTS
  • -----------------------------------------------------------------
SUSTRAFL CMP.L D6,D4 BLT INF SUB.L D5,D3 MOVE.L D3,REST SUB.L D6,D4 MOVE.L D4,RSIM RTS INF: SUB.L D5,D3 SUB.L #1,D3 MOVE.L D3,REST SUB.L D4,D6 MOVE.L #10000,D1 SUB.L D6,D1 MOVE.L D1,RSIM RTS
  • ------------------------------------------------------------------
ADDITIONFL ADD.L D3,D5 ADD.L D4,D6 MOVE.L D6,D2 DIVU #10000,D2 EXT.L D2 ADD.L D2,D5 MOVE.L D5,REST MULU #10000,D2 SUB.L D2,D6 MOVE.L D6,RSIM RTS
  • -------------------------------------------------------------------
DIVISIONFL MULU #1000,D3 ADD.L D4,D3 MOVE.L D3,NB1 MOVE.L D3,D1 MULU #1000,D5 ADD.L D6,D5 MOVE.L D5,NB2 DIVU D5,D3 EXT.L D3 MOVE.L D3,REST MULU D5,D3 SUB.L D3,D1 MULU #10,D1 MOVE.L D1,RSIM MOVE.L D1,D2 CMP.L #0,D2 BEQ FIND MOVE.W #3,D5 CLR.L D4 LOOP2: MOVE.L NB2,D1 CMP.W #0,D5 BEQ FIND MULU #10,D2 MOVE.L D2,NB1 DIVU D1,D2 EXT.L D2 MULU #10,D4 ADD.L D2,D4 MULU D2,D1 MOVE.L NB1,D2 SUB.L D1,D2 SUB.W #1,D5 BRA LOOP2 FIND: MOVE.L D4,RSIM RTS
  • ------------------------------------------------------------------
MSG1 DC.B 'ENTREE N=' FMSG DC.B '--------FIN------' VERG DC.B '.' NBRE1 DS.L 1 SIMEN1 DS.L 1 NBRE2 DS.L 1 SIMEN2 DS.L 1 REST DS.L 1 RSIM DS.L 1 NB1 DS.L 1 NB2 DS.L 1 NN DS.L 1 F_XRES DS.L 1 F_XSIM DS.L 1 F__XRES DS.L 1 F__XSIM DS.L 1 RAPORT_RES DS.L 1 RAPORT_SIM DS.L 1 END $1000 End of assembly #sparc .global akr akr: save %sp,-64,%sp cmp %g0,%g2 bne else nop add %g3,%g1,%g5 ret restore else: cmp %g0,%g1 bne else2 nop sub %g2,%g3,%g2 mov 1,%g1 call akr nop ret restore else2: sub %g1,%g3,%g1 mov %g2,%l2 call akr nop mov %l2,%g2 sub %g2,%g3,%g2 mov %g5,%g1 call akr nop ret restore .global _start _start: sethi str1>>10,%l1 add %l1,str1&0x3FF,%l1 st %l1,[%g0+IODevPrintStrz] mov 3,%l2 st %l2,[%g0+IODevPrintInt] add %l1,str2-str1,%l1 st %l1,[%g0+IODevPrintStrz] mov 1,%l2 st %l2,[%g0+IODevPrintInt] add %l1,str3-str2,%l1 st %l1,[%g0+IODevPrintStrz] mov 1,%g1 mov 4,%g2 mov 1,%g3 call akr nop st %g5,[%g0+IODevPrintInt] .word 0 ! ill instr halt str1: .ascii "Entree la valeur de M=",0 str2: .ascii 10,"Entree la valeur de N=",0 str3: .ascii 10,"Akr=",0 .macro domaine n domaine: mov 1,%g5 loop1: mov %g2,%g3 st %g2,[%g0+IODevMulM1] st %g3,[%g0+IODevMulM2] ld [%g0+IODevMulSPL],%g3 sub %g3,n,%g3 cmp %g3,%g0 bg floop1 nop be floop2 nop add %g5,%g2,%g2 ba loop1 nop floop1: ba fin nop floop2: mov 1,n fin: .endm !---------------------------------------------------- mulfl: st %g5,[%g0+IODevMulM1] st %g3,[%g0+IODevMulM2] ld [%g0+IODevMulSPL],%l3 st %g6,[%g0+IODevMulM1] st %g3,[%g0+IODevMulM2] ld [%g0+IODevMulSPL],%l4 st %g4,[%g0+IODevMulM1] st %g5,[%g0+IODevMulM2] ld [%g0+IODevMulSPL],%l5 add %l4,%l5,%l4 st %g4,[%g0+IODevMulM1] st %g6,[%g0+IODevMulM2] ld [%g0+IODevMulSPL],%l6 sethi 10000>>10,%l7 !ddddddd add %l7,10000&0x3FF,%l7 st %l7,[%g0+IODevDivDH] st %l6,[%g0+IODevDivDL] st %l7,[%g0+IODevDivDiv] ld [%g0+IODevDivUQ],%l6 add %l6,%l4,%l4 mov %l4,%l6 st %l7,[%g0+IODevDivDH] st %l4,[%g0+IODevDivDL] st %l7,[%g0+IODevDivDiv] ld [%g0+IODevDivUQ],%l4 add %l4,%l3,%l3 mov %l3,%o1 mov %l4,%l5 st %l5,[%g0+IODevMulM1] st %l7,[%g0+IODevMulM2] ld [%g0+IODevMulSPL],%l5 sub %l6,%l5,%o2 retl nop !--------------------------------------------------- sustrafl: cmp %g6,%g4 bg inf nop sub %g3,%g5,%o1 sub %g4,%g6,%o2 b end nop inf: sub %g3,%g5,%l3 mov 1,%l6 sub %l3,%l6,%o1 sub %g6,%g4,%l6 sethi 10000>>10,%l5 add %l5,10000&0x3FF,%l5 !ddddddddddd sub %l5,%l6,%o2 end: retl nop !------------------------------------------------- .macro divisionfl res,rest divisionfl: sethi 10000>>10,%l7 add %l7,10000&0x3FF,%l7!ddddddddd st %g3,[%g0+IODevMulM1] st %l7,[%g0+IODevMulM2] ld [%g0+IODevMulSPL],%g3 add %g3,%g4,%g3 mov %g3,%l2 mov %g3,%l1 st %g5,[%g0+IODevMulM1] st %l7,[%g0+IODevMulM2] ld [%g0+IODevMulSPL],%g5 add %g6,%g5,%g5 mov %g5,%l3 st %g5,[%g0+IODevDivDH] st %g3,[%g0+IODevDivDL] st %g5,[%g0+IODevDivDiv] ld [%g0+IODevDivUQ],%g3 mov %g3,res st %g5,[%g0+IODevMulM1] st %g3,[%g0+IODevMulM2] ld [%g0+IODevMulSPL],%g3 sub %l1,%g3,%l1 mov %l1,rest mov %l1,%l4 cmp %g0,%l4 be find nop mov 4,%g5!dddddddddddd sub %g4,%g4,%g4 loop2: mov %l3,%l1 cmp %g0,%g5 be find nop mov 10,%l6 st %l4,[%g0+IODevMulM1] st %l6,[%g0+IODevMulM2] ld [%g0+IODevMulSPL],%l4 mov %l4,%l2 st %l1,[%g0+IODevDivDH] st %l4,[%g0+IODevDivDL] st %l1,[%g0+IODevDivDiv] ld [%g0+IODevDivUQ],%l4 st %l6,[%g0+IODevMulM1] st %g4,[%g0+IODevMulM2] ld [%g0+IODevMulSPL],%g4 add %l4,%g4,%g4 st %l1,[%g0+IODevMulM1] st %l4,[%g0+IODevMulM2] ld [%g0+IODevMulSPL],%l1 mov %l2,%l4 sub %l4,%l1,%l4 sub %g5,1,%g5 b loop2 nop find: mov %g4,rest .endm .global _start _start: sethi str1>>10,%l2 add %l2,str1&0x3FF,%l2 st %l2,[%g0+IODevPrintStrz] mov 3,%l1 st %l1,[%g0+IODevPrintInt] add %l2,str2-str1,%l2 st %l2,[%g0+IODevPrintStrz] mov 2023,%l0 !%l0=nn mov 1,%g2 mov %l0,%g1 domaine %g1 nop mov %g2,%o5 mov 0,%o6 mov 1,%i1 cmp %i1,%g1 be fintrait nop trait: mov %o5,%g3 mov %o6,%g4 mov %g3,%g5 mov %g4,%g6 call mulfl !calcul de x*x nop mov %o1,%g3 mov %o2,%g4 mov %l0,%g5 mov 0,%g6 call sustrafl ! calcul de x*x-nn nop mov %o1,%o3 mov %o2,%o4 mov %o5,%g3 mov %o6,%g4 mov 2,%g5 mov 0,%g6 call mulfl !calcule de 2*x nop mov %o1,%i3 mov %o2,%i4 mov %o3,%g3 mov %o4,%g4 mov %i3,%g5 mov %i4,%g6 divisionfl %o1,%o2 !calcule le rapport nop mov %o1,%i5 mov %o2,%i6 mov %i5,%g5 mov %i6,%g6 mov %o5,%g3 mov %o6,%g4 call sustrafl nop mov %o1,%g3 mov %o2,%g4 mov %g3,%o5 mov %g4,%o6 fintrait: st %g3,[%g0+IODevPrintInt] sethi ver>>10,%l2 add %l2,ver&0x3FF,%l2 st %l2,[%g0+IODevPrintStrz] sethi 1000>>10,%l1 add %l1,1000&0x3Ff,%l1 mov 10,%l2 aff: mov %g4,%g5 st %l1,[%g0+IODevDivDH] st %g4,[%g0+IODevDivDL] st %l1,[%g0+IODevDivDiv] ld [%g0+IODevDivUQ],%g5 st %g5,[%g0+IODevPrintInt] st %g5,[%g0+IODevMulM1] st %l1,[%g0+IODevMulM2] ld [%g0+IODevMulSPL],%g5 sub %g4,%g5,%g4 st %l2,[%g0+IODevDivDH] st %l1,[%g0+IODevDivDL] st %l2,[%g0+IODevDivDiv] ld [%g0+IODevDivUQ],%l1 cmp %g0,%l1 be finp nop b aff nop finp: sethi saut>>10,%l3 add %l3,saut&0x3FF,%l3 st %l3,[%g0+IODevPrintStrz] cmp %g0,%i6 be finpgm nop b trait nop finpgm: .word 0 ! ill instr halt str1: .ascii "Entree la valeur de N=",0 str2: .ascii 10,"La Racine =",0 ver: .ascii ",",0 saut: .ascii 10 .global _start !------------------------------------------- print: st %l1,[%g0+IODevPrintStrz] retl nop !------------------------------------------- bin2dec: mov 0,%g3 mov 7,%i1 mov 0,%g6 boucle: ldsb [%g1+%g6],%g4 sub %g4,48,%g4 cmp %g4,0 bl erre nop cmp %g4,1 bg erre nop sll %g4,%i1,%g5 add %g3,%g5,%g3 sub %i1,1,%i1 add %g6,1,%g6 cmp %i1,%g0 bg boucle nop be boucle nop mov 1,%g2 retl nop erre: mov 0,%g2 retl nop !------------------------------------------------ str2dec: mov 0,%g3 mov 10,%l2 mov 0,%g6 sethi 10000000>>10,%o5 add %o5,10000000&0x3FF,%o5 boucle3: ldsb [%g1+%g6],%g4 sub %g4,48,%g4 cmp %g4,0 bl erre3 nop cmp %g4,9 bg erre3 nop st %o5,[%g0+IODevMulM1] st %g4,[%g0+IODevMulM2] ld [%g0+IODevMulSPL],%g5 add %g5,%g3,%g3 st %l2,[%g0+IODevDivDH] st %o5,[%g0+IODevDivDL] st %l2,[%g0+IODevDivDiv] ld [%g0+IODevDivUQ],%o5 add %g6,1,%g6 cmp %o5,0 bg boucle3 nop mov 1,%g2 retl nop erre3: mov 0,%g2 retl nop !------------------------------------------------ dec2hex: sethi hexout>>10,%l2 add %l2,hexout&0x3FF,%l2 mov %l2,%l3 add %l2,7,%l2 boucle6: srl %g1,4,%g2 sll %g2,4,%g4 sub %g1,%g4,%l5 cmp %l5,9 bg hexa2 nop add %l5,48,%l5 b normal2 nop hexa2: add %l5,55,%l5 normal2: stb %l5,[%l2] sub %l2,1,%l2 mov %g2,%g1 cmp %g1,0 bg boucle6 nop boucle7: mov 48,%g1 stb %g1,[%l2] sub %l2,1,%l2 cmp %l3,%l2 bl boucle7 nop be boucle7 nop retl nop !------------------------------------------------ dec2bin: sethi binout>>10,%l1 add %l1,binout&0x3FF,%l1 mov %l1,%l2 add %l1,31,%l1 boucle4: srl %g1,1,%l4 sll %l4,1,%l5 sub %g1,%l5,%l3 add %l3,48,%l3 stb %l3,[%l1] sub %l1,1,%l1 mov %l4,%g1 cmp %g1,0 bg boucle4 nop boucle5: mov 48,%g1 stb %g1,[%l1] sub %l1,1,%l1 cmp %l2,%l1 bl boucle5 nop be boucle5 nop retl nop !------------------------------------------------- hex2dec: mov 0,%g3 mov 28,%l2 boucle2: ldsb [%g1],%g4 sub %g4,48,%g4 cmp %g4,0 bl erre2 nop cmp %g4,9 bg hexx nop b normal nop hexx: sub %g4,7,%g4 cmp %g4,10 bl erre2 nop cmp %g4,15 bg erre2 nop normal: sll %g4,%l2,%g5 add %g3,%g5,%g3 sub %l2,4,%l2 add %g1,1,%g1 cmp %l2,0 bg boucle2 nop be boucle2 nop mov 1,%g2 retl nop erre2: mov 0,%g2 retl nop !------------------------------------------------- _start: sethi msg>>10,%l1 add %l1,msg&0x3FF,%l1 call print nop sethi based>>10,%l1 add %l1,based&0x3FF,%l1 call print nop !lecture de la base de depart mov 2,%l6 !base de depart**************** sethi baser>>10,%l1 add %l1,baser&0x3FF,%l1 call print nop !lecture de la base de resultat mov 10,%l7 !base de resultat**************** cmp %l6,2 be bin nop cmp %l6,10 be dec nop cmp %l6,16 be hex nop b erreur nop !*********************************************** bin: cmp %l7,10 be bindec nop cmp %l7,16 be binhex nop b erreur nop !*********************************************** dec: cmp %l7,2 be decbin nop cmp %l7,16 be dechex nop b erreur nop !************************************************ hex: cmp %l7,2 be hexbin nop cmp %l7,10 be hexdec nop b erreur nop !************************************************ binhex: !lecture de nbre qui sera dans in sethi in>>10,%g1 add %g1,in&0x3FF,%g1 call bin2dec nop cmp %g2,%g0 be errnn nop mov %g3,%g1 call dec2hex nop sethi res>>10,%l1 add %l1,res&0x3FF,%l1 call print nop sethi hexout>>10,%l1 add %l1,hexout&0x3FF,%l1 call print nop b fin nop !---------------------------------------- bindec: !lecture de nbre il sera dans in sethi in>>10,%g1 add %g1,in&0x3FF,%g1 call bin2dec nop cmp %g2,%g0 be errnn nop sethi res>>10,%l1 add %l1,res&0x3FF,%l1 call print nop st %g3,[%g0+IODevPrintInt] b fin nop !************************************************* dechex: !lecture de nbre , il sera dans in sethi in>>10,%g1 add %g1,in&0x3FF,%g1 call str2dec nop cmp %g2,%g0 be errnn nop mov %g3,%g1 call dec2hex nop sethi res>>10,%l1 add %l1,res&0x3FF,%l1 call print nop sethi hexout>>10,%l1 add %l1,hexout&0x3FF,%l1 call print nop b fin nop !--------------------------------------------- decbin: !lecture de nbre qui sera dans in sethi in>>10,%g1 add %g1,in&0x3FF,%g1 call str2dec nop cmp %g2,%g0 be errnn nop mov %g3,%g1 call dec2bin nop sethi res>>10,%l1 add %l1,res&0x3FF,%l1 st %l1,[%g0+IODevPrintStrz] sethi binout>>10,%l1 add %l1,binout&0x3FF,%l1 st %l1,[%g0+IODevPrintStrz] b fin nop !************************************************ hexdec: !lecture de nbre qui sera dans in sethi in>>10,%g1 add %g1,in&0x3FF,%g1 call hex2dec nop cmp %g2,%g0 be errnn nop sethi res>>10,%l1 add %l1,res&0x3FF,%l1 call print nop st %g3,[%g0+IODevPrintInt] b fin nop !------------------------------------------------- hexbin: !lecture de nbre qui sera dans in sethi in>>10,%g1 add %g1,in&0x3FF,%g1 call hex2dec nop cmp %g2,%g0 be errnn nop mov %g3,%g1 call dec2bin nop sethi res>>10,%l1 add %l1,res&0x3FF,%l1 call print nop sethi binout>>10,%l1 add %l1,binout&0x3FF,%l1 call print nop b fin nop !------------------------------------------------- errnn: sethi errn>>10,%l1 add %l1,errn&0x3FF,%l1 call print nop b fin nop erreur: sethi errb>>10,%l1 add %l1,errb&0x3FF,%l1 call print nop b fin nop !------------------------------------------------- fin: .word 0 ! ill instr halt in: .ascii "00201110",0 deout: .ascii " ",0 hexout: .ascii " ",0 binout: .ascii " ",0 msg: .ascii "----------Tp n1 de Arichi--------",0 based: .ascii 10,"Entree la base de depart:",0 baser: .ascii 10,"Entree la base de resultat:",0 nombre: .ascii 10,"Entree la nombre:",0 res: .ascii 10,"La conversion donne:",0 errb: .ascii 10,"base erronee.....",0 errn: .ascii 10,"nbre erronee.....",0

Conclusion :


bon chance :-)

A voir également

Ajouter un commentaire Commentaires
Messages postés
1
Date d'inscription
vendredi 16 janvier 2009
Statut
Membre
Dernière intervention
9 mai 2009

bonlour moi jamal cherche un code de flash de mibile motoro v3x merci forgeron12@hotmail.com
Messages postés
225
Date d'inscription
mardi 4 mars 2003
Statut
Membre
Dernière intervention
30 juillet 2008

Un language bien écrit se lit aisément...

A bon entendeur...

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.