English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 26 June 2005, 10:08   #1
redblade
Zone Friend
 
redblade's Avatar
 
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.
redblade is offline  
Old 27 June 2005, 17:30   #2
Wepl
Moderator
 
Wepl's Avatar
 
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)+
Wepl is offline  
Old 28 June 2005, 00:34   #3
redblade
Zone Friend
 
redblade's Avatar
 
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?
redblade is offline  
Old 28 June 2005, 02:49   #4
Codetapper
2 contact me: email only!
 
Codetapper's Avatar
 
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?
Codetapper is offline  
Old 28 June 2005, 08:33   #5
alexh
Thalion Webshrine
 
alexh's Avatar
 
Join Date: Jan 2004
Location: Oxford
Posts: 14,337
I think he meant to say "can I use:"

Code:
move.l #$28F,d0
instead of:

Code:
move.l #655,d0
which of course he can.

You'll note that $299 is of course 665 and not 655 as in Wepl's code
alexh is offline  
Old 28 June 2005, 09:07   #6
Wepl
Moderator
 
Wepl's Avatar
 
Join Date: Nov 2001
Location: Germany
Posts: 866
Quote:
Originally Posted by Codetapper
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?
!665 is decimal notation, for example used in Action Replay
the routine will work for any number below 1000 not 999
for much bigger numbers it will make sense to write a loop maybe...
Wepl is offline  
Old 30 June 2005, 10:56   #7
redblade
Zone Friend
 
redblade's Avatar
 
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
redblade is offline  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 14:16.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.13176 seconds with 15 queries