quarta-feira, 22 de julho de 2015

ASSEMBLER 8085

;FR    La multiplication par additions successives
;PT    MULTIPLICACAO POR SOMAS SUCESSIVAS
;EN   Multiplication by successive additions

;FR    Le résultat est valable uniquement si moins d'un octet
;PT    O RESULTADO NAO PODE EXCEDER 1 BYTE
;EN   The result is only valid if less than one byte    

DADOS        EQU 2000h
CODIGO       EQU 3000h

                   ORG DADOS
NUM1:        DB 1    
NUM2:        DB 1   
   
       
                  ORG CODIGO
BEGIN:            LXI H,NUM1       ; HL APONTA NUM1
                        LDA NUM2;
                        CMP M                ; instrucctions to put
                        JC CONDICAO    ; the counter
                        MOV A,M            ; with the less number that we have
                        LXI H,NUM2       ; to multiply
CONDICAO:    MOV C,A   
                        INR C   
                        MVI A,0
LOOP:              DCR C
                        JZ FIM
                        ADD M
                        JMP LOOP
          
FIM:                RST 1



EN: The result of multiplying NUM1 by NUM2 is in the accumulator now at the end
FR: Le acumulateur va rester avec le resultat de la multiplication de le NUM1 e NUM2
PT: O resultado da multiplicação de NUM1 pelo NUM2 fica no acumulador 

means:         ça veux dire:          quer dizer:

A=NUM1xNUM2

very nice!



2 comentários:

  1. Como este código é a multiplicação por somas sucessivas, podia dar se o caso de quererem por exemplo 100 x 2 e aqui temos duas hipoteses ou somamos o valor 2 durante 100 vezes ou somamos o 100 durante duas vezes. Esta ultima hipotese é a que leva menos tempo de processamento. Foi para este efeito que fiz a primeira parte do código: é uma fase de preparação sendo a segunda fase a multiplicação pelas somas sucessivas.

    ResponderEliminar
  2. As this code is multiplication by successive additions could take the case of wanting to eg 2 x 100 and here have two hypotheses: we add the value 2, 100 times or we add 100 for two times. This last hypothesis is that it takes less processing time. It was for this purpose that made the first part of the code: is a preparation phase and the second phase multiplication by successive additions.

    ResponderEliminar