Menino Posted April 25, 2013 at 11:08 AM Report #504773 Posted April 25, 2013 at 11:08 AM Desde já uma boa tarde e um bom feriado a todos. A minha duvida é no seguinte código .data digito1 db 0 digito2 db 0 multi db 10h ;multi = 10 mov bx,dx mov ax,[bx+2] mov digito2,ah mov digito1,al mov bh,digito1 mov bl,digito2 sub bh,30h mul bh,multi ;ERRO quero multiplicar o bh por 10 sub bl,30h add bh,bl ao compilar este código está a dar-me erro na linha assinalada. O que estou a fazer mal? Obrigado
Rui Carlos Posted April 25, 2013 at 01:51 PM Report #504789 Posted April 25, 2013 at 01:51 PM Acho que a instrução de multiplicação só recebe um operando. O outro é suposto estar no registo EAX. Não sei se consegues usar directamente o multi, ou se tens que o colocar no registo antes. http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH06/CH06-2.html#HEADING2-337 Rui Carlos Gonçalves
Menino Posted April 25, 2013 at 05:41 PM Author Report #504824 Posted April 25, 2013 at 05:41 PM Tens razão já consegui solucionar, já agora alguém sabe como se faz conversão de hex para decimal?,obrigado
cenorasped Posted June 2, 2013 at 05:47 PM Report #510571 Posted June 2, 2013 at 05:47 PM Tens razão já consegui solucionar, já agora alguém sabe como se faz conversão de hex para decimal?,obrigado Também estou com o mesmo problema (conversão hex to dec)! Se alguém conseguisse ajudar!?
KTachyon Posted June 2, 2013 at 10:30 PM Report #510592 Posted June 2, 2013 at 10:30 PM Pegas nos dígitos hexadecimais e multiplicas cada um por 16^N, sendo N a posição do dígito, indexado a zero e a partir da direita (o menos significativo é o em que N = 0). Exemplo 1B4D3 3 x 16^0 = 3 x 1 = 3 D x 16^1 = 13 x 16 = 208 4 x 16^2 = 4 x 256 = 1024 B x 16^3 = 11 x 4096 = 45056 1 x 16^4 = 1 x 65536 = 65536 3 + 208 + 1024 + 45056 + 65536 = 111827 1 Report “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare
cenorasped Posted June 2, 2013 at 11:16 PM Report #510595 Posted June 2, 2013 at 11:16 PM Pegas nos dígitos hexadecimais e multiplicas cada um por 16^N, sendo N a posição do dígito, indexado a zero e a partir da direita (o menos significativo é o em que N = 0). Exemplo 1B4D3 3 x 16^0 = 3 x 1 = 3 D x 16^1 = 13 x 16 = 208 4 x 16^2 = 4 x 256 = 1024 B x 16^3 = 11 x 4096 = 45056 1 x 16^4 = 1 x 65536 = 65536 3 + 208 + 1024 + 45056 + 65536 = 111827 antes de mais obrigado pela resposta! Mas ainda assim me surge outro problema pela minha falta de conhecimento como pego cada digito se tiver num registo por exemplo AX?
Rui Carlos Posted June 3, 2013 at 10:23 PM Report #510792 Posted June 3, 2013 at 10:23 PM Depende de como tiveres os valores armazenados em memória. Um dígito hexadecimal são 4 bits, e se estiver armazenado em 4 bits, deves conseguir extraí-lo com operações de shift. Mas neste caso, não estou bem a ver o que seria a conversão para decimal. Já se estiver armazenado com um caracter (8 bits), vais ter que andar com conversões entre caracteres e inteiros. Pegas num byte, convertes para um inteiro (entre 0 e 15), aplicas o algoritmo de conversão para decimal, e no final convertes o número decimal para caracteres (a divisão inteira deve dar jeito aqui). Rui Carlos Gonçalves
KTachyon Posted June 3, 2013 at 11:29 PM Report #510800 Posted June 3, 2013 at 11:29 PM Se dividires sucessivamente por A (10), o resto da divisão é o dígito decimal. Depois somas ao valor do caracter 0 (zero) e obténs o caracter ASCII que corresponde a cada dígito. 1B4D3 / A = 2BAE, resto 7 2BAE / A = 45E, resto 2 45E / A = 6F, resto 8 6F / A = B, resto 1 B / A = 1, resto 1 1 / A = 0, resto 1 1 Report “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now