~oubiwann/pymite/ipm-enhancements

« back to all changes in this revision

Viewing changes to src/vm/int.c

  • Committer: dwhall256
  • Date: 2009-04-20 00:10:16 UTC
  • Revision ID: svn-v4:22ac2b26-2a8a-11de-a747-197756c87c9e:trunk:349
issue #16 patched from branch and mainlined

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * Integer object type operations.
17
17
 */
18
18
 
 
19
#include <stdint.h>
 
20
#include <limits.h>
19
21
 
20
22
#include "pm.h"
21
23
 
176
178
 
177
179
 
178
180
PmReturn_t
179
 
_int_printHex(int32_t n)
 
181
_int_printHex(intptr_t n)
180
182
{
181
183
    PmReturn_t retval;
 
184
    int8_t i;
182
185
 
183
186
    /* Print the hex value, most significant byte first */
184
 
    retval = int_printHexByte((n >> (uint8_t)24) & (uint8_t)0xFF);
185
 
    PM_RETURN_IF_ERROR(retval);
186
 
    retval = int_printHexByte((n >> (uint8_t)16) & (uint8_t)0xFF);
187
 
    PM_RETURN_IF_ERROR(retval);
188
 
    retval = int_printHexByte((n >> (uint8_t)8) & (uint8_t)0xFF);
189
 
    PM_RETURN_IF_ERROR(retval);
190
 
    retval = int_printHexByte(n & (uint8_t)0xFF);
 
187
    for (i = CHAR_BIT * sizeof(intptr_t) - 8; i >= 0; i -= 8)
 
188
    {
 
189
        retval = int_printHexByte((n >> i) & 0xFF);
 
190
        PM_BREAK_IF_ERROR(retval);
 
191
    }
191
192
 
192
193
    return retval;
193
194
}