EASy68Khttp://www.easy68k.com/EASy68Kforum/ Convert a hexadecimal value to an integerhttp://www.easy68k.com/EASy68Kforum/viewtopic.php?f=6&t=1083 Page 1 of 1

 Author: DevotedStudentJA [ Sat Mar 24, 2012 11:12 am ] Post subject: Convert a hexadecimal value to an integer 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?

 Author: profkelly [ Sat Mar 24, 2012 1:13 pm ] Post subject: 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 doCode:    MOVE.size    Rn,memorywhere: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.

 Author: DevotedStudentJA [ Sat Mar 24, 2012 3:16 pm ] Post subject: 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?

 Author: clive [ Sat Mar 24, 2012 5:22 pm ] Post subject: 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.

 Author: DevotedStudentJA [ Sat Mar 24, 2012 6:24 pm ] Post subject: 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