Skip to content
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

DOS commands with "L" parameter and range 1 to 32767 #6

Open
TommyGH opened this issue Aug 12, 2017 · 2 comments
Open

DOS commands with "L" parameter and range 1 to 32767 #6

TommyGH opened this issue Aug 12, 2017 · 2 comments

Comments

@TommyGH
Copy link

TommyGH commented Aug 12, 2017

This isn't really an issue as much as an observation that can be easily overlooked.

OPTAB3

2963:FF 7F DW 32767 ; LENGTH RANGE

You might already be aware of this, but having this defined as a range 1 to 32767 for the L parameter, when you start at an even page boundary you will not get the last byte in the last page of memory that you might think you did.

To really save exactly 32K memory, the range would need to be 1 to 32768. Of course 32768 is 1 greater than "max int".

As examples:

BSAVE BIG,A$800,L$32767
BSAVE BIG,A$800,L32767
BSAVE BIG,A$800,L$7FFF

These examples save memory from $0800 through $87FE (and not $87FF).

As a thought experiment, how would you ever designate you wanted to save all 64K of memory even with changing the value in OPTAB3 to 65535 (FF FF)?


[ Note: I edited this message to fix the first example. --Michael]

@Michaelangel007
Copy link
Owner

Thanks for the insight Tommy! I didn't realize there was an overflow / off-by-one bug lurking there.

Interesting "puzzle". Simple solution would be to use 3-bytes and fix the parser. If we are restricted to $FFFF then there are two conditions we need to check:

  • zero
  • over-flow

Specifically,

  • BSAVE ZERO,A$0,L$0
  • BSAVE BIG, A$0,L$10000

@Michaelangel007
Copy link
Owner

Michaelangel007 commented Aug 25, 2017

Context / Reference:

2138:D9 55 29       221             CMP OPTAB3,Y    ; WITH LOW RANGE (LOW)          ; +0 = OptValMin[x].Lo ?
213F:D9 58 29       224 SP5         CMP OPTAB3+3,Y                                  ; +3 = OptValMax[x].Hi ?
2148:D9 57 29       228             CMP OPTAB3+2,Y                                  ; +2 = OptValMax[x].Lo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants