English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 10 January 2011, 00:18   #1
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 744
Couple of sunday night questions...

First one, although I'm sure I should know this... Really basic stuff but..

How do you convert hex to decimal so you can display it on screen??? For example, i want to show track 04 / 11, not track 04 / 0B. Or BPM 160 rathern than A0.


Second one, whats the best way to time a routine?

Cheers
h0ffman is offline  
Old 10 January 2011, 00:33   #2
KevG
Banned
 
Join Date: Jan 2009
Location: U.K.
Posts: 93
Everyone does it their own way, but for me....

1. I always convert to binary first. In Hex, each digit is 4 bits so you just convert the binary digits to decimal. Then convert the value of the decimal to a string to display it.

2. For timing I use a millisecs function (in what-ever language)
e.g....

Time1=Current time (in millisecs)
Your routine....
Time2=Current time (in millisecs)
TotalTime=Time2-Time1


Thats how I would do it. But no doubt someone else will post another way of doing it.

Hope that helps.

Kev G.
KevG is offline  
Old 10 January 2011, 00:37   #3
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
Quote:
Originally Posted by h0ffman View Post
First one, although I'm sure I should know this... Really basic stuff but..

How do you convert hex to decimal so you can display it on screen??? For example, i want to show track 04 / 11, not track 04 / 0B. Or BPM 160 rathern than A0.


Second one, whats the best way to time a routine?

Cheers
Easiest way to time a routine is vertical blank, but the most accurate is CIA, but rarely does anyone bother to use the CIA to time.

As for Hex to Decimal: http://eab.abime.net/showpost.php?p=251559&postcount=5
Galahad/FLT is offline  
Old 10 January 2011, 02:10   #4
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Generally, for picking a number apart into digits of an arbitrary base: divide your number by the base, the remainder will be the next higher digit, and you then use the quotient as the numerator and repeat this division until you are left with 0.

(I assume this is what you were looking for, or do you have an actual hexadecimal text string you want to convert?)

EDIT better explanation: take any number and keep dividing it by f.ex 10 until you are left with 0. The remainder of each division will be the value of the next higher digit.

Code:
         ; print any number up to 65535 as ascii

print    clr.l    d0
         move.w   value, d0
         lea      string+6, a0
         clr.b    -(a0)

loop     divu.w   #10, d0      ; format as base 10, decimal

         swap     d0           ; upper word contains remainder
         add.b    #"0", d0     ; which we convert to ascii
         move.b   d0, -(a0)    ; and store
         clr.w    d0

         swap     d0           ; lower word contains quotient
         bne      loop         ; repeat until quotient is 0

         rts                   ; A0 now points to our ascii string

string   ds.b     6

value    dc.w     48109

Last edited by Leffmann; 10 January 2011 at 02:21.
Leffmann is offline  
Old 10 January 2011, 10:42   #5
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 744
Cheers Leffman, I'll be able to display the BPM now Getting closer to completion. Mind you I still have the 16x16 scroller to do.
h0ffman 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
So I have a whole tosec, a couple of questions Kitty support.FS-UAE 2 05 May 2013 17:54
A Couple Of Winuae Questions. fishyfish support.WinUAE 4 23 March 2012 16:42
couple of n00b questions about WHDLoad jimmy2x2x project.WHDLoad 11 30 March 2011 11:13
Couple of hardware questions Smiley support.Hardware 3 10 February 2007 02:38
A couple of newbie questions... kemppe New to Emulation or Amiga scene 2 17 April 2002 09:50

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 09:54.

Top

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