Jump to content

Photo

help with hex to decimal mac65

hex mac65 assembler decimal conversion help

7 replies to this topic

#1 dogdark OFFLINE  

dogdark

    Combat Commando

  • 3 posts

Posted Thu Jul 19, 2018 8:50 PM

Estoy con el siguiente problema, necesito convertir el hexadecimal $44000 a decimal. por ende no puedo utilizar el floating point por que este solo trabaja hasta 2 bytes y un máximo de 65335, trate de todos los medios, incluso sumando de un byte a uno y comparando hasta llegar a la igualdad, pero el proceso es demasiado lento, casi 1 minuto. He revisado revistas manuales y ninguno da señal de algún código que pueda ayudar a realizar este proceso.
 
traduccion
I am with the following problem, I need to convert the hexadecimal $ 44000 to decimal. so I can not use the floating point because it only works up to 2 bytes and a maximum of 65335, try all media, even adding one byte to one and comparing until you reach equality, but the process is too slow , almost 1 minute. I have reviewed manual journals and none gives a signal of any code that can help to carry out this process.
 

        *=$2000
M=17
MEMORY
	.BYTE $00,$00,$00,$9B
DISPONIBLE
	.BYTE $00,$00,$00,$00,$00,$00,$9B
CALCULO
	.BYTE $00,$00,$00,$00,$00,$00,$9B
SUMAMOSMEMORIA
	LDX M
SUMAMOSMEMORIA?
	CLC
	LDA MEMORY+2
	ADC #$00
	STA MEMORY+2
	LDA MEMORY+1
	ADC #$40
	STA MEMORY+1
	LDA MEMORY
	ADC #0
	STA MEMORY
SUMAMOSMEMORIA??
	CPX #0
	BEQ FINSUMAMOSMEMORIA
	DEX
	JMP SUMAMOSMEMORIA?
FINSUMAMOSMEMORIA
	RTS
INICIO
	LDA #0
	STA 710
LOOP
	JMP LOOP
	*=$02E0
	.WORD INICIO

como se puede apreciar en el código tengo la variable M con un valor de 16 que realiza el bucle de SUMAMOSMEMORIA sumando de a $4000 bytes que equivale a 16384 y este resultado queda en MEMORY( $04 $40 $00) y eso quedo dejarlo como disponible ( $02,$07,$08,$05,$02,$08 ). Alguna idea de como realizar la conversión.

 

traducción

As you can see in the code I have the variable M with a value of 16 that makes the SUMAMOSMEMORIA loop adding up to $ 4000 bytes that is equivalent to 16384 and this result is in MEMORY ($ 04 $ 40 $ 00) and that is left as available ($ 02,$07,$08,$05,$02,$08). Some idea of ​​how to perform the conversion.



#2 1050 OFFLINE  

1050

    Stargunner

  • 1,084 posts

Posted Fri Jul 20, 2018 4:55 AM

As long as DISPONIBLE values will never be above $09
for each place you can just add $30 to it to get the
atascii value as a printable one place decimal number.

$08 = $38 which is one place character 8. Same holds
true for $00 thru $09 values.

Welcome new guy, most code heads are posting in the
official code side of the forum
http://atariage.com/...it-programming/

But posting code questions over here is Ok on
occasion too. Especially for the new guy with the
impressive code I don't fully understand but has the
correct results anyway. :)

You can call this a cheap and dirty atascii trick
I picked up on and I'll just smile and say yep. It
really belongs to someone else too, I just stole it
for my own use.

#3 pirx OFFLINE  

pirx

    Moonsweeper

  • 450 posts
  • Location:Poland

Posted Fri Jul 20, 2018 5:25 AM

Hey,

 

Here is my quite lousy routine https://github.com/pkali/scorch_src/blob/master/textproc.asm (starting from line 1033).

 

It is bloody inefficient, but well commented and will help you to start your own. It works up to 9999, but it will be easy to expand it to higher values.



#4 rcgldr OFFLINE  

rcgldr

    Chopper Commander

  • 111 posts

Posted Fri Jul 20, 2018 12:26 PM

Here is my quite lousy routine https://github.com/pkali/scorch_src/blob/master/textproc.asm (starting from line 1033).

Link is broken (404).



#5 AtariGeezer ONLINE  

AtariGeezer

    River Patroller

  • 2,889 posts
  • Location:Santee, CA

Posted Fri Jul 20, 2018 1:52 PM

Link had garbage chars in it.

https://github.com/p...er/textproc.asm



#6 pirx OFFLINE  

pirx

    Moonsweeper

  • 450 posts
  • Location:Poland

Posted Fri Jul 20, 2018 3:28 PM

thank you ;]



#7 dogdark OFFLINE  

dogdark

    Combat Commando

  • Topic Starter
  • 3 posts

Posted Fri Jul 20, 2018 4:26 PM

muchas gracias por el código, y pido las disculpas por haber posteado en un lugar que no correspondía, me fijare para mas adelante, revisare la rutina para expandirla a 3 bytes. yo creo que me servirá de mucho.

 

traducción.

 

thank you very much for the code, and I apologize for having posted in a place that did not correspond, I will look for later, I will review the routine to expand it to 3 bytes. I think it will help me a lot.



#8 vitoco OFFLINE  

vitoco

    Moonsweeper

  • 330 posts

Posted Thu Jul 26, 2018 8:52 AM

Just an update: this was also discussed in Retronia's forum. The problem was to display a 3-bytes integer (24 bits) as decimal digits. xt5 found a very simple method and modified it to take 3 bytes instead of a word (16 bits). It takes bits from the integer by the MSB side and adds to an acumulator using decimal mode (nibbles), and doubles that acumulator at the same time by adding it to itself in the loop. He also provides the code there if someone is interested: http://www.retronia....?p=29596#p29602

 







Also tagged with one or more of these keywords: hex, mac65, assembler, decimal, conversion, help

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users