26 June 2005, 10:08 | #1 |
Zone Friend
Join Date: Mar 2004
Location: Middle Earth
Age: 40
Posts: 2,127
|
hex2ascii in asm
hi does any one one have a asm routine where i can feed the hex value in a data reg ie d0, and the output in a0, and it converts it to say from
d0 = !655, and then down in the buffer. buffer: dc.b 0,0,0,0 after the routine it gets updated to buffer: dc.b '655',0 ;after being converted back to ascii? sorry had a quick look on aminet and i couldn't find a routine. |
27 June 2005, 17:30 | #2 |
Moderator
Join Date: Nov 2001
Location: Germany
Posts: 866
|
Code:
move.l #655,d0 lea buffer,a0 divu #100,d0 add.b #"0",d0 move.b d0,(a0)+ clr.w d0 swap d0 divu #10,d0 add.b #"0",d0 move.b d0,(a0)+ swap d0 add.b #"0",d0 move.b d0,(a0)+ |
28 June 2005, 00:34 | #3 |
Zone Friend
Join Date: Mar 2004
Location: Middle Earth
Age: 40
Posts: 2,127
|
cheers matey .
just about had problems there with the: add.b #"0",d0 but I realized you were just converting it back to the Ascii numerical value. , so thanks. would code still be the same if it was d0=$299 not d0=!665? |
28 June 2005, 02:49 | #4 |
2 contact me: email only!
Join Date: May 2001
Location: Auckland / New Zealand
Posts: 3,182
|
The above code will work for any number under 999. It you need it to go higher, just start off by dividing by 1000, then 100, 10 etc. I don't know what !665 means either, what is the exclamation mark for? $ signifies hexadecimal, what on earth is ! for?
|
28 June 2005, 08:33 | #5 |
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 14,337
|
I think he meant to say "can I use:"
Code:
move.l #$28F,d0 Code:
move.l #655,d0 You'll note that $299 is of course 665 and not 655 as in Wepl's code |
28 June 2005, 09:07 | #6 | |
Moderator
Join Date: Nov 2001
Location: Germany
Posts: 866
|
Quote:
the routine will work for any number below 1000 not 999 for much bigger numbers it will make sense to write a loop maybe... |
|
30 June 2005, 10:56 | #7 |
Zone Friend
Join Date: Mar 2004
Location: Middle Earth
Age: 40
Posts: 2,127
|
yeah sorry about that, after posting that msg, i thought for a while and realised that the routine was still going to work.
so problem answered. Thanks people |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Need an ASM manual | VoltureX | Coders. General | 2 | 17 November 2011 15:24 |
for ASM programmers | meynaf | Coders. General | 29 | 05 August 2010 10:00 |
Using ReadArgs() from asm | oRBIT | Coders. General | 4 | 11 May 2010 16:11 |
6502 Asm | pmc | Coders. General | 21 | 06 November 2008 09:37 |
ASM Uni Course | BippyM | Coders. Tutorials | 27 | 18 September 2008 10:37 |
|
|