Skip to content

Commit

Permalink
load: accept slt # b-field in 88 mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bobertlo committed Nov 25, 2024
1 parent aadb921 commit 9ca48e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions load.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,12 @@ func getOpModeAndValidate88(Op OpCode, AMode AddressMode, BMode AddressMode) (Op

case SLT:
// SLT;
// AB if #A, B otherwise, no #B allowed
if BMode == IMMEDIATE {
return 0, fmt.Errorf("invalid b mode '#' for op 'slt'")
}
// AB if #A, B otherwise

// #B is not allowed by the 88 standard but is allowed on hills
// if BMode == IMMEDIATE {
// return 0, fmt.Errorf("invalid b mode '#' for op 'slt'")
// }
if AMode == IMMEDIATE {
return AB, nil
} else {
Expand Down
5 changes: 3 additions & 2 deletions load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ func TestLoadDwarf(t *testing.T) {
}, data.Code)
}

func TestValidInput(t *testing.T) {
func TestValidInput88(t *testing.T) {
// random inputs that are valid but not worth validating output
cases := []string{
"END\n",
"\n\n",
"SLT $ 0, # 0\n", // not in 88 spec, pMARS supports this though
}

config := ConfigKOTH88
Expand Down Expand Up @@ -112,7 +113,7 @@ func TestInvalidInput(t *testing.T) {
"DAT # 0, $ 0\n",
"DAT # 0, @ 0\n",
"CMP $ 0, # 0\n",
"SLT $ 0, # 0\n",
// "SLT $ 0, # 0\n", // pMARS supports this
"ADD $ 0, # 0\n",
"SUB $ 0, # 0\n",
"JMP # 0, $ 0\n",
Expand Down

0 comments on commit 9ca48e8

Please sign in to comment.