Bug 182 - ds.X slightly inconsistent behaviour? (discuss!)
Summary: ds.X slightly inconsistent behaviour? (discuss!)
Alias: None
Product: RMAC
Classification: Unclassified
Component: Core (show other bugs)
Version: unspecified
Hardware: PC Linux
: Normal enhancement
Assignee: Shamus Hammons
Depends on:
Reported: 2021-03-06 12:18 CST by ggn
Modified: 2021-03-06 12:19 CST (History)
1 user (show)

See Also:

The patches! (1019 bytes, patch)
2021-03-06 12:19 CST, ggn

Note You need to log in before you can comment on or make changes to this bug.
Description ggn 2021-03-06 12:18:06 CST
Consider the following program:


    dc.w $1000-*
    ds.b $1000-$
    moveq #0,d0

Assembling this, the dc.w will produce what's expected, i.e. subtract 2 from $1000 for a result of $ffe. The ds.b on the other hand will fail with the error "Error: illegal relative address". "Why's that?" I wondered.

Taking a peek at the source, I saw that the implementation of d_ds() makes a call to abs_expr() to calculate the value. This has a clause that makes it fail if the expression is in a TEXT/DATA/BSS segment (which is considered relative). I think this check was there due to ds.X in the past being legal only in the BSS segment, or something close to that.

I think that we can replace that to a plain call to expr() so it can be more flexible.

I'll attach a patch in a bit, let me know if you can think of any reasons why we shouldn't do this!
Comment 1 ggn 2021-03-06 12:19:50 CST
Created attachment 159 [details]
The patches!