-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposed updates #89
Proposed updates #89
Conversation
Resolves #31
I am working on the assumption this will minimise confusion; binaries built from this branch will at least be distinguishable from v1.09 and the final v1.10.
Merge latest upstream changes
Current master shows an incorrect line number when assembling errorlinenumber1.6502. A naive fix by removing the -1 in the assignment to m_lineNumber in the 'reloop' case of SourceCode::UpdateFor() fixes that, but causes errorlinenumber2.6502 to report an incorrect line number.
This caused line numbers to be reported incorrectly when an error occured during macro expansion.
In a statement like "JMP .label" the ".label" would be parsed as a floating point number, silently fail and return 0.
diff --git a/examples/basicrhstoken.6502 b/examples/basicrhstoken.6502 new file mode 100644 index 0000000..e46a8c2 --- /dev/null +++ b/examples/basicrhstoken.6502 @@ -0,0 +1 @@ +putbasic "basicrhstoken.bas", "RHSTOK" diff --git a/examples/basicrhstoken.bas b/examples/basicrhstoken.bas new file mode 100644 index 0000000..f2d9a47 --- /dev/null +++ b/examples/basicrhstoken.bas @@ -0,0 +1,13 @@ +p=PAGE +PRINT p +?&900=PAGE MOD 256 +PRINT FNpage +PRINT ?&900 +?&901=TIME MOD 256 +PRINT ?&901 +PRINT FNtime +END +DEF FNpage +=PAGE +DEF FNtime +=TIME diff --git a/src/BASIC.cpp b/src/BASIC.cpp index ff95f62..eaac8a7 100644 --- a/src/BASIC.cpp +++ b/src/BASIC.cpp @@ -587,6 +587,8 @@ bool EncodeLine() if(Token == ':') // a colon always switches the tokeniser back to "start of statement" mode StartOfStatement = true; + else if(Token == '=') // an equals sign always switches the tokeniser back to "middle of statement" mode + StartOfStatement = false; // grab entire variables rather than allowing bits to be tokenised if @@ -676,9 +678,7 @@ bool EncodeLine() } } - if( - (Flags & 0x40) && StartOfStatement - ) + if((Flags & 0x40) && StartOfStatement) { /* pseudo-variable flag */ Memory[Addr-1] += 0x40; //adjust just-written token
diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..57b3dbb --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +# https://editorconfig.org/ + +root = true + +[*] +end_of_line = crlf +insert_final_newline = true + +[*.{c,h,cpp}] +indent_style = tab
Add .editorconfig
diff --git a/src/main.cpp b/src/main.cpp index d102fc0..d96d3fd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -138,7 +138,9 @@ int main( int argc, char* argv[] ) { state = WAITING_FOR_SYMBOL; } - else if ( strcmp( argv[i], "--help" ) == 0 ) + else if ( ( strcmp( argv[i], "--help" ) == 0 ) || + ( strcmp( argv[i], "-help" ) == 0 ) || + ( strcmp( argv[i], "-h" ) == 0 ) ) { cout << "beebasm " VERSION << endl << endl; cout << "Possible options:" << endl;
…into ZornsLemma/rhs-token-fix
diff --git a/README.md b/README.md index 13c17f6..be6e885 100644 --- a/README.md +++ b/README.md @@ -702,6 +702,8 @@ There is also a demo called `"relocdemo.asm"`, which shows how the 'reload addre cardboardguru76 for pointing this out) Fixed silently treating label references starting with "." as 0 (thanks to mungre for this fix) + Allowed "-h" and "-help" options to see help + Fixed tokenisation of BASIC pseudo-variables in some cases TODO: OTHER CHANGES 12/05/2018 1.09 Added ASSERT Added CPU (as a constant)
Fix incorrect line number in error messages
diff --git a/README.md b/README.md index 5602574..036369a 100644 --- a/README.md +++ b/README.md @@ -699,13 +699,13 @@ There is also a demo called `"relocdemo.asm"`, which shows how the 'reload addre ## 9. VERSION HISTORY ``` ??/??/???? 1.10 Documented "$" and "%" as literal prefixes (thanks to - cardboardguru76 for pointing this out) + cardboardguru76 for pointing this out). Fixed silently treating label references starting with "." - as 0 (thanks to mungre for this fix) - Allowed "-h" and "-help" options to see help - Fixed tokenisation of BASIC pseudo-variables in some cases - Fixed incorrect line number for errors inside macros with - blank lines inside them. + as 0 (thanks to mungre for this fix). + Allowed "-h" and "-help" options to see help. + Fixed tokenisation of BASIC pseudo-variables in some cases. + Fixed incorrect line number for errors inside macros with + blank lines inside them. TODO: OTHER CHANGES 12/05/2018 1.09 Added ASSERT Added CPU (as a constant)
This could be seen with examples/invalidbasic* diff --git a/src/BASIC.cpp b/src/BASIC.cpp index dec9bed..f27e3ea 100644 --- a/src/BASIC.cpp +++ b/src/BASIC.cpp @@ -493,6 +493,10 @@ bool CopyStringLiteral() if(IncomingBuffer[0] != '"') // stopped going for some reason other than a close quote { ErrorNum = -1; + if(IncomingBuffer[0] == '\n') + { + --CurLine; + } DynamicErrorText << "Malformed string literal on line " << CurLine; return false; } @@ -797,7 +801,8 @@ bool ImportBASIC(const char *Filename, Uint8 *Mem, int* Size) if(Length >= 256) { ErrorNum = -1; - DynamicErrorText << "Overly long line at line " << CurLine; + /* CurLine - 1 because we've incremented it on seeing '\n' */ + DynamicErrorText << "Overly long line at line " << CurLine - 1; break; } Memory[LengthAddr] = static_cast<Uint8>(Length);
diff --git a/README.md b/README.md index 036369a..969cffd 100644 --- a/README.md +++ b/README.md @@ -706,6 +706,7 @@ There is also a demo called `"relocdemo.asm"`, which shows how the 'reload addre Fixed tokenisation of BASIC pseudo-variables in some cases. Fixed incorrect line number for errors inside macros with blank lines inside them. + Fixed incorrect line numbers from PUTBASIC in some cases. TODO: OTHER CHANGES 12/05/2018 1.09 Added ASSERT Added CPU (as a constant)
diff --git a/README.md b/README.md index 969cffd..519e61d 100644 --- a/README.md +++ b/README.md @@ -704,6 +704,7 @@ There is also a demo called `"relocdemo.asm"`, which shows how the 'reload addre as 0 (thanks to mungre for this fix). Allowed "-h" and "-help" options to see help. Fixed tokenisation of BASIC pseudo-variables in some cases. + (Thanks to Richard Russell for advice on this.) Fixed incorrect line number for errors inside macros with blank lines inside them. Fixed incorrect line numbers from PUTBASIC in some cases.
I infer this is correct from looking at how the existing source code is formatted; with this value things line up nicely. diff --git a/.editorconfig b/.editorconfig index 57b3dbb..73f0f5f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,3 +8,4 @@ insert_final_newline = true [*.{c,h,cpp}] indent_style = tab +tab_width = 4
I took a quick pass at README to verify that new functionality was included, but would appreciate additional attention. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this! I've had a look over the list of diffs and I have a few (fairly nit-picky, so take them or leave them as you see fit) comments:
The README still says "1.10-pre" in a couple of places, and the date in the changelog at the end is still "??/??/????". You may already know about this and be planning to change it at the last minute but I thought I'd mention it.
The following commits aren't mentioned in the changelog at the end of README.md and might be worth including:
- Seg fault if last line of basic file unterminated
- Buffer overflow if BASIC file ends with 2 blank lines (perhaps merge this with previous one as "fix PUTBASIC undefined behaviour in rare cases" or similar)
- Random number generator using 32-bit ints - this change can cause different output on some machines
- Handle out of range integer conversions
- Don't mistake an EOR for an exponent in e.g. 2EOR3
The man page's list of options is a bit out of date, e.g. it doesn't include -cycle. Arguably this doesn't matter, since what it does list is correct, but FWIW.
There's quite a lot to take in so I may have missed something, but apart from this it looks to me like all the user-visible changes are well-documented
Thank you. Steve seems to have covered everything so apart from those few things I think it's good to go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
Adds missing description of changes in v1.10
Thanks for the review, I've updated the README. Once one of you approves I will merge, tag and announce the new version on the *. forums. I appreciate all the work you have done to get this over the line. |
Thanks for doing this, it will be really nice to have a beebasm 1.10 at last! The change to the README looks good except that:
|
I think the inadvertent tab use in the version history was my handiwork. I've made these few changes and I've also updated the copyright message and date. |
Thanks, that looks good to me now! |
LGTM, I'm going to merge this. 🎉 |
Nice one! |
Excellent! I downloaded it and built a few projects just to be sure it works. Release builds are much faster! Also, I just noticed that the automatic release builder script always tags releases as "pre-release" so I've manually unticked the box. |
Land all the changes that make up v1.10
@mungre @ZornsLemma