"Target out of range" errors now output how far off.

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@6 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye 2012-03-16 20:21:09 +00:00
parent 12fe1826d3
commit 57ff3490e0
4 changed files with 27 additions and 9 deletions

View File

@ -12,6 +12,14 @@ platform used. There should be another help file in this archive
outlining the platform specific changes.
----------------------------------------------------------------------
Section: New in release 0.94.3
----------------------------------------------------------------------
"Target out of range" error now includes info on how much the range was
exceeded. Thanks to Bitbreaker/VOZ for the suggestion.
----------------------------------------------------------------------
Section: New in release 0.94.2
----------------------------------------------------------------------

View File

@ -227,9 +227,11 @@ Source file contains illegal character.
Syntax error.
Guess what - there's a syntax error.
Target out of range.
Target out of range (N; M too far).
A relative addressing (branch commands or PER) only has a limited
range. You exceeded it.
range. You exceeded it. N is the attempted offset, M is the difference
to the limit - so if you succeed in optimizing M bytes away, the code
would assemble.
There's more than one character.
You used a text string in an arithmetic expression, but the string

View File

@ -15,9 +15,9 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#define RELEASE "0.94.2" // update before release (FIXME)
#define RELEASE "0.94.3" // update before release (FIXME)
#define CODENAME "Zarquon" // update before release
#define CHANGE_DATE "28 Feb" // update before release
#define CHANGE_DATE "16 Mar" // update before release
#define CHANGE_YEAR "2012" // update before release
//#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/" // FIXME
#define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME

View File

@ -137,7 +137,6 @@ SCS jump_lind[] = { 0, 0, 0, 0xdc00, 0xdc00, 0,
// error message strings
static const char exception_illegal_combination[] = "Illegal combination of command and addressing mode.";
static const char exception_highbyte_zero[]= "Using oversized addressing mode.";
static const char exception_too_far[] = "Target out of range.";
// Variables
@ -572,6 +571,15 @@ static void group_only_implied_addressing(int opcode)
Input_ensure_EOS();
}
// helper function to output "Target out of range" message
static void too_far(intval_t actual, intval_t minimum, intval_t maximum)
{
char buffer[60]; // 640K should be enough for anybody
sprintf(buffer, "Target out of range (%ld; %ld too far).", actual, actual < minimum ? minimum - actual : actual - maximum);
Throw_error(buffer);
}
// Mnemonics using only 8bit relative addressing (short branch instructions).
static void group_only_relative8_addressing(int opcode)
{
@ -580,8 +588,8 @@ static void group_only_relative8_addressing(int opcode)
ALU_int_result(&result);
if (result.flags & MVALUE_DEFINED) {
result.intval -= (CPU_pc.intval + 2);
if ((result.intval > 127) || (result.intval < -128))
Throw_error(exception_too_far);
if ((result.intval < -128) || (result.intval > 127))
too_far(result.intval, -128, 127);
}
Output_byte(opcode);
// this fn has its own range check (see above).
@ -600,8 +608,8 @@ static void group_only_relative16_addressing(int opcode)
ALU_int_result(&result);
if (result.flags & MVALUE_DEFINED) {
result.intval -= (CPU_pc.intval + 3);
if ((result.intval > 32767) || (result.intval < -32768))
Throw_error(exception_too_far);
if ((result.intval < -32768) || (result.intval > 32767))
too_far(result.intval, -32768, 32767);
}
Output_byte(opcode);
// this fn has its own range check (see above).