10 January 2011, 00:18 | #1 |
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 |
10 January 2011, 00:33 | #2 |
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. |
10 January 2011, 00:37 | #3 | |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
|
Quote:
As for Hex to Decimal: http://eab.abime.net/showpost.php?p=251559&postcount=5 |
|
10 January 2011, 02:10 | #4 |
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. |
10 January 2011, 10:42 | #5 |
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.
|
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 |
|
|