1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-21 10:37:58 +03:00
Commit Graph

11 Commits

Author SHA1 Message Date
Joel Martin
115e430d02 Basic: QBasic fixes/enabling. Recursive includes.
Enable QBasic console mode usage and fix bugs in newline handling
differences with C64 basic (cbm). To enable console mode for QBasic
programs, have basicpp.py prefix the output with the QB64 specific
console activation variables/functions.

One change to basicpp.py to make this change more straightfowards is
recursive includes so that includes can appear in more than just the
top level step files. This allows us to conditionally include the
right readline implementation. For QBasic in the special console mode
(instead of the default full-screen UI mode) we need to use the LINE
INPUT command in order to read input.
2017-09-14 23:50:15 -05:00
Joel Martin
7895453b77 Basic: various memory savings.
- simplify DO_CONCAT.
- inline MAL_READ/PRINT.
- comment out memory debug/sanity checks.
- more aggressive space removal.

Saves over 900 bytes.

Increase Z% value memory by 374 to 9216 (8192+1024).
2016-12-21 13:51:26 -07:00
Joel Martin
935930128c Basic: move logic/release stack to $C000
Uses stack PUSH*/POP*/PEEK* routines instead of direct X% and Y%
access. Seems to be about the same performance (maybe a 5% performance
hit at most).

This gives us a larger stack (1920 2-byte words of $C000 rather
than 200 words as before). The release stack at $CF00 stays the same
size (64 4-byte addr/level entries).

Also saves over 1K or program and array space. So take the opportunity
to expand Z% entry space from 3712 to 3950.
2016-11-04 21:46:45 -05:00
Joel Martin
4fab6aa517 Basic: more memory savings
- Do the pop of CALL return value at the end of the subroutine
  (callee) rather than at the call point (caller)
- shorten some character variables (CH$->C$, CH->C)
- remove spaces after OPEN, GET
- print REPL header directly in BASIC code

Together saves 404 bytes of memory.
2016-11-02 23:36:44 -05:00
Joel Martin
259dd13c56 Basic: more aggressive space removal
Saves over 1200 bytes so that Z% value space can be bumped up by 256
entries.
2016-11-02 22:19:51 -05:00
Joel Martin
0197588627 Basic: add QBasic support.
make MODE=qbasic stepA_mal.bas
qb64 stepA_mal.bas
2016-10-30 19:15:24 -05:00
Joel Martin
af621e3aec Basic: implement CALL in basicpp.py and use it.
- Add clean rule to Makefile and restructure deps.
2016-10-26 01:26:05 -05:00
Joel Martin
01e8850d43 Basic: Reduce GOSUB use. Partial self-host to step3
step4 runs out of space attempting to load the program. Step2 and
step3 run out of memory (stack exhaustion) for more complicated forms.

- Use GOTO with return label on our stack instead of GOSUB for:
    - APPLY function in types.in.bas
    - "apply", "map" and "swap!" core functions
- Implement DO TCO. Change EVAL_AST to detect if we are called from DO
  and exit one element early.
- Remove GOSUB recursion from EQUAL_Q
- Inline PAIR_Q. Reduce REPLACE stack use.
- Remove one level of GOSUB/stack by calling REP with GOTO
- Simplify mal/step2_eval.mal to remove use of (or ) macro in
  eval_ast.
- Fix ON GOTO/GOSUB line detection in basicpp
2016-10-24 23:29:27 -05:00
Joel Martin
0e508fa518 Basic: add read-file. Misc basicpp space savings.
- Add read-file which is similar to read-string but from a file name
  rather than a string. This allows steps 0-2 to load although each
  one eventuall crashes with out of memory after evaluating "123"
  a few times.
- basicpp:
    - Renumber the line numbers so they are ordinally increasing. This
      saves 150 or so bytes because GOTO/GOSUB calls have smaller line
      numbers.
    - Shrink 'IF 123' -> 'IF123' for almost 300 byte savings.[:w
    - Simplify PR_MEMORY_SUMMARY output. Save 75 bytes
- Add missing runtest.py change that allows basic tests to pass.
2016-10-23 22:18:08 -05:00
Joel Martin
60ef223c3c Basic: basicpp adds, other misc. Shaves 3031 bytes.
- basicpp.py:
    - Fix "ON GOTO/GOSUB" label replacment
    - Add combine line capability
    - Change "THEN GOTO" to "THEN"
- Remove some spaces and unnecessary parens
- Restructure several places with multiple "GOTO/GOSUBs" statements
  into fewer "ON GOTO/GOSUB" statements
2016-09-23 22:36:17 -05:00
Joel Martin
8be49ba8ef Basic: switch to python preprocessor.
- Adds ON GOTO, ON GOSUB support.
- Simplifies REM keep/drop to just yes/no
2016-09-22 22:14:08 -05:00