• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sign_extend函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sign_extend函数的典型用法代码示例。如果您正苦于以下问题:C++ sign_extend函数的具体用法?C++ sign_extend怎么用?C++ sign_extend使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sign_extend函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: dec_bi

static void dec_bi(DisasContext *dc)
{
    LOG_DIS("bi %d\n", sign_extend(dc->imm26 << 2, 26));

    gen_goto_tb(dc, 0, dc->pc + (sign_extend(dc->imm26 << 2, 26)));

    dc->is_jmp = DISAS_TB_JUMP;
}
开发者ID:binape,项目名称:qemu,代码行数:8,代码来源:translate.c


示例2: dec_calli

static void dec_calli(DisasContext *dc)
{
    LOG_DIS("calli %d\n", sign_extend(dc->imm26, 26) * 4);

    tcg_gen_movi_tl(cpu_R[R_RA], dc->pc + 4);
    gen_goto_tb(dc, 0, dc->pc + (sign_extend(dc->imm26 << 2, 26)));

    dc->is_jmp = DISAS_TB_JUMP;
}
开发者ID:binape,项目名称:qemu,代码行数:9,代码来源:translate.c


示例3: dec_lw

static void dec_lw(DisasContext *dc)
{
    TCGv t0;

    LOG_DIS("lw r%d, (r%d+%d)\n", dc->r1, dc->r0, sign_extend(dc->imm16, 16));

    t0 = tcg_temp_new();
    tcg_gen_addi_tl(t0, cpu_R[dc->r0], sign_extend(dc->imm16, 16));
    tcg_gen_qemu_ld32s(cpu_R[dc->r1], t0, MEM_INDEX);
    tcg_temp_free(t0);
}
开发者ID:binape,项目名称:qemu,代码行数:11,代码来源:translate.c


示例4: dec_sw

static void dec_sw(DisasContext *dc)
{
    TCGv t0;

    LOG_DIS("sw (r%d+%d), r%d\n", dc->r0, sign_extend(dc->imm16, 16), dc->r1);

    t0 = tcg_temp_new();
    tcg_gen_addi_tl(t0, cpu_R[dc->r0], sign_extend(dc->imm16, 16));
    tcg_gen_qemu_st32(cpu_R[dc->r1], t0, MEM_INDEX);
    tcg_temp_free(t0);
}
开发者ID:binape,项目名称:qemu,代码行数:11,代码来源:translate.c


示例5: sensor_convert_from_raw

/**
 * sensor_convert_from_raw: convert raw sensor values to interpreted values.
 * It can be used to convert raw data, raw thresholds or raw hysteresis of a sensor
 * to human readable format.
 *
 * @sensor: sensor.
 * @val: raw sensor value.
 * @result: the interpreted value
 *
 * Return value: SA_OK if conversion possible
 **/
SaErrorT 
sensor_convert_from_raw (SaHpiSensorRecT *sensor,
                         SaHpiUint32T     val,
                         SaHpiFloat32T   *result)
{
        SaHpiFloat32T m, b, b_exp, r_exp, fval;
        linearizer c_func;
        SaHpiSensorFactorsT *factors = &sensor->DataFormat.Factors;

        if ( factors->Linearization == SAHPI_SL_NONLINEAR )
                c_func = c_linear;
        else if ( factors->Linearization <= 11 )
                c_func = linearize[factors->Linearization];
        else
                return SA_ERR_HPI_INVALID_DATA;

        val &= 0xff;

        m     = (SaHpiFloat32T)factors->M_Factor;
        b     = (SaHpiFloat32T)factors->B_Factor;
        r_exp = (SaHpiFloat32T)factors->ExpR;
        b_exp = (SaHpiFloat32T)factors->ExpB;

        switch( sensor->DataFormat.SignFormat ) {
        case SAHPI_SDF_UNSIGNED:
                fval = (SaHpiFloat32T)val;
                break;

        case SAHPI_SDF_1S_COMPLEMENT:
                val = sign_extend( val, 8 );
                if ( val < 0 )
                        val += 1;

                fval = (SaHpiFloat32T)val;
                break;

        case SAHPI_SDF_2S_COMPLEMENT:
                fval = (SaHpiFloat32T)sign_extend( val, 8 );
                break;

        default:
                return SA_ERR_HPI_INVALID_DATA;
        }

        *result = c_func(   ((m * fval) + (b * pow(10, b_exp)))
                          * pow(10, r_exp) );

        return SA_OK;
}
开发者ID:CSU-GH,项目名称:okl4_3.0,代码行数:60,代码来源:convert.c


