mirror of
https://github.com/open-simh/simtools.git
synced 2026-01-11 23:53:02 +00:00
Allow TRAP without argument, or with non-literal argument
This commit is contained in:
parent
fbb936d1ce
commit
43d7b493fb
49
assemble.c
49
assemble.c
@ -1347,29 +1347,40 @@ O 75 .endc
|
||||
case OC_MARK:
|
||||
/* MARK, EMT, TRAP */ {
|
||||
EX_TREE *value;
|
||||
unsigned word;
|
||||
|
||||
cp = skipwhite(cp);
|
||||
if (*cp == '#')
|
||||
cp++; /* Allow the hash, but
|
||||
don't require it */
|
||||
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;
|
||||
if (EOL (*cp)) {
|
||||
/* Default argument is 0 */
|
||||
store_word (stack->top, tr, 2, op->value);
|
||||
}
|
||||
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);
|
||||
free_tree(value);
|
||||
if (v > max) {
|
||||
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;
|
||||
|
||||
|
||||
@ -22,16 +22,14 @@ test-operands.mac:15: ***ERROR Junk at end of line (',0 ; bad')
|
||||
19 000020 104377 emt 255.
|
||||
test-operands.mac:20: ***ERROR Literal operand too large (256. > 255.)
|
||||
20 000022 104377 emt 256. ; too large
|
||||
test-operands.mac:21: ***ERROR Instruction requires simple literal operand
|
||||
21 000024 104000 emt . ; must be literal
|
||||
21 000024 024' 210 emt . ; allowed though strange
|
||||
22
|
||||
23 000026 104400 trap 0
|
||||
24 000030 104401 trap 1
|
||||
25 000032 104777 trap 255.
|
||||
test-operands.mac:26: ***ERROR Literal operand too large (256. > 255.)
|
||||
26 000034 104777 trap 256. ; too large
|
||||
test-operands.mac:27: ***ERROR Instruction requires simple literal operand
|
||||
27 000036 104400 trap . ; must be literal
|
||||
27 000036 036' 211 trap . ; allowed though strange
|
||||
28
|
||||
29 ; OC_1GEN
|
||||
30
|
||||
|
||||
@ -18,13 +18,13 @@
|
||||
emt 1
|
||||
emt 255.
|
||||
emt 256. ; too large
|
||||
emt . ; must be literal
|
||||
emt . ; allowed though strange
|
||||
|
||||
trap 0
|
||||
trap 1
|
||||
trap 255.
|
||||
trap 256. ; too large
|
||||
trap . ; must be literal
|
||||
trap . ; allowed though strange
|
||||
|
||||
; OC_1GEN
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user