Beispiel #1
0
struct expr *new_expr_incword(const char *name,
                              struct expr *skip)
{
    i32 word;
    i32 offset;
    long length;
    struct membuf *in;
    struct expr *expr;
    unsigned char *p;

    offset = resolve_expr(skip);
    in = get_named_buffer(s->named_buffer, name);
    length = membuf_memlen(in);
    if(offset < 0)
    {
        offset += length;
    }
    if(offset < 0 || offset > length - 2)
    {
        LOG(LOG_ERROR,
            ("Can't read word from offset %d in file \"%s\".\n",
             offset, name));
        exit(-1);
    }
    p = membuf_get(in);
    p += offset;
    word = *p++;
    word |= *p++ << 8;

    expr = new_expr_number(word);
    return expr;
}
Beispiel #2
0
struct expr *new_expr_inclen(const char *name)
{
    long length;
    struct membuf *in;
    struct expr *expr;

    in = get_named_buffer(s->named_buffer, name);
    length = membuf_memlen(in);

    expr = new_expr_number((i32)length);
    return expr;
}
Beispiel #3
0
struct expr *pc_get()
{
    struct expr *old_pc1;

    if(s_pc1 == unset_value)
    {
        LOG(LOG_ERROR, ("PC must be set by a .org(pc) call.\n"));
        exit(-1);
    }
    if(s_pc1 == NULL || s_pc2 != 0)
    {
        old_pc1 = s_pc1;
        s_pc1 = new_expr_number(s_pc2);
        s_pc2 = 0;
        if(old_pc1 != NULL)
        {
            s_pc1 = new_expr_op2(PLUS, s_pc1, old_pc1);
        }
    }

    return s_pc1;
}
Beispiel #4
0
void set_initial_symbol(const char *symbol, i32 value)
{
    struct expr *e = new_expr_number(value);
    map_put(s->initial_symbols, symbol, e);
}
Beispiel #5
0
struct expr *new_is_defined(const char *symbol)
{
    int expr_val = (map_get(s->sym_table, symbol) != NULL);
    return new_expr_number(expr_val);
}