mirror of
https://github.com/open-simh/simtools.git
synced 2026-04-27 20:38:01 +00:00
Allow TRAP without argument, or with non-literal argument
This commit is contained in:
49
assemble.c
49
assemble.c
@@ -1347,29 +1347,40 @@ O 75 .endc
|
|||||||
case OC_MARK:
|
case OC_MARK:
|
||||||
/* MARK, EMT, TRAP */ {
|
/* MARK, EMT, TRAP */ {
|
||||||
EX_TREE *value;
|
EX_TREE *value;
|
||||||
unsigned word;
|
|
||||||
|
|
||||||
cp = skipwhite(cp);
|
cp = skipwhite(cp);
|
||||||
if (*cp == '#')
|
if (EOL (*cp)) {
|
||||||
cp++; /* Allow the hash, but
|
/* Default argument is 0 */
|
||||||
don't require it */
|
store_word (stack->top, tr, 2, op->value);
|
||||||
value = parse_expr(cp, 0);
|
|
||||||
cp = value->cp;
|
|
||||||
if (value->type != EX_LIT) {
|
|
||||||
report(stack->top, "Instruction requires simple literal operand\n");
|
|
||||||
word = op->value;
|
|
||||||
} else {
|
|
||||||
unsigned int max = (op->value == I_MARK)? 077 : 0377;
|
|
||||||
|
|
||||||
if (value->data.lit > max) {
|
|
||||||
report(stack->top, "Literal operand too large (%d. > %d.)\n", value->data.lit, max);
|
|
||||||
value->data.lit = max;
|
|
||||||
}
|
|
||||||
word = op->value | value->data.lit;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (*cp == '#')
|
||||||
|
cp++; /* Allow the hash, but
|
||||||
|
don't require it */
|
||||||
|
value = parse_expr(cp, 0);
|
||||||
|
cp = value->cp;
|
||||||
|
if (value->type != EX_LIT) {
|
||||||
|
if (op->value == I_MARK) {
|
||||||
|
report(stack->top, "Instruction requires " "simple literal operand\n");
|
||||||
|
store_word(stack->top, tr, 2, op->value);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* EMT, TRAP: handle as two bytes */
|
||||||
|
store_value (stack, tr, 1, value);
|
||||||
|
store_word (stack->top, tr, 1, op->value >> 8);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unsigned v = value->data.lit;
|
||||||
|
unsigned int max = (op->value == I_MARK)? 077 : 0377;
|
||||||
|
|
||||||
store_word(stack->top, tr, 2, word);
|
if (v > max) {
|
||||||
free_tree(value);
|
report(stack->top, "Literal operand too large (%d. > %d.)\n", value->data.lit, max);
|
||||||
|
v = max;
|
||||||
|
}
|
||||||
|
store_word(stack->top, tr, 2, op->value | v);
|
||||||
|
}
|
||||||
|
free_tree(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return CHECK_EOL;
|
return CHECK_EOL;
|
||||||
|
|
||||||
|
|||||||
@@ -22,16 +22,14 @@ test-operands.mac:15: ***ERROR Junk at end of line (',0 ; bad')
|
|||||||
19 000020 104377 emt 255.
|
19 000020 104377 emt 255.
|
||||||
test-operands.mac:20: ***ERROR Literal operand too large (256. > 255.)
|
test-operands.mac:20: ***ERROR Literal operand too large (256. > 255.)
|
||||||
20 000022 104377 emt 256. ; too large
|
20 000022 104377 emt 256. ; too large
|
||||||
test-operands.mac:21: ***ERROR Instruction requires simple literal operand
|
21 000024 024' 210 emt . ; allowed though strange
|
||||||
21 000024 104000 emt . ; must be literal
|
|
||||||
22
|
22
|
||||||
23 000026 104400 trap 0
|
23 000026 104400 trap 0
|
||||||
24 000030 104401 trap 1
|
24 000030 104401 trap 1
|
||||||
25 000032 104777 trap 255.
|
25 000032 104777 trap 255.
|
||||||
test-operands.mac:26: ***ERROR Literal operand too large (256. > 255.)
|
test-operands.mac:26: ***ERROR Literal operand too large (256. > 255.)
|
||||||
26 000034 104777 trap 256. ; too large
|
26 000034 104777 trap 256. ; too large
|
||||||
test-operands.mac:27: ***ERROR Instruction requires simple literal operand
|
27 000036 036' 211 trap . ; allowed though strange
|
||||||
27 000036 104400 trap . ; must be literal
|
|
||||||
28
|
28
|
||||||
29 ; OC_1GEN
|
29 ; OC_1GEN
|
||||||
30
|
30
|
||||||
|
|||||||
@@ -18,13 +18,13 @@
|
|||||||
emt 1
|
emt 1
|
||||||
emt 255.
|
emt 255.
|
||||||
emt 256. ; too large
|
emt 256. ; too large
|
||||||
emt . ; must be literal
|
emt . ; allowed though strange
|
||||||
|
|
||||||
trap 0
|
trap 0
|
||||||
trap 1
|
trap 1
|
||||||
trap 255.
|
trap 255.
|
||||||
trap 256. ; too large
|
trap 256. ; too large
|
||||||
trap . ; must be literal
|
trap . ; allowed though strange
|
||||||
|
|
||||||
; OC_1GEN
|
; OC_1GEN
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user