|
|
Flavioweb
Registered: Nov 2011 Posts: 122 |
64tass: hex to string into source, how?
I i use
number = $1000
.text ^number
result is:
$34, $30, $39, $36
How to do the same but with result
$31, $30, $30, $30? |
|
|
... 2 posts hidden. Click here to view all posts.... |
| |
Flavioweb
Registered: Nov 2011 Posts: 122 |
Thanks a lot !!!
But seems there is a problem:
Assembling file: hex2str.s
hex2str.s:6: (hex2str.s:2) (hex2str.s:11) Constant too large ".byte ($1000 >> (i*4)) - 10 + $41"
hex2str.s:6: (hex2str.s:2) (hex2str.s:11) Constant too large ".byte ($1000 >> (i*4)) - 10 + $41"
... |
| |
Conrad Account closed
Registered: Nov 2006 Posts: 604 |
Ok. Just use the first example for now. I can't test the second one because I'm on my PC at work which has no C64 tools. I'll be happy if someone else can adjust it.
Also, if you want the "A-F" characters to use bytes $01-$06 from the charset, replace "$41" with "$01". |
| |
Flavioweb
Registered: Nov 2011 Posts: 122 |
This version works fine:
HEX2STR .macro
.if \2 = 4
.if (\1 >> 12)<10
.byte (\1 >> 12) + $30
.else
.byte (\1 >> 12) - 10 + $01
.endif
.fi
.if \2 >= 3
.if ((\1 >> 8) & $f)<10
.byte ((\1 >> 8) & $f) + $30
.else
.byte ((\1 >> 8) & $f) - 10 + $01
.endif
.fi
.if \2 >= 2
.if ((\1 >> 4) & $f)<10
.byte ((\1 >> 4) & $f) + $30
.else
.byte ((\1 >> 4) & $f) - 10 + $01
.endif
.fi
.if \2 >= 1
.if (\1 & $f)<10
.byte (\1 & $f) + $30
.else
.byte (\1 & $f) - 10 + $01
.endif
.fi
.endm
|
| |
Conrad Account closed
Registered: Nov 2006 Posts: 604 |
Revision II of the other version (hope it works):
HEX2STR .macro
.for i=(\2)-1,i>=0,i=i-1
.if ((\1 >> (i*4)) & $f) < 10
.byte ((\1 >> (i*4)) & $f) + $30
.else
.byte ((\1 >> (i*4)) & $f) - 9
.endif
.next
.endm
#HEX2STR $1234abcd,8
The error before was due to forgetting to mask the bit-shift result with $f. |
| |
Flavioweb
Registered: Nov 2011 Posts: 122 |
Quoting ConradRevision II of the other version (hope it works):
The error before was due to forgetting to mask the bit-shift result with $f.
Just for precision, this version work with 8 digits or minus.
$1234abcd, works, $12345abcd still return "Constant too large" error.
Nothing really important... just saying... |
| |
iAN CooG
Registered: May 2002 Posts: 1159 |
$12345abcd is not a 32 bit integer, of course it's not valid... |
| |
TWW
Registered: Jul 2009 Posts: 283 |
Quote: I i use
number = $1000
.text ^number
result is:
$34, $30, $39, $36
How to do the same but with result
$31, $30, $30, $30?
number = $03e8
.text ^number
? |
| |
Flavioweb
Registered: Nov 2011 Posts: 122 |
Quoting TWW
number = $03e8
.text ^number
?
Ok, but i can't know the -result- before... the "$1000" is just an example...
But i like the concept of always finding different ways to solve problems =) |
| |
Conrad Account closed
Registered: Nov 2006 Posts: 604 |
^number only prints the result out in decimal, according to the manual.
As for larger numbers than 32-bit, 64Tass is only available on 32-bit OSs. A 64-bit compiled version would probably work. For now, you'll just have to use two 32-bit variables for bigger hex strings. |
| |
Flavioweb
Registered: Nov 2011 Posts: 122 |
Quoting Conrad^number only prints the result out in decimal, according to the manual.
As for larger numbers than 32-bit, 64Tass is only available on 32-bit OSs. A 64-bit compiled version would probably work. For now, you'll just have to use two 32-bit variables for bigger hex strings.
I'm using a -self compiled- version of 64Tass on OpenSuse 12.1 64bit, but seems that only 32bit numbers can be used...
In makefile
#CFLAGS = -O2 -march=i486 -mcpu=i486 -pipe
#CFLAGS = -Wall -O3 -march=i686 -pipe -fomit-frame-pointer -fno-exceptions
#CFLAGS = -Wall
... |
| Previous - 1 | 2 - Next |