Skip to content

Commit

Permalink
Merge pull request #1 from thomas374b/master
Browse files Browse the repository at this point in the history
back-merge
  • Loading branch information
thomas374b committed Jul 13, 2020
2 parents f66becd + 0b1d415 commit 22f0b13
Show file tree
Hide file tree
Showing 19 changed files with 73 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ enum FORMAT
ERROR_VALUE_MUST_BE_LT_10000, /* 30 */
ERROR_ILLEGAL_OPERAND_COMBINATION, /* 31 */


ERROR_RECURSION_TOO_DEEP, /* 32 */
ERROR_AVOID_SEGFAULT, /* 33 */
};

typedef struct ERRORSTRUCT
Expand Down
9 changes: 4 additions & 5 deletions src/exp.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,9 +700,8 @@ void doop(opfunc_t func, int pri)
printf("doop @ %d unary\n", Opi);

if (Opi > MAXOPS) {
char errMsg[128];
sprintf(errMsg,"doop: operator index(%d) > MAXOPS(%d), probably too deep recursion", Opi, MAXOPS);
puts(errMsg);
fprintf(stderr,"doop: error: operator index(%d) > MAXOPS(%d), probably too deep recursion", Opi, MAXOPS);
asmerr(ERROR_RECURSION_TOO_DEEP, true, "doop()");
return;
}
Opdis[Opi] = func;
Expand Down Expand Up @@ -976,8 +975,8 @@ const char *pushsymbol(const char *str)
if (str == lastSymbolStr) {
symbolRecursionCount++;
if (symbolRecursionCount > 1000) {
fprintf(stderr,"%s:%d: recursion > 1000, too deep, aborting\n",__FILE__,__LINE__);
exit(1);
fprintf(stderr, "error: %s:%d: recursion > 1000, too deep, aborting\n",__FILE__,__LINE__);
asmerr(ERROR_RECURSION_TOO_DEEP, true, "pushsymbol()");
}
} else {
symbolRecursionCount = 0;
Expand Down
7 changes: 5 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ ERROR_DEFINITION sErrorDef[] = {
{ ERROR_VALUE_MUST_BE_LT_F, true, "Value in '%s' must be <$f." },
{ ERROR_VALUE_MUST_BE_LT_10000, true, "Value in '%s' must be <$10000." },
{ ERROR_ILLEGAL_OPERAND_COMBINATION, true, "Illegal combination of operands '%s'" },
{ ERROR_RECURSION_TOO_DEEP, true, "Recursion too deep in %s" },
{ ERROR_AVOID_SEGFAULT, true, "Internal error in %s" },
{-1, true, "Doh! Internal end-of-table marker, report the bug!"}
};

Expand Down Expand Up @@ -1382,8 +1384,9 @@ int asmerr(int err, bool bAbort, const char *sText )
pincfile = pIncfile;
while(1) {
if (pincfile == NULL) {
fprintf(stderr, "%s:%d, pincfile is NULL, err:%d, abort:%d, [%s]: %s\n", __FILE__, __LINE__
, err, bAbort, sText, sErrorDef[err].sDescription);
fprintf(stderr, "%s:%d: error: pincfile is NULL, err:%d, [%s]: %s\n", __FILE__, __LINE__
, err, sText, sErrorDef[err].sDescription);
bAbort = true;
break;
}
if (pincfile->flags & INF_MACRO) {
Expand Down
5 changes: 5 additions & 0 deletions test/6811_X16.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.PROCESSOR 68hc11
.ORG 0

addA 500,X ; word offset is not allowed with this mnemonic

Empty file added test/6811_X16.fail
Empty file.
5 changes: 5 additions & 0 deletions test/6811_Y16.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.PROCESSOR 68hc11
.ORG 0

andA 500,Y ; word offset is not allowed with this mnemonic

Empty file added test/6811_Y16.fail
Empty file.
5 changes: 5 additions & 0 deletions test/68908_cbeq_SP16.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.PROCESSOR 68hc908
.ORG 0
backLoop:
cbeq (500,SP),backLoop ; word offset is not allowed with this mnemonic

Empty file added test/68908_cbeq_SP16.fail
Empty file.
5 changes: 5 additions & 0 deletions test/68908_dbnz_SP16.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.PROCESSOR 68hc908
.ORG 0
backLoop:
dbnz 400,SP,backLoop ; word offset is not allowed with this mnemonic

Empty file added test/68908_dbnz_SP16.fail
Empty file.
1 change: 1 addition & 0 deletions test/cmdline_defs/declare_var_mac.asm
Binary file added test/cmdline_defs/declare_var_mac.bin.ref
Binary file not shown.
2 changes: 2 additions & 0 deletions test/cmdline_defs/declare_var_mac.hex.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:0B800000CE0066359660A700B7006355
:00000001FF
37 changes: 37 additions & 0 deletions test/declare_var_mac.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
;
; the purpose of this macro is to declare a global variable without need to know its exact location
; the location is automatically derived from its predecessor 'next_var' which gets redefined at every
; occurence. This way one can copy-paste, comment-out or conditional-define variable declarations
; without worrying. Memory usage will be always as compact as possible
;
.PROCESSOR 6803

#ifnconst RAM_START
RAM_START .EQU 0x80
#endif

.mac declare_var ; {name},{size}
{1} .EQU next_var
next_var .set ({1}+{2})
.endm

next_var .set RAM_START

declare_var first, 1 ; declare variable name "first" 8bit
declare_var second, 2 ; declare variable name "second" 16bit
#if (RAM_START == 0x60)
declare_var extra, 3 ; in case of special define, include variable extra 24bit
#endif
declare_var third, 4 ; declare variable name "third" 32bit

.ORG 0x8000

example_code:
ldx #third
txs
ldaa first
staa ,X
#if (RAM_START == 0x60)
staa.w extra
#endif

Binary file added test/declare_var_mac.bin.ref
Binary file not shown.
2 changes: 2 additions & 0 deletions test/declare_var_mac.hex.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:08800000CE0083359680A70035
:00000001FF
Empty file added test/reverse_segfault.fail
Empty file.
Empty file added test/segfault.fail
Empty file.

0 comments on commit 22f0b13

Please sign in to comment.