No announcement yet.

32 Bit Math on uLCD-43 (Diablo 16)

  • Filter
  • Time
  • Show
Clear All
new posts

  • 32 Bit Math on uLCD-43 (Diablo 16)

    The max int size on the Diablo 16 architecture is... of course 16 bits. I want to actually store a 32 bit value (in an array of 4 ints, each int representing one 8 bit portion of the 32 bit value), do math on it (multiplication, subtraction, addition, division, etc.), then display the value on the display. What are my options? How can I achieve this?

  • #2
    As well as floating point there are also uadd_3232(), usub_3232(), umul_1616(), udiv3232(), ucmp_3232(), see 2.3.15 and onwards in the internal functions manual


    • #3
      Thanks for the response! I can see that there are a lot of good math functions for 32 bit INTs and float point numbers, but I don't see any way to define 32 bit INTs or floating point numbers. I'm concerned about the definition of these variables, because if I am going to print out the value of one of these 32 bit INTs or float variables, I think the print() function might just treat them as 16 bit INTs by default. How do I define 32 bit INTs and floats, and how do I print them to the display?

      Edit: Just after posting this, I scrolled down further and saw the functions to print float values. However, I still don't know how to define floats and 32 bit INTs, and how to print 32 bit INTs.
      Last edited by JackTheGrey; 26 July 2016, 02:50 AM.


      • #4
        floats and ints are defined as arrays with an element size of 2, eg
        var int32[2], float[2] ;
        to print 32 bit numbers you use str_printf(), specifically the "%ld" and "%lu" options. Of course if the long ends up being 16bits in length after operations are performed on it you can print it in the usual way.


        • #5
          Hi, a related newbie question:

          How do you pass a 32 bit value to a function? For example to update the file so I can show bigger numbers:


          In my program:

          #inherit "" // my edit to allow 32 bit handling..
          var My32bitVal[2]; //declare a var that can be a 32bit number.. THIS IS CLEAR FROM THE DOCUMENTATION
          My32bitVal := 0xffffffff; // - IS THIS A VALID ASSIGNMENT?
          My32bitVal := 1000000; //- IS THIS A VALID ASSIGNMNT?

          ledDigitsDisplay(My32bitVal, iLeddigits5+1, 4, 6, 5, 44, 1) ; // - IS THIS VALID METHOD TO PASS AN ARRAY BY VALUE?


          func ledDigitsDisplay(var newval[2], var index, var left, var Digits, var MinDigits, var WidthDigit, var LeadingBlanks) // - IS THIS VALID SPECIFICATION OF ARRAY PARAMETER?

          ...replace "newval % 10" with 32 bit equivalent etc...

          endfunc //ledDigitsDisplay


          Many thanks