IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Assembleur Discussion :

Conversion hexa-BCD en assembleur pour intel 8085


Sujet :

Assembleur

  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2006
    Messages
    101
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2006
    Messages : 101
    Par défaut Conversion hexa-BCD en assembleur pour intel 8085
    Bonjour,

    je programme en assembleur sur un micro intel 8085

    Je recherche un programme que me permettrait de convertir un nombre Hexadécimal en un nombre BCD

    Exemple :

    0A = 10
    09 = 09
    0F = 15

    Merci pour votre aide

  2. #2
    Membre averti
    Inscrit en
    Janvier 2005
    Messages
    21
    Détails du profil
    Informations forums :
    Inscription : Janvier 2005
    Messages : 21
    Par défaut un peut d'observation
    salut
    pour passer du hex vers BCD on peut regarder que:

    0A h + 06 h = 10 h

    0B h + 06 h = 11 h

    0C h + 06 h = 12 h

    0D h + 06 h = 13 h

    0E h + 06 h = 14 h

    0F h + 06 h = 15 h

    les nombre sont donc représentés en BCD, chaque chiffre est codé sur 4 bits
    pour les autres nombres (de 0 à 9) ils sont par force codés en BCD puisque

    09 h = 1001 b == 9 BCD
    08 h = 1000 b == 8 BCD
    ...
    00 h = 0000 b == 0 BCD
    je crois qu c'est le mme principe des instruction tels que DAA

    j'espère que c'est suffisant

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2006
    Messages
    101
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2006
    Messages : 101
    Par défaut
    merci de m'aider ,

    ta solution fonctionne mais je l'ai déja faite et le programme est trés long..
    j'aimarai connaître une solution bcp plus courte, je sais qu'elle existe je l'ai déja vue...
    merci

  4. #4
    Membre averti
    Inscrit en
    Janvier 2005
    Messages
    21
    Détails du profil
    Informations forums :
    Inscription : Janvier 2005
    Messages : 21
    Par défaut
    salut tous le monde;

    pardon pour le retard!
    essayer l'instruction:

    DAA

  5. #5
    jbe
    jbe est déconnecté
    Membre actif
    Profil pro
    Inscrit en
    Novembre 2002
    Messages
    33
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2002
    Messages : 33
    Par défaut
    En effet :

    Decimal adjust accumulator

    DAA

    The contents of the accumulator are changed from a binary value to two 4-bit binary coded decimal (BCD) digits. This is the only instruction that uses the auxiliary flag to perform the binary to BCD conversion, and the conversion procedure is described below. S, Z, AC, P, CY flags are altered to reflect the results of the operation.

    If the value of the low-order 4-bits in the accumulator is greater than 9 or if AC flag is set, the instruction adds 6 to the low-order four bits.

    If the value of the high-order 4-bits in the accumulator is greater than 9 or if the Carry flag is set, the instruction adds 6 to the high-order four bits.


    autrement il y aussi cette technique :
    Routines for convert 24-bit binary to 4-byte BCD (three algorithms - Gorner and LUTs)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    ;  +-------------------------------------------------------------------------+
    ;  | Purpose: Routine to convert a 16bit binary number in ASCII
    ;  |                                                                         |
    ;  | INPUT : R2 (Lsb) and R3 (Msb)   ( binary)                               |
    ;  |                                                                         |
    ;  | OUPUT : 30h,31h,32h,33h,34h  (internal RAM address)  (ASCII)            |
    ;  |   msb--^                  ^------lsb                                       |
    ;  |                                                                         |
    ;  | Destroy all registers                                                   |
    ;  |                                                                         |
    ;  | PROGRAMMER: Bruno Marcio Diogo Venancio ( <a href="mailto:bruno.marcio@bol.com.br">bruno.marcio@bol.com.br</a> )     |
    ;  | BRAZIL 07/19/2002                                                       |
    ;  |          THIS CODE CAN BE FREELY DISTRIBUTED WITHOUT CHANGES            |
    ;  +-------------------------------------------------------------------------+
    ;
    ; Use example:    
    ;                      
    ;START:
    ;        MOV R2,#low(1234)                                
    ;        MOV R3,#high(1234)
    ;        LCALL  BINTOASC
    ;       
    ;   in 30h until 34h of internal RAM will be :'0','1',' 2',','3','4' ( ASCII)
    ;
    ;
    ;             The Routine Algorithm
    ;
    ;
    ;                  +-------+
    ;                  | START |
    ;                  +---+---+
    ;                      |         
    ;                  +-------+
    ;                  |   N   |        ( N= Number to be coverted)
    ;                  +-------+
    ;                      |
    ;                +-------------+
    ;                | POUT   <- 0 |    ( POUT = Output address )        
    ;                +-------------+
    ;                      |
    ;                 +--------+
    ;                 | P <- 0 |      ( P= Table Index )
    ;                 +--------+
    ;                      |
    ;                      |
    ;     +----------->    | 
    ;     |           +-------------+ ( R = Register )
    ;     |           | R <- TAB(P) | ( Fetch a table number indexed by P ) 
    ;     |           +-------------+
    ;     |                |
    ;     |           +----------+
    ;     |           | C <- '0' |    ( C= counter)
    ;     |           +----------+    ( counter <- 0 in ASCII)
    ;     |                |
    ;     |    +------>    |
    ;     |    |      +-----------+
    ;     |    |      | N <-  N-R |   ( subtract the table number with R )
    ;     |    |      +-----------+                                          
    ;     |    |           |
    ;     |    |      N   /  \   Y
    ;     |    |     +--< N<0? >-----------+
    ;     |    |     |   \    /            |
    ;     |    |     |     \/              |
    ;     |    |     |             +--------------------+
    ;     |    |  +-------+        | TABOUT (POUT) <- C |
    ;     |    |  |C<- C+1|        +--------------------+
    ;     |    |  +-------+                |
    ;     |    |     |                +----------+
    ;     |    +-----+                | N <- N+R |
    ;     |                           +----------+
    ;     |                                |
    ;     |                       +------------------+
    ;     |                       | POUT  <- POUT +1 |
    ;     |                       +------------------+
    ;     |                                |
    ;     |                               /^\
    ;     |                             /     \
    ;     |   +----------+         N  /         \ S
    ;     +---| P <- P+1 |-----------< TAB(P)=1? > ---------+
    ;         +----------+            \         /           |
    ;                                   \     /             |
    ;                                     \ /               |
    ;                                                    +-----+
    ;                                                    | END |
    ;                                                    +-----+
    ;
    ;           
     
    BINTOASC:
     
            MOV R0,#30h                 ; R0 = POUT 
            MOV DPTR,#TAB               ; R=TAB(P)
     
    COM1:
     
            CLR A                       ; P <- 0     
            MOVC A,@A+DPTR              ; R <-  TAB(P)
            MOV R7,A
            INC DPTR
            CLR A
            MOVC A,@A+DPTR
            MOV R6,A
     
            MOV R4,#'0'                  ; C  <- '0'
     
     
    SOMA:                                ; N <-  N-R 
          CLR C        ;              
          MOV A,R2     ;              
          SUBB A,R6    ;              
          MOV R2,A     ;              
     
          MOV A,R3     ;               
          SUBB A,R7    ;              
          MOV R3,A     ;              
          JC SAIDA     ;    If < 0 goto  SAIDA
          INC R4       ;    If >0 then C <- C +1
          SJMP SOMA    ;    goto SOMA            
    SAIDA:
          MOV A,R4                 
          MOV @R0,A              ;TABOUT (POUT) <- C
     
          MOV A,R2             
          ADD A,R6               ;  N=N+R
          MOV R2,A             
     
          MOV A,R3             
          ADDC A,R7            
          MOV R3,A             
     
          INC R0                 ; PSAIDA=PSAIDA +1
     
          CLR A
          MOVC A,@A+DPTR
          CJNE A,#1,INCREMENTA   ; TAB(P) = 1 ?
          RET                    ; If yes, END
     
    INCREMENTA:                  ; If No, P <- P+1
          INC DPTR
          LJMP COM1              ; goto COM1
     
     
    TAB:
         DW 10000
         DW 1000
         DW 100
         DW 10
         DW 1
     
     
    ;------------------------------- Cut here  8<---------------------------

Discussions similaires

  1. Conversion HEXA -> ASCII pour affichage LCD
    Par MarcO_- dans le forum C
    Réponses: 11
    Dernier message: 03/03/2007, 17h47
  2. Conversion Latitude,Longitude en UTM pour débutant.
    Par Messie dans le forum Algorithmes et structures de données
    Réponses: 3
    Dernier message: 22/04/2006, 18h37
  3. Conversion Hexa --> Decimal
    Par lory_van_eyck dans le forum Général Python
    Réponses: 2
    Dernier message: 28/09/2005, 07h29
  4. conversion hexa-binaire
    Par jack69 dans le forum C
    Réponses: 8
    Dernier message: 04/04/2005, 16h33
  5. Quel désassembleur/assembleur pour un exe Windows ?
    Par Anonymous dans le forum x86 32-bits / 64-bits
    Réponses: 6
    Dernier message: 17/04/2002, 10h59

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo