It is currently Sat Apr 04, 2020 2:09 am

 All times are UTC

 Page 1 of 1 [ 5 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Convert a hexadecimal value to an integerPosted: Sat Mar 24, 2012 11:12 am

Joined: Sat Mar 10, 2012 5:07 pm
Posts: 4
Location: Jamaica
I am trying to convert a hexadecimal value that is being stored in a register to an integer, so that I can store it to a variable in memory. Can someone assist please?

_________________
SAnderson

Top

 Post subject: Posted: Sat Mar 24, 2012 1:13 pm

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1118
Integer variables are stored as binary numbers. The numbers in the registers are also binary numbers. They are displayed in hexadecimal for easier user interaction. To store the register to memory just do
Code:
MOVE.size    Rn,memory

where:
size is one of B, W or L. The default is W if no size is specified.
Rn is the register.
memory is the label or address of the variable.

_________________
Prof. Kelly

Top

 Post subject: Posted: Sat Mar 24, 2012 3:16 pm

Joined: Sat Mar 10, 2012 5:07 pm
Posts: 4
Location: Jamaica
Thank you profKelly, but I need to keep a running total of the numbers in their integer form, for example the first time the program loops the hexadecimal value 'C' will be stored in register d7, I want to store this value to a variable called 'Total' as integer 12. Then when the programme loops again the next value will be 6, I then want it to add 12+6 = 18, but when I do it using the hexadecimal numbers stored in the registers I get my answer in hexadecimal.

12 in binary is 1100, so is it that I use the multiplication function to convert this to decimal, since that is the form in which they are stored in memory? and if so, how exactly do I do that?

_________________
SAnderson

Top

 Post subject: Posted: Sat Mar 24, 2012 5:22 pm

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
You're over thinking this.

The values held in registers, or memory is binary. These bit represent a number, and integer, that can be expressed in a number of bases.

Top

 Post subject: Posted: Sat Mar 24, 2012 6:24 pm

Joined: Sat Mar 10, 2012 5:07 pm
Posts: 4
Location: Jamaica
You are right, I was over thinking it, all I needed to do was use trap task 3, and wa- la, the number is displayed as an integer. But I used move, instead of move.b, so that is why I was getting the wrong value for the addition result. I picked up on the error after viewing a few samples on here. Thanks for all the assistance

_________________
SAnderson

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 5 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Google [Bot] and 3 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ EASy68K Forum    FAQ    Latest Features    EASy68K Questions    68000 Programming Questions    Wish List    Wishes Granted    Undocumented Features    Documented Features    General Discussion    EASy68K Projects