示例6: dec_bg

static void dec_bg(DisasContext *dc)
{
    LOG_DIS("bg r%d, r%d, %d\n", dc->r0, dc->r1,
            sign_extend(dc->imm16, 16 * 4));

    gen_cond_branch(dc, TCG_COND_GT);
}
开发者ID:binape,项目名称:qemu,代码行数:7,代码来源:translate.c


示例7: paf_audio_decode

static int paf_audio_decode(AVCodecContext *avctx, void *data,
                            int *got_frame, AVPacket *pkt)
{
    AVFrame *frame = data;
    int16_t *output_samples;
    const uint8_t *src = pkt->data;
    int frames, ret, i, j;
    int16_t cb[256];

    frames = pkt->size / PAF_SOUND_FRAME_SIZE;
    if (frames < 1)
        return AVERROR_INVALIDDATA;

    frame->nb_samples = PAF_SOUND_SAMPLES * frames;
    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
        return ret;

    output_samples = (int16_t *)frame->data[0];
    // codebook of 256 16-bit samples and 8-bit indices to it
    for (j = 0; j < frames; j++) {
        for (i = 0; i < 256; i++)
            cb[i] = sign_extend(AV_RL16(src + i * 2), 16);
        src += 256 * 2;
        // always 2 channels
        for (i = 0; i < PAF_SOUND_SAMPLES * 2; i++)
            *output_samples++ = cb[*src++];
    }
    *got_frame = 1;

    return pkt->size;
}
开发者ID:TaoheGit,项目名称:hmi_sdl_android,代码行数:31,代码来源:pafaudio.c


示例8: cinaudio_decode_frame

static int cinaudio_decode_frame(AVCodecContext *avctx, void *data,
                                 int *got_frame_ptr, AVPacket *avpkt)
{
    AVFrame *frame         = data;
    const uint8_t *buf     = avpkt->data;
    CinAudioContext *cin   = avctx->priv_data;
    const uint8_t *buf_end = buf + avpkt->size;
    int16_t *samples;
    int delta, ret;

    /* get output buffer */
    frame->nb_samples = avpkt->size - cin->initial_decode_frame;
    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
        return ret;
    samples = (int16_t *)frame->data[0];

    delta = cin->delta;
    if (cin->initial_decode_frame) {
        cin->initial_decode_frame = 0;
        delta                     = sign_extend(AV_RL16(buf), 16);
        buf                      += 2;
        *samples++                = delta;
    }
    while (buf < buf_end) {
        delta     += cinaudio_delta16_table[*buf++];
        delta      = av_clip_int16(delta);
        *samples++ = delta;
    }
    cin->delta = delta;

    *got_frame_ptr = 1;

    return avpkt->size;
}
开发者ID:r-type,项目名称:vice-libretro,代码行数:34,代码来源:dsicinaudio.c


示例9: dec_bne

static void dec_bne(DisasContext *dc)
{
    LOG_DIS("bne r%d, r%d, %d\n", dc->r0, dc->r1,
            sign_extend(dc->imm16, 16) * 4);

    gen_cond_branch(dc, TCG_COND_NE);
}
开发者ID:binape,项目名称:qemu,代码行数:7,代码来源:translate.c


示例10: dec_bgeu

static void dec_bgeu(DisasContext *dc)
{
    LOG_DIS("bgeu r%d, r%d, %d\n", dc->r1, dc->r0,
            sign_extend(dc->imm16, 16) * 4);

    gen_cond_branch(dc, TCG_COND_GEU);
}
开发者ID:Mellanox,项目名称:qemu,代码行数:7,代码来源:translate.c


