EASy68K  
It is currently Sun Nov 17, 2019 5:59 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sat Mar 24, 2012 11:12 am 
Offline

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
 Profile  
 
 Post subject:
PostPosted: Sat Mar 24, 2012 1:13 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1103
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
 Profile  
 
 Post subject:
PostPosted: Sat Mar 24, 2012 3:16 pm 
Offline

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
 Profile  
 
 Post subject:
PostPosted: Sat Mar 24, 2012 5:22 pm 
Offline

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
 Profile  
 
 Post subject:
PostPosted: Sat Mar 24, 2012 6:24 pm 
Offline

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
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


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

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group