From e5bcbcdebd0af90df914c480d714af8f09174bf0 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 22 Jan 2015 14:08:58 +0000 Subject: [PATCH] py: Allow asmx64 to compile with -Wsign-compare. See issue #699. --- py/asmx64.c | 15 ++++++++------- py/asmx64.h | 6 +++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/py/asmx64.c b/py/asmx64.c index 222b280fb5..39f060d388 100644 --- a/py/asmx64.c +++ b/py/asmx64.c @@ -159,6 +159,7 @@ void asm_x64_start_pass(asm_x64_t *as, uint pass) { void asm_x64_end_pass(asm_x64_t *as) { // could check labels are resolved... + (void)as; } // all functions must go through this one to emit bytes @@ -501,11 +502,11 @@ void asm_x64_setcc_r8(asm_x64_t *as, int jcc_type, int dest_r8) { asm_x64_write_byte_3(as, OPCODE_SETCC_RM8_A, OPCODE_SETCC_RM8_B | jcc_type, MODRM_R64(0) | MODRM_RM_REG | MODRM_RM_R64(dest_r8)); } -void asm_x64_label_assign(asm_x64_t *as, int label) { +void asm_x64_label_assign(asm_x64_t *as, mp_uint_t label) { assert(label < as->max_num_labels); if (as->pass < ASM_X64_PASS_EMIT) { // assign label offset - assert(as->label_offsets[label] == -1); + assert(as->label_offsets[label] == (mp_uint_t)-1); as->label_offsets[label] = as->code_offset; } else { // ensure label offset has not changed from PASS_COMPUTE to PASS_EMIT @@ -514,15 +515,15 @@ void asm_x64_label_assign(asm_x64_t *as, int label) { } } -STATIC mp_uint_t get_label_dest(asm_x64_t *as, int label) { +STATIC mp_uint_t get_label_dest(asm_x64_t *as, mp_uint_t label) { assert(label < as->max_num_labels); return as->label_offsets[label]; } -void asm_x64_jmp_label(asm_x64_t *as, int label) { +void asm_x64_jmp_label(asm_x64_t *as, mp_uint_t label) { mp_uint_t dest = get_label_dest(as, label); mp_int_t rel = dest - as->code_offset; - if (dest != -1 && rel < 0) { + if (dest != (mp_uint_t)-1 && rel < 0) { // is a backwards jump, so we know the size of the jump on the first pass // calculate rel assuming 8 bit relative jump rel -= 2; @@ -541,10 +542,10 @@ void asm_x64_jmp_label(asm_x64_t *as, int label) { } } -void asm_x64_jcc_label(asm_x64_t *as, int jcc_type, int label) { +void asm_x64_jcc_label(asm_x64_t *as, int jcc_type, mp_uint_t label) { mp_uint_t dest = get_label_dest(as, label); mp_int_t rel = dest - as->code_offset; - if (dest != -1 && rel < 0) { + if (dest != (mp_uint_t)-1 && rel < 0) { // is a backwards jump, so we know the size of the jump on the first pass // calculate rel assuming 8 bit relative jump rel -= 2; diff --git a/py/asmx64.h b/py/asmx64.h index f3f7ec12b4..cb021b2f3c 100644 --- a/py/asmx64.h +++ b/py/asmx64.h @@ -104,9 +104,9 @@ void asm_x64_sub_r64_r64(asm_x64_t* as, int dest_r64, int src_r64); void asm_x64_cmp_r64_with_r64(asm_x64_t* as, int src_r64_a, int src_r64_b); void asm_x64_test_r8_with_r8(asm_x64_t* as, int src_r64_a, int src_r64_b); void asm_x64_setcc_r8(asm_x64_t* as, int jcc_type, int dest_r8); -void asm_x64_label_assign(asm_x64_t* as, int label); -void asm_x64_jmp_label(asm_x64_t* as, int label); -void asm_x64_jcc_label(asm_x64_t* as, int jcc_type, int label); +void asm_x64_label_assign(asm_x64_t* as, mp_uint_t label); +void asm_x64_jmp_label(asm_x64_t* as, mp_uint_t label); +void asm_x64_jcc_label(asm_x64_t* as, int jcc_type, mp_uint_t label); void asm_x64_entry(asm_x64_t* as, int num_locals); void asm_x64_exit(asm_x64_t* as); void asm_x64_mov_local_to_r64(asm_x64_t* as, int src_local_num, int dest_r64);