示例11: ff_h263_decode_motion

int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code)
{
    int code, val, sign, shift;
    code = get_vlc2(&s->gb, mv_vlc.table, MV_VLC_BITS, 2);

    if (code == 0)
        return pred;
    if (code < 0)
        return 0xffff;

    sign = get_bits1(&s->gb);
    shift = f_code - 1;
    val = code;
    if (shift) {
        val = (val - 1) << shift;
        val |= get_bits(&s->gb, shift);
        val++;
    }
    if (sign)
        val = -val;
    val += pred;

    /* modulo decoding */
    if (!s->h263_long_vectors) {
        val = sign_extend(val, 5 + f_code);
    } else {
        /* horrible h263 long vector mode */
        if (pred < -31 && val < -63)
            val += 64;
        if (pred > 32 && val > 63)
            val -= 64;

    }
    return val;
}
开发者ID:cxxg,项目名称:FFmpeg,代码行数:35,代码来源:ituh263dec.c


示例12: arm_wince_skip_main_prologue

CORE_ADDR
arm_wince_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
{
  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
  ULONGEST this_instr;

  this_instr = read_memory_unsigned_integer (pc, 4, byte_order);

  /* bl offset <__gccmain> */
  if ((this_instr & 0xfff00000) == 0xeb000000)
    {
#define sign_extend(V, N) \
  (((long) (V) ^ (1L << ((N) - 1))) - (1L << ((N) - 1)))

      long offset = sign_extend (this_instr & 0x000fffff, 23) << 2;
      CORE_ADDR call_dest = (pc + 8 + offset) & 0xffffffffU;
      struct minimal_symbol *s = lookup_minimal_symbol_by_pc (call_dest);

      if (s != NULL
	  && SYMBOL_LINKAGE_NAME (s) != NULL
	  && strcmp (SYMBOL_LINKAGE_NAME (s), "__gccmain") == 0)
	pc += 4;
    }

  return pc;
}
开发者ID:cooljeanius,项目名称:apple-gdb-1824,代码行数:26,代码来源:arm-wince-tdep.c


示例13: MTS_PROTO

/* LB: Load Byte */
fastcall void MTS_PROTO(lb)(cpu_mips_t *cpu,m_uint64_t vaddr,u_int reg)
{
   m_uint64_t data;
   void *haddr;

   haddr = MTS_PROTO(access)(cpu,vaddr,MIPS_MEMOP_LB,1,MTS_READ,&data);
   if (likely(haddr != NULL)) data = *(m_uint8_t *)haddr;
   cpu->gpr[reg] = sign_extend(data,8);
}
开发者ID:GNS3,项目名称:dynamips,代码行数:10,代码来源:mips_mts.c


示例14: mips_cp0_exec_mfc0_fastcall

void fastcall mips_cp0_exec_mfc0_fastcall (cpu_mips_t * cpu,
    mips_insn_t insn)
{
    int rt = bits (insn, 16, 20);
    int rd = bits (insn, 11, 15);
    int sel = bits (insn, 0, 2);

    cpu->reg_set (cpu, rt, sign_extend (mips_cp0_get_reg_fast (cpu, rd, sel), 32));
}
开发者ID:AtomSoftTech,项目名称:retrobsd,代码行数:9,代码来源:mips_cp0.c


示例15: gen_cond_branch

static inline void gen_cond_branch(DisasContext *dc, int cond)
{
    TCGLabel *l1 = gen_new_label();
    tcg_gen_brcond_tl(cond, cpu_R[dc->r0], cpu_R[dc->r1], l1);
    gen_goto_tb(dc, 0, dc->pc + 4);
    gen_set_label(l1);
    gen_goto_tb(dc, 1, dc->pc + (sign_extend(dc->imm16 << 2, 16)));
    dc->is_jmp = DISAS_TB_JUMP;
}
开发者ID:binape,项目名称:qemu,代码行数:9,代码来源:translate.c


示例16: mips_exec_memop2

/* Execute a memory operation (2) */
static int forced_inline mips_exec_memop2 (cpu_mips_t * cpu, int memop,
    m_va_t base, int offset, u_int dst_reg, int keep_ll_bit)
{
    m_va_t vaddr = cpu->gpr[base] + sign_extend (offset, 16);
    mips_memop_fn fn;

    if (!keep_ll_bit)
        cpu->ll_bit = 0;
    fn = cpu->mem_op_fn[memop];
    return (fn (cpu, vaddr, dst_reg));
}
开发者ID:AtomSoftTech,项目名称:retrobsd,代码行数:12,代码来源:mips_fdd.c


示例17: dec_cmpne

static void dec_cmpne(DisasContext *dc)
{
    if (dc->format == OP_FMT_RI) {
        LOG_DIS("cmpnei r%d, r%d, %d\n", dc->r0, dc->r1,
                sign_extend(dc->imm16, 16));
    } else {
        LOG_DIS("cmpne r%d, r%d, r%d\n", dc->r2, dc->r0, dc->r1);
    }

    gen_compare(dc, TCG_COND_NE);
}
开发者ID:binape,项目名称:qemu,代码行数:11,代码来源:translate.c


示例18: dec_mul

static void dec_mul(DisasContext *dc)
{
    if (dc->format == OP_FMT_RI) {
        LOG_DIS("muli r%d, r%d, %d\n", dc->r0, dc->r1,
                sign_extend(dc->imm16, 16));
    } else {
        LOG_DIS("mul r%d, r%d, r%d\n", dc->r2, dc->r0, dc->r1);
    }

    if (!(dc->features & LM32_FEATURE_MULTIPLY)) {
        qemu_log_mask(LOG_GUEST_ERROR,
                      "hardware multiplier is not available\n");
        t_gen_illegal_insn(dc);
        return;
    }

    if (dc->format == OP_FMT_RI) {
        tcg_gen_muli_tl(cpu_R[dc->r1], cpu_R[dc->r0],
                sign_extend(dc->imm16, 16));
    } else {
        tcg_gen_mul_tl(cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]);
    }
}
开发者ID:binape,项目名称:qemu,代码行数:23,代码来源:translate.c


示例19: dec_add

static void dec_add(DisasContext *dc)
{
    if (dc->format == OP_FMT_RI) {
        if (dc->r0 == R_R0) {
            if (dc->r1 == R_R0 && dc->imm16 == 0) {
                LOG_DIS("nop\n");
            } else {
                LOG_DIS("mvi r%d, %d\n", dc->r1, sign_extend(dc->imm16, 16));
            }
        } else {
            LOG_DIS("addi r%d, r%d, %d\n", dc->r1, dc->r0,
                    sign_extend(dc->imm16, 16));
        }
    } else {
        LOG_DIS("add r%d, r%d, r%d\n", dc->r2, dc->r0, dc->r1);
    }

    if (dc->format == OP_FMT_RI) {
        tcg_gen_addi_tl(cpu_R[dc->r1], cpu_R[dc->r0],
                sign_extend(dc->imm16, 16));
    } else {
        tcg_gen_add_tl(cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]);
    }
}
开发者ID:binape,项目名称:qemu,代码行数:24,代码来源:translate.c


示例20: print_code_immed

void print_code_immed( int opcode, int imme ) {
    int se_imme = (sign_extend(imme));
    switch( opcode ) {
        case op_call:
            printf("call %d\n", se_imme); break;
        case op_jump:
            printf("jump %d\n", se_imme); break;
        case op_mova:
            printf("mova %d\n", se_imme); break;
        case op_movb:
            printf("movb %d\n", se_imme); break;
        case op_push:
            printf("push %d\n", se_imme); break;
        default:
            break;
    }
}
开发者ID:stevely,项目名称:New-Robowar,代码行数:17,代码来源:compiletest.c



注:本文中的sign_extend函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ signal函数代码示例发布时间:2022-05-30
下一篇:
C++ signMessage函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap