mirror of
https://github.com/yasm/yasm
synced 2026-08-26 22:26:05 -04:00
Revert value.c/h changes made in [1567].
svn path=/branches/new-optimizer/; revision=1569
This commit is contained in:
parent
25a2df0247
commit
449f058b3b
2 changed files with 19 additions and 21 deletions
|
|
@ -494,33 +494,31 @@ yasm_value_get_intnum(yasm_value *value, yasm_bytecode *bc, int calc_bc_dist)
|
|||
}
|
||||
|
||||
if (value->rel) {
|
||||
/* Get the relative portion's offset. */
|
||||
/* If relative portion is not in bc section, return NULL.
|
||||
* Otherwise get the relative portion's offset.
|
||||
*/
|
||||
/*@dependent@*/ yasm_bytecode *rel_prevbc;
|
||||
unsigned long dist;
|
||||
|
||||
if (!calc_bc_dist)
|
||||
return NULL; /* Don't calculate BC distance */
|
||||
if (!bc)
|
||||
return NULL; /* Can't calculate relative value */
|
||||
|
||||
sym_local = yasm_symrec_get_label(value->rel, &rel_prevbc);
|
||||
if (value->wrt || value->seg_of || value->section_rel || !sym_local)
|
||||
return NULL; /* we can't handle SEG, WRT, or external symbols */
|
||||
if (rel_prevbc->section != bc->section)
|
||||
return NULL; /* not in this section */
|
||||
if (!value->curpos_rel)
|
||||
return NULL; /* not PC-relative */
|
||||
|
||||
/* Calculate relative value as integer */
|
||||
/* Calculate value relative to current assembly position */
|
||||
dist = rel_prevbc->offset + rel_prevbc->len;
|
||||
if (value->curpos_rel) {
|
||||
/* PC-relative */
|
||||
if (!bc)
|
||||
return NULL; /* Can't calculate PC-relative value */
|
||||
if (rel_prevbc->section != bc->section)
|
||||
return NULL; /* not in this section */
|
||||
|
||||
if (dist < bc->offset) {
|
||||
outval = yasm_intnum_create_uint(bc->offset - dist);
|
||||
yasm_intnum_calc(outval, YASM_EXPR_NEG, NULL);
|
||||
} else {
|
||||
dist -= bc->offset;
|
||||
outval = yasm_intnum_create_uint(dist);
|
||||
}
|
||||
if (dist < bc->offset) {
|
||||
outval = yasm_intnum_create_uint(bc->offset - dist);
|
||||
yasm_intnum_calc(outval, YASM_EXPR_NEG, NULL);
|
||||
} else {
|
||||
dist -= bc->offset;
|
||||
outval = yasm_intnum_create_uint(dist);
|
||||
}
|
||||
|
||||
if (value->rshift > 0) {
|
||||
|
|
|
|||
|
|
@ -100,15 +100,15 @@ int yasm_value_finalize_expr(/*@out@*/ yasm_value *value,
|
|||
/*@null@*/ /*@kept@*/ yasm_expr *e,
|
||||
unsigned int size);
|
||||
|
||||
/** Get value if absolute, pure relative, or PC-relative section-local
|
||||
* relative. Returns NULL otherwise.
|
||||
/** Get value if absolute or PC-relative section-local relative. Returns NULL
|
||||
* otherwise.
|
||||
* \param value value
|
||||
* \param bc current bytecode (for PC-relative calculation); if
|
||||
* NULL, NULL is returned for PC-relative values.
|
||||
* \param calc_bc_dist if nonzero, calculates bytecode distances in absolute
|
||||
* portion of value
|
||||
* \note Adds in value.rel (correctly) if PC-relative and in the same section
|
||||
* as bc (and there is no WRT or SEG), or if value is pure-relative.
|
||||
* as bc (and there is no WRT or SEG).
|
||||
* \return Intnum if can be resolved to integer value, otherwise NULL.
|
||||
*/
|
||||
/*@null@*/ /*@only@*/ yasm_intnum *yasm_value_get_intnum
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue