migrated to ACME assembler
commit 145d64aa6e78838ed07cefed372f0ad6a4687e97 Author: FeralChild64 <you@example.com> Date: Sun Sep 20 20:16:57 2020 +0200 ACME adaptation commit 885209d7822286744ea53232ae7461472a01d5d6 Author: FeralChild64 <you@example.com> Date: Sun Sep 20 19:57:25 2020 +0200 ACME adaptation commit 334d84486bc603551887e7cbeb59d329f2224cc7 Author: FeralChild64 <you@example.com> Date: Sun Sep 20 18:29:15 2020 +0200 ACME adaptation commit b5966f49bcd8f0ca79cbec93819a31238924707e Author: FeralChild64 <you@example.com> Date: Sun Sep 20 18:09:31 2020 +0200 ACME adaptation commit 786536a93a5eab5e676fca99625b4eb094a554e7 Author: FeralChild64 <you@example.com> Date: Sun Sep 20 17:24:48 2020 +0200 ACME adaptation commit 704c70dfb1f5d68775d6f3da220803b8a3990f56 Author: FeralChild64 <you@example.com> Date: Sun Sep 20 15:07:12 2020 +0200 ACME adaptation commit 136874964c9083b375f151475310f9636871fc72 Author: FeralChild64 <you@example.com> Date: Sun Sep 20 14:45:14 2020 +0200 ACME adaptation commit 8eca0d5700b72d04336e72c5cd3a68e18b85f96d Author: FeralChild64 <you@example.com> Date: Sun Sep 20 14:06:52 2020 +0200 ACME adaptation commit 11d29eb7ee318239d782f85498b6d0524624d5c4 Author: FeralChild64 <you@example.com> Date: Sun Sep 20 13:56:45 2020 +0200 ACME apaptation commit c9b5e5e04cceb92c66bc027e6440bc0f7c5a499f Author: FeralChild64 <you@example.com> Date: Sun Sep 20 13:49:04 2020 +0200 ACME adaptation commit f5cc254cbc921f07863807468cb3fe26b410b409 Author: FeralChild64 <you@example.com> Date: Sun Sep 20 13:01:18 2020 +0200 ACME adaptation commit e135a27bf9c30cc0965379c954564e06406303b1 Author: FeralChild64 <you@example.com> Date: Sat Sep 19 21:55:01 2020 +0200 ACME adaptation commit e9dfddf90d9e2795e88b7da40ae050d733faeb56 Author: FeralChild64 <you@example.com> Date: Sat Sep 19 21:48:47 2020 +0200 Makefile fix commit 07030104c65cf5e5beeacf6d629ccb9245e58657 Author: FeralChild64 <you@example.com> Date: Sat Sep 19 21:42:00 2020 +0200 ACME adaptation commit f824362ee5bcfbffca86c430b57773b2ffd65655 Author: FeralChild64 <you@example.com> Date: Sat Sep 19 20:14:56 2020 +0200 ACME adaptation commit 3a3c59007dcd4940d89b8669f34ca56b61c25fdf Author: FeralChild64 <you@example.com> Date: Fri Sep 18 21:51:45 2020 +0200 ACME adaptation commit 6790ef7bc88a41de2881c69b7524dd4ab8c74b5d Author: FeralChild64 <you@example.com> Date: Fri Sep 18 20:35:23 2020 +0200 ACME adaptation commit 38ad18b90e9ec713aa7ca49576b3388ce1733357 Author: FeralChild64 <you@example.com> Date: Fri Sep 18 18:46:20 2020 +0200 ACME adaptation commit 541340371122a9702f7b2d9771c298223cffd0e9 Author: FeralChild64 <you@example.com> Date: Fri Sep 18 16:49:46 2020 +0200 ACME adaptation commit 25cfd5e186459be1a260d3eb8cfff767838de370 Author: FeralChild64 <you@example.com> Date: Thu Sep 17 20:13:33 2020 +0200 ACME adaptation commit f61599444d5b1d03d8fd8e4a6a7c3b85069bedb3 Author: FeralChild64 <you@example.com> Date: Thu Sep 17 19:29:23 2020 +0200 ACME adaptation commit b290be31ec7bb2e5723607697da1bbc621c84429 Author: FeralChild64 <you@example.com> Date: Thu Sep 17 17:20:14 2020 +0200 ACME adaptation commit 877be9e856880d98fd4bcb25b42aaaacda9dc463 Author: FeralChild64 <you@example.com> Date: Wed Sep 16 21:47:38 2020 +0200 ACME adaptation commit bb20edaf85d386e41d5c2f715b745b68fbd3362e Author: FeralChild64 <you@example.com> Date: Wed Sep 16 21:31:30 2020 +0200 ACME adaptation commit c5d31bd8685abce37c8e254d15aac20bd1570d9f Author: FeralChild64 <you@example.com> Date: Wed Sep 16 18:40:49 2020 +0200 ACME adaptation commit 29349826b38f8a89649171559dc8cf24c560aff1 Author: FeralChild64 <you@example.com> Date: Mon Sep 14 23:35:47 2020 +0200 ACME adaptation commit 8bcd6a621c4b11766d0cf34f79858ba90a67248e Author: FeralChild64 <you@example.com> Date: Mon Sep 14 22:52:25 2020 +0200 ACME adaptation commit e87a69edc2ce4bfcc460c31e08dcc352a985f88d Author: FeralChild64 <you@example.com> Date: Mon Sep 14 22:43:27 2020 +0200 ACME adaptation commit f49a097bd52e96d00b866c02bda7121e4543233c Author: FeralChild64 <you@example.com> Date: Mon Sep 14 19:02:07 2020 +0200 ACME adaptation commit fa0e9214a633b8e8f867cc70925b390940dcd426 Author: FeralChild64 <you@example.com> Date: Mon Sep 14 17:47:19 2020 +0200 ACME adaptation commit 1b763b91e7a03e426227129c7f22f0ce57a4c197 Author: FeralChild64 <you@example.com> Date: Mon Sep 14 17:17:10 2020 +0200 ACME adaptation commit e92a4b57b232cd85eb1e71090b8a89c7c8461ebc Author: FeralChild64 <you@example.com> Date: Mon Sep 14 17:15:37 2020 +0200 ACME adaptation commit de3c693e8a7e73ea5289198946058e3240894e6a Author: FeralChild64 <you@example.com> Date: Mon Sep 14 17:10:05 2020 +0200 ACME adaptation commit f9bd7ae0f04e932d613be9ed5cb19af9be5d338e Author: FeralChild64 <you@example.com> Date: Sun Sep 13 14:34:44 2020 +0200 ACME adaptation commit 694dee52555dbfc2b1f7f452a9671ff51106c057 Author: FeralChild64 <you@example.com> Date: Sun Sep 13 14:16:14 2020 +0200 ACME adaptation commit 0af2c55edfcd22942d9f25417eb0d35f55b71604 Author: FeralChild64 <you@example.com> Date: Fri Sep 11 17:38:09 2020 +0200 ACME adaptation commit 2015e17334bd56a1e8a13a5abc098d9c2e7ea44f Author: FeralChild64 <you@example.com> Date: Fri Sep 11 16:46:05 2020 +0200 ACME adaptation commit b1e972162798d60f4483cd6cc261e856c20c2c8c Author: FeralChild64 <you@example.com> Date: Fri Sep 11 16:24:31 2020 +0200 ACME adaptation commit 9d027e868466901ba53bf074a79ec8cf16273021 Author: FeralChild64 <you@example.com> Date: Fri Sep 11 15:04:31 2020 +0200 ACME adaptation commit 957186deddd1aa4f3b4f1aa1f421e4239a584e57 Author: FeralChild64 <you@example.com> Date: Thu Sep 10 22:49:07 2020 +0200 ACME adaptation commit b8060f67a455cfac109f08d96b62c360d693b931 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 23:07:28 2020 +0200 ACME adaptation commit e54d004568f44bbfe5c070ef1d7cf3544112e497 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 22:58:20 2020 +0200 ACME adaptation commit f90b77f073c5a605cb31c6ee451f65c8a8aff7d8 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 22:12:09 2020 +0200 ACME adaptation commit b211bb4afcd9c58fe1f5c92f3007717d611cd531 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 22:01:40 2020 +0200 ACME adaptation commit 8d7ea343b07e9e08e5f77f3c414758a6cffd0440 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 21:38:34 2020 +0200 ACME adaptation commit 46413eb0d92d6400aba0ff8dfe556e61e8a44d78 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 21:07:47 2020 +0200 ACME adaptation commit 9f98f69ecc21f7b74a5eb89e247f5a2c6fcb655d Author: FeralChild64 <you@example.com> Date: Wed Sep 9 20:05:03 2020 +0200 ACME adaptation commit 7bb9f1cadc682c7e0a4a6796739d860d473ca110 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 19:55:12 2020 +0200 ACME adaptation commit 5fc115392b5bdca6b56f67ad866b1884d2d2bdf8 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 19:31:10 2020 +0200 ACME adaptation commit b7940fc60e568d859df9e3156f6bacc6d685b2cc Author: FeralChild64 <you@example.com> Date: Wed Sep 9 19:16:09 2020 +0200 ACME adaptation commit 56288cb97197561afa0816b29c134ec1190e8eab Author: FeralChild64 <you@example.com> Date: Wed Sep 9 18:48:23 2020 +0200 ACME adaptation commit 10401a60fc7922a53d782120ef6795d889140218 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 16:34:16 2020 +0200 ACME adaptation commit 8ce76e4d2b56837a691ae84b1a412a2ae32a157b Author: FeralChild64 <you@example.com> Date: Wed Sep 9 16:20:44 2020 +0200 ACME adaptation commit 33fade899fa6172ea6b5b5f6683bb61f544429fd Author: FeralChild64 <you@example.com> Date: Wed Sep 9 15:28:46 2020 +0200 ACME adaptation commit a416f04734402fcfbc57a933731376df2e0180a1 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 12:40:03 2020 +0200 ACME adaptation commit f8daee005b1d29f6912723be2ac94bc5fbeb0508 Author: FeralChild64 <you@example.com> Date: Mon Sep 7 23:29:54 2020 +0200 ACME adaptation commit 83fe6bdd0b08a44fdbfc6eefe323a4b194ccaf5b Author: FeralChild64 <you@example.com> Date: Mon Sep 7 22:23:16 2020 +0200 ACME adaptation commit cb1f75620b9c83000a15c9c7f7acefdfee79a979 Author: FeralChild64 <you@example.com> Date: Mon Sep 7 19:23:12 2020 +0200 ACME adaptation commit e524d517c933ae1f0aeb49764d307fadb4845025 Author: FeralChild64 <you@example.com> Date: Sun Sep 6 08:24:25 2020 +0200 ACME adaptation - replaced comments commit 2ab572c3a21f4a78a7312d0e684bc11d91d1717a Author: FeralChild64 <you@example.com> Date: Sat Sep 5 17:59:10 2020 +0200 ACME adaptation - replaced the assembler
This commit is contained in:
1 parent
bfc8291e41
commit
c8d255130c
685 files changed
+15835
-16296
No files matched your search
@@ -1,8 +1,8 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
// Just a compatibility jump - our routine is longer than original one
|
||||
; Just a compatibility jump - our routine is longer than original one
|
||||
|
||||
jmp FRMEVL
|
||||
@@ -1,16 +1,16 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
check_stack_space:
|
||||
|
||||
phx_trash_a
|
||||
+phx_trash_a
|
||||
|
||||
tsx
|
||||
cpx #$60 // XXX is this a safe threshold?
|
||||
bcc_16 do_FORMULA_TOO_COMPLEX_error
|
||||
cpx #$60 ; XXX is this a safe threshold?
|
||||
+bcc do_FORMULA_TOO_COMPLEX_error
|
||||
|
||||
plx_trash_a
|
||||
+plx_trash_a
|
||||
|
||||
rts
|
||||
@@ -1,10 +1,10 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Tries to convert PETSCII in .A to a digit (0-9 values), sets Carry to indicate failure
|
||||
//
|
||||
;
|
||||
; Tries to convert PETSCII in .A to a digit (0-9 values), sets Carry to indicate failure
|
||||
;
|
||||
|
||||
convert_PETSCII_to_digit:
|
||||
|
||||
|
||||
+107
-107
@@ -1,209 +1,209 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# M65 BASIC_1 #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# M65 BASIC_1 #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
// As many errors are triggered from many places in the BASIC
|
||||
// interprettor, it is important to have an efficicent means of
|
||||
// calling them.
|
||||
// LDX #$nn / jmp do_basic_error
|
||||
// is the simplest, but takes 5 bytes.
|
||||
// Having a direct JMP address for each error is preferable, as
|
||||
// it reduces the overhead to 3 bytes, but at the cost of having
|
||||
// a jump table of some sort. The .byte $2C method can be used
|
||||
// to have a set of addresses that each execute a different
|
||||
// LDX #$nn command, reducing the cost of the jump table to 3
|
||||
// bytes per error number.
|
||||
// But we can do better with a bit of scullduggery and carnal
|
||||
// knowledge of ZP usage.
|
||||
// The INC $nn opcode is $E6. ZP location $E6 is one of the screen
|
||||
// link addresses. In the original KERNAL, the lower bits of those
|
||||
// addresses have meaning, but in our KERNAL, we ignore them, and just
|
||||
// have them all zeroes. So.... We can have a sequence of $E6 bytes,
|
||||
// and know exactly how many of them have been executed, by checking
|
||||
// the value of $E6. Then all we need to worry about is if an odd
|
||||
// number is required, then we have to have an exit that has a $E6
|
||||
// opcode with some other address as target, but where the byte value
|
||||
// of that argument can be safely executed as a CPU instruction.
|
||||
// NOP = $EA is the obvious choice, as if used as an argument to
|
||||
// $E6 will increment location $EA, which is another of the screen
|
||||
// link addresses.
|
||||
; As many errors are triggered from many places in the BASIC
|
||||
; interprettor, it is important to have an efficicent means of
|
||||
; calling them.
|
||||
; LDX #$nn / jmp do_basic_error
|
||||
; is the simplest, but takes 5 bytes.
|
||||
; Having a direct JMP address for each error is preferable, as
|
||||
; it reduces the overhead to 3 bytes, but at the cost of having
|
||||
; a jump table of some sort. The .byte $2C method can be used
|
||||
; to have a set of addresses that each execute a different
|
||||
; LDX #$nn command, reducing the cost of the jump table to 3
|
||||
; bytes per error number.
|
||||
; But we can do better with a bit of scullduggery and carnal
|
||||
; knowledge of ZP usage.
|
||||
; The INC $nn opcode is $E6. ZP location $E6 is one of the screen
|
||||
; link addresses. In the original KERNAL, the lower bits of those
|
||||
; addresses have meaning, but in our KERNAL, we ignore them, and just
|
||||
; have them all zeroes. So.... We can have a sequence of $E6 bytes,
|
||||
; and know exactly how many of them have been executed, by checking
|
||||
; the value of $E6. Then all we need to worry about is if an odd
|
||||
; number is required, then we have to have an exit that has a $E6
|
||||
; opcode with some other address as target, but where the byte value
|
||||
; of that argument can be safely executed as a CPU instruction.
|
||||
; NOP = $EA is the obvious choice, as if used as an argument to
|
||||
; $E6 will increment location $EA, which is another of the screen
|
||||
; link addresses.
|
||||
|
||||
// This gives a total overhead of 18 bytes + 1 byte per error
|
||||
// message. This compares favourably to the 3 bytes per error
|
||||
// message that the $2C method would result in.
|
||||
; This gives a total overhead of 18 bytes + 1 byte per error
|
||||
; message. This compares favourably to the 3 bytes per error
|
||||
; message that the $2C method would result in.
|
||||
|
||||
|
||||
// Error messages reported by KERNAL
|
||||
; Error messages reported by KERNAL
|
||||
|
||||
do_kernal_error: // .A = KERNAL error code, also almost matches BASIC error codes
|
||||
do_kernal_error: ; .A = KERNAL error code, also almost matches BASIC error codes
|
||||
|
||||
// Convert to BASIC error code
|
||||
; Convert to BASIC error code
|
||||
|
||||
tax
|
||||
beq do_BREAK_error // XXX is 0 really a proper error code?
|
||||
beq do_BREAK_error ; XXX is 0 really a proper error code?
|
||||
|
||||
dex
|
||||
#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_1)
|
||||
!ifdef SEGMENT_M65_BASIC_1 {
|
||||
jmp do_basic_error
|
||||
#else
|
||||
bpl do_basic_error // branch always
|
||||
#endif
|
||||
} else {
|
||||
bpl do_basic_error ; branch always
|
||||
}
|
||||
|
||||
// Error messages specific to Open ROMs BASIC dialect
|
||||
; Error messages specific to Open ROMs BASIC dialect
|
||||
|
||||
do_MEMORY_CORRUPT_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
|
||||
// Error messages compatible with CBM BASIC V7 dialect
|
||||
; Error messages compatible with CBM BASIC V7 dialect
|
||||
|
||||
do_FILE_READ_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_NOT_IMPLEMENTED_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_UNRESOLVED_REFERENCE_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_LINE_NUMBER_TOO_LARGE_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_BEND_NOT_FOUND_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_BAD_DISK_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_NO_GRAPHICS_AREA_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_DIRECT_MODE_ONLY_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_LOOP_WITHOUT_DO_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_LOOP_NOT_FOUND_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_CANT_RESUME_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
|
||||
// Error messages compatible with CBM BASIC V2 dialect
|
||||
; Error messages compatible with CBM BASIC V2 dialect
|
||||
|
||||
do_BREAK_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_LOAD_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_VERIFY_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_UNDEFD_FUNCTION_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_CANT_CONTINUE_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_FORMULA_TOO_COMPLEX_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_FILE_DATA_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_STRING_TOO_LONG_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_TYPE_MISMATCH_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_ILLEGAL_DIRECT_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_DIVISION_BY_ZERO_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_REDIMD_ARRAY_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_BAD_SUBSCRIPT_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_UNDEFD_STATEMENT_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_OUT_OF_MEMORY_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_OVERFLOW_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_ILLEGAL_QUANTITY_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_OUT_OF_DATA_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_RETURN_WITHOUT_GOSUB_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_SYNTAX_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_NEXT_WITHOUT_FOR_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_ILLEGAL_DEVICE_NUMBER_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_MISSING_FILENAME_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_NOT_OUTPUT_FILE_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_NOT_INPUT_FILE_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_DEVICE_NOT_PRESENT_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_FILE_NOT_FOUND_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_FILE_NOT_OPEN_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_FILE_OPEN_error:
|
||||
.byte $E6
|
||||
!byte $E6
|
||||
do_TO_MANY_FILES_error:
|
||||
.byte $EA
|
||||
!byte $EA
|
||||
|
||||
#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_1)
|
||||
!ifdef SEGMENT_M65_BASIC_1 {
|
||||
|
||||
jmp do_error_fetch
|
||||
|
||||
#else
|
||||
} else {
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
do_error_fetch:
|
||||
|
||||
// Now get the error id and restore $E6 to its correct value
|
||||
; Now get the error id and restore $E6 to its correct value
|
||||
|
||||
lda $E6
|
||||
pha
|
||||
and #$80
|
||||
sta $E6
|
||||
pla
|
||||
// $E6 has even part
|
||||
; $E6 has even part
|
||||
asl
|
||||
ora $EA
|
||||
and #$7F
|
||||
tax
|
||||
|
||||
// Restore $EA to correct value in case the NOP above is used
|
||||
// as an argument to the preceeding INC $nn (opcode $E6).
|
||||
; Restore $EA to correct value in case the NOP above is used
|
||||
; as an argument to the preceeding INC $nn (opcode $E6).
|
||||
|
||||
lda $EA
|
||||
and #$80
|
||||
sta $EA
|
||||
|
||||
// FALLTHROUGH
|
||||
; FALLTHROUGH
|
||||
|
||||
do_basic_error: // error code in .X
|
||||
do_basic_error: ; error code in .X
|
||||
|
||||
#if ROM_LAYOUT_M65
|
||||
// Make sure we are back with normal memory map
|
||||
!ifdef ROM_LAYOUT_M65 {
|
||||
; Make sure we are back with normal memory map
|
||||
jsr map_NORMAL
|
||||
#endif
|
||||
}
|
||||
|
||||
// Clear all temporary variables, print "?"
|
||||
; Clear all temporary variables, print "?"
|
||||
|
||||
phx_trash_a
|
||||
+phx_trash_a
|
||||
jsr tmpstr_free_all
|
||||
ldx #IDX__STR_RET_QM
|
||||
jsr print_packed_misc_str
|
||||
plx_trash_a
|
||||
+plx_trash_a
|
||||
|
||||
// Error message text + " ERROR"
|
||||
; Error message text + " ERROR"
|
||||
|
||||
jsr print_packed_error
|
||||
|
||||
ldx #IDX__STR_ERROR
|
||||
jsr print_packed_misc_str
|
||||
|
||||
// Check if direct mode
|
||||
; Check if direct mode
|
||||
|
||||
lda CURLIN+1
|
||||
cmp #$FF
|
||||
beq !+
|
||||
beq @1
|
||||
|
||||
// We were in a program, so show IN <line>
|
||||
; We were in a program, so show IN <line>
|
||||
|
||||
ldx #IDX__STR_IN
|
||||
jsr print_packed_misc_str
|
||||
@@ -211,12 +211,12 @@ do_basic_error: // error code in .X
|
||||
lda CURLIN+1
|
||||
ldx CURLIN+0
|
||||
jsr print_integer
|
||||
!:
|
||||
// Reset stack, and go back to main loop
|
||||
@1:
|
||||
; Reset stack, and go back to main loop
|
||||
|
||||
ldx #$FE
|
||||
txs
|
||||
|
||||
jmp shell_main_loop
|
||||
|
||||
#endif // ROM layout
|
||||
} ; ROM layout
|
||||
@@ -1,35 +1,40 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# M65 * #TAKE
|
||||
// #LAYOUT# X16 BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# M65 * #TAKE
|
||||
;; #LAYOUT# X16 BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
// See https://www.c64-wiki.com/wiki/Memory_(BASIC) for BASIC memory organization
|
||||
; See https://www.c64-wiki.com/wiki/Memory_(BASIC) for BASIC memory organization
|
||||
|
||||
|
||||
do_new:
|
||||
do_new:
|
||||
|
||||
#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_0)
|
||||
!ifdef SEGMENT_M65_BASIC_0 {
|
||||
|
||||
jsr map_BASIC_1
|
||||
jsr_ind VB1__do_new
|
||||
jmp map_NORMAL
|
||||
jsr map_BASIC_1
|
||||
jsr (VB1__do_new)
|
||||
+bra do_restore_end
|
||||
|
||||
do_clr:
|
||||
|
||||
jsr map_BASIC_1
|
||||
jsr_ind VB1__do_clr
|
||||
jmp map_NORMAL
|
||||
jsr map_BASIC_1
|
||||
jsr (VB1__do_clr)
|
||||
+bra do_restore_end
|
||||
|
||||
do_restore:
|
||||
|
||||
jsr map_BASIC_1
|
||||
jsr_ind VB1__do_restore
|
||||
jmp map_NORMAL
|
||||
jsr map_BASIC_1
|
||||
jsr (VB1__do_restore)
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
do_restore_end:
|
||||
|
||||
#else
|
||||
jmp map_NORMAL
|
||||
|
||||
// See Computes Mapping the Commodore 64 - page 96
|
||||
} else {
|
||||
|
||||
; See Computes Mapping the Commodore 64 - page 96
|
||||
|
||||
ldy #$00
|
||||
tya
|
||||
@@ -37,7 +42,7 @@ do_restore:
|
||||
iny
|
||||
sta (TXTTAB),y
|
||||
|
||||
// The book does not mention this, but IMHO it is necessary to initialize VARTAB here too
|
||||
; The book does not mention this, but IMHO it is necessary to initialize VARTAB here too
|
||||
|
||||
clc
|
||||
lda TXTTAB+0
|
||||
@@ -49,9 +54,9 @@ do_restore:
|
||||
|
||||
do_clr:
|
||||
|
||||
// See Computes Mapping the Commodore 64 - page 96
|
||||
; See Computes Mapping the Commodore 64 - page 96
|
||||
|
||||
// XXX check if original ROM does this too
|
||||
; XXX check if original ROM does this too
|
||||
jsr JCLALL
|
||||
|
||||
lda MEMSIZ+0
|
||||
@@ -59,7 +64,7 @@ do_clr:
|
||||
lda MEMSIZ+1
|
||||
sta FRETOP+1
|
||||
|
||||
// The book is not precise here $31-$32 is definitely not the end of BASIC text
|
||||
; The book is not precise here $31-$32 is definitely not the end of BASIC text
|
||||
|
||||
lda VARTAB+0
|
||||
sta ARYTAB+0
|
||||
@@ -69,18 +74,18 @@ do_clr:
|
||||
sta ARYTAB+1
|
||||
sta STREND+1
|
||||
|
||||
// This is a good place to reset the temporary string stack
|
||||
; This is a good place to reset the temporary string stack
|
||||
|
||||
jsr tmpstr_free_all_reset
|
||||
|
||||
// FALLTROUGH (confirmed on real C64 that CLR indeed resets DATPTR)
|
||||
; FALLTROUGH (confirmed on real C64 that CLR indeed resets DATPTR)
|
||||
|
||||
do_restore:
|
||||
|
||||
// See Computes Mapping the Commodore 64 - page 98
|
||||
// Initial DATPTR value checked on real C64
|
||||
; See Computes Mapping the Commodore 64 - page 98
|
||||
; Initial DATPTR value checked on real C64
|
||||
|
||||
#if HAS_OPCODES_65CE02
|
||||
!ifdef HAS_OPCODES_65CE02 {
|
||||
|
||||
lda TXTTAB+0
|
||||
sta DATPTR+0
|
||||
@@ -89,7 +94,7 @@ do_restore:
|
||||
|
||||
dew DATPTR
|
||||
|
||||
#else
|
||||
} else {
|
||||
|
||||
sec
|
||||
lda TXTTAB+0
|
||||
@@ -98,10 +103,8 @@ do_restore:
|
||||
lda TXTTAB+1
|
||||
sbc #$00
|
||||
sta DATPTR+1
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
rts
|
||||
|
||||
|
||||
#endif // ROM layout
|
||||
} ; ROM layout
|
||||
@@ -1,10 +1,10 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Executes the next command - after previous got finished
|
||||
//
|
||||
;
|
||||
; Executes the next command - after previous got finished
|
||||
;
|
||||
|
||||
|
||||
end_of_statement:
|
||||
@@ -12,12 +12,12 @@ end_of_statement:
|
||||
jsr tmpstr_free_all
|
||||
jsr fetch_character_skip_spaces
|
||||
|
||||
cmp #$3A // check for colon
|
||||
beq_16 execute_statements
|
||||
cmp #$3A ; check for colon
|
||||
+beq execute_statements
|
||||
|
||||
cmp #$00 // check for end of the line
|
||||
beq_16 execute_statements_end_of_line
|
||||
cmp #$00 ; check for end of the line
|
||||
+beq execute_statements_end_of_line
|
||||
|
||||
// Unexpected character
|
||||
; Unexpected character
|
||||
|
||||
jmp do_SYNTAX_error
|
||||
@@ -1,72 +1,71 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Tries to execute the statement, and all the subsequent ones
|
||||
//
|
||||
;
|
||||
; Tries to execute the statement, and all the subsequent ones
|
||||
;
|
||||
|
||||
|
||||
execute_statements:
|
||||
|
||||
// Check for RUN/STOP
|
||||
; Check for RUN/STOP
|
||||
|
||||
lda STKEY
|
||||
bpl_16 cmd_stop
|
||||
+bpl cmd_stop
|
||||
|
||||
// Skip over any white spaces and colons (':')
|
||||
!:
|
||||
; Skip over any white spaces and colons (':')
|
||||
@1:
|
||||
jsr fetch_character_skip_spaces
|
||||
cmp #$3A // colon, can be skipped
|
||||
beq !-
|
||||
cmp #$3A ; colon, can be skipped
|
||||
beq @1
|
||||
|
||||
// Check if end of the line
|
||||
; Check if end of the line
|
||||
|
||||
cmp #$00
|
||||
beq execute_statements_end_of_line
|
||||
|
||||
// Not end of the line - it seems we actually have something to execute
|
||||
; Not end of the line - it seems we actually have something to execute
|
||||
|
||||
// Move token code to .X
|
||||
; Move token code to .X
|
||||
tax
|
||||
|
||||
// Push the 'end_of_statement' address for RTS
|
||||
; Push the 'end_of_statement' address for RTS
|
||||
|
||||
lda #>(end_of_statement - 1)
|
||||
pha
|
||||
lda #<(end_of_statement - 1)
|
||||
pha
|
||||
|
||||
// Check if token is valid for execution
|
||||
; Check if token is valid for execution
|
||||
|
||||
#if HAS_SMALL_BASIC
|
||||
!ifdef HAS_SMALL_BASIC {
|
||||
|
||||
cpx #$01
|
||||
beq execute_statements_01
|
||||
|
||||
#else
|
||||
} else {
|
||||
|
||||
#if ROM_LAYOUT_M65
|
||||
!ifdef CONFIG_MB_M65 {
|
||||
cpx #$04
|
||||
#else
|
||||
} else {
|
||||
cpx #$03
|
||||
#endif
|
||||
}
|
||||
bcc execute_statements_extended
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
cpx #$CB
|
||||
beq_16 cmd_go // // 'GO' command has a strange token, placed after function tokens
|
||||
+beq cmd_go ; 'GO' command has a strange token, placed after function tokens
|
||||
|
||||
cpx #$7F
|
||||
bcc_16 execute_statements_var_assign // not a token - try variable assign
|
||||
+bcc execute_statements_var_assign ; not a token - try variable assign
|
||||
|
||||
cpx #$A7
|
||||
bcs_16 do_SYNTAX_error
|
||||
+bcs do_SYNTAX_error
|
||||
|
||||
#if !HAS_OPCODES_65C02
|
||||
!ifndef HAS_OPCODES_65C02 {
|
||||
|
||||
// Get the jump table entry for it, push it on the stack, and then RTS to start it.
|
||||
; Get the jump table entry for it, push it on the stack, and then RTS to start it.
|
||||
|
||||
lda command_jumptable_hi - $80, x
|
||||
pha
|
||||
@@ -75,24 +74,23 @@ execute_statements:
|
||||
|
||||
rts
|
||||
|
||||
#else // HAS_OPCODES_65C02
|
||||
} else { ; HAS_OPCODES_65C02
|
||||
|
||||
// Use jumptable to go to the command routine
|
||||
; Use jumptable to go to the command routine
|
||||
|
||||
txa
|
||||
asl
|
||||
tax
|
||||
jmp (command_jumptable, x)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !HAS_SMALL_BASIC
|
||||
!ifndef HAS_SMALL_BASIC {
|
||||
|
||||
execute_statements_extended:
|
||||
|
||||
// Support for extended BASIC commands
|
||||
; Support for extended BASIC commands
|
||||
|
||||
// XXX consider jumpable here
|
||||
; XXX consider jumpable here
|
||||
|
||||
cpx #$01
|
||||
beq execute_statements_01
|
||||
@@ -100,33 +98,31 @@ execute_statements_extended:
|
||||
cpx #$02
|
||||
beq execute_statements_02
|
||||
|
||||
#if ROM_LAYOUT_M65
|
||||
!ifdef CONGIH_MB_M65 {
|
||||
|
||||
cpx #$03
|
||||
beq execute_statements_03
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
jmp do_SYNTAX_error
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
execute_statements_01:
|
||||
|
||||
// Get the sub-token, check that it is valid
|
||||
; Get the sub-token, check that it is valid
|
||||
|
||||
jsr fetch_character
|
||||
cmp #$00
|
||||
beq_16 do_SYNTAX_error
|
||||
+beq do_SYNTAX_error
|
||||
|
||||
cmp #(TK__MAXTOKEN_keywords_01+1)
|
||||
bcs_16 do_SYNTAX_error
|
||||
+bcs do_SYNTAX_error
|
||||
|
||||
// Execute command
|
||||
; Execute command
|
||||
|
||||
#if !HAS_OPCODES_65C02
|
||||
!ifndef HAS_OPCODES_65C02 {
|
||||
|
||||
// Get the jump table entry for it, push it on the stack, and then RTS to start it.
|
||||
; Get the jump table entry for it, push it on the stack, and then RTS to start it.
|
||||
|
||||
tax
|
||||
lda command_01_jumptable_hi - 1, x
|
||||
@@ -136,34 +132,33 @@ execute_statements_01:
|
||||
|
||||
rts
|
||||
|
||||
#else // HAS_OPCODES_65C02
|
||||
} else { ; HAS_OPCODES_65C02
|
||||
|
||||
// Use jumptable to go to the command routine
|
||||
; Use jumptable to go to the command routine
|
||||
|
||||
asl
|
||||
tax
|
||||
jmp (command_01_jumptable - 2, x)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !HAS_SMALL_BASIC
|
||||
!ifndef HAS_SMALL_BASIC {
|
||||
|
||||
execute_statements_02:
|
||||
|
||||
// Get the sub-token, check that it is valid
|
||||
; Get the sub-token, check that it is valid
|
||||
|
||||
jsr fetch_character
|
||||
cmp #$00
|
||||
beq_16 do_SYNTAX_error
|
||||
+beq do_SYNTAX_error
|
||||
|
||||
cmp #(TK__MAXTOKEN_keywords_02+1)
|
||||
bcs_16 do_SYNTAX_error
|
||||
+bcs do_SYNTAX_error
|
||||
|
||||
// Execute command
|
||||
; Execute command
|
||||
|
||||
#if !HAS_OPCODES_65C02
|
||||
!ifndef HAS_OPCODES_65C02 {
|
||||
|
||||
// Get the jump table entry for it, push it on the stack, and then RTS to start it.
|
||||
; Get the jump table entry for it, push it on the stack, and then RTS to start it.
|
||||
|
||||
tax
|
||||
lda command_02_jumptable_hi - 1, x
|
||||
@@ -173,75 +168,74 @@ execute_statements_02:
|
||||
|
||||
rts
|
||||
|
||||
#else // HAS_OPCODES_65C02
|
||||
} else { ; HAS_OPCODES_65C02
|
||||
|
||||
// Use jumptable to go to the command routine
|
||||
; Use jumptable to go to the command routine
|
||||
|
||||
asl
|
||||
tax
|
||||
jmp (command_02_jumptable - 2, x)
|
||||
}
|
||||
|
||||
#endif
|
||||
} ; !HAS_SMALL_BASIC
|
||||
|
||||
#endif // !HAS_SMALL_BASIC
|
||||
|
||||
#if ROM_LAYOUT_M65
|
||||
!ifdef CONFIG_MB_M65 {
|
||||
|
||||
execute_statements_03:
|
||||
|
||||
// Get the sub-token, check that it is valid
|
||||
; Get the sub-token, check that it is valid
|
||||
|
||||
jsr fetch_character
|
||||
cmp #$00
|
||||
beq_16 do_SYNTAX_error
|
||||
+beq do_SYNTAX_error
|
||||
|
||||
cmp #(TK__MAXTOKEN_keywords_03+1)
|
||||
bcs_16 do_SYNTAX_error
|
||||
+bcs do_SYNTAX_error
|
||||
|
||||
// Use jumptable to go to the command routine
|
||||
; Use jumptable to go to the command routine
|
||||
|
||||
asl
|
||||
tax
|
||||
jmp (command_03_jumptable - 2, x)
|
||||
|
||||
#endif // ROM_LAYOUT_M65
|
||||
} ; CONFIG_MB_M65
|
||||
|
||||
execute_statements_end_of_line:
|
||||
|
||||
// First check, if we are in direct mode - if so,
|
||||
// end the execution and go to main loop
|
||||
; First check, if we are in direct mode - if so,
|
||||
; end the execution and go to main loop
|
||||
|
||||
ldx CURLIN+1
|
||||
inx
|
||||
beq_16 shell_main_loop
|
||||
+beq shell_main_loop
|
||||
|
||||
// Advance to the next line - first copy the line number
|
||||
// to previous line number
|
||||
; Advance to the next line - first copy the line number
|
||||
; to previous line number
|
||||
|
||||
lda CURLIN+0
|
||||
sta OLDLIN+0
|
||||
lda CURLIN+1
|
||||
sta OLDLIN+1
|
||||
|
||||
// Advance the basic line pointer to the next line; if end,
|
||||
// go to the main loop
|
||||
; Advance the basic line pointer to the next line; if end,
|
||||
; go to the main loop
|
||||
|
||||
jsr follow_link_to_next_line
|
||||
|
||||
lda OLDTXT+0
|
||||
ora OLDTXT+1
|
||||
beq_16 shell_main_loop
|
||||
+beq shell_main_loop
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
execute_line:
|
||||
|
||||
// Check if pointer is null, if so, we are at the end of the program
|
||||
; Check if pointer is null, if so, we are at the end of the program
|
||||
|
||||
jsr is_line_pointer_null
|
||||
beq_16 shell_main_loop // branch if end of program reached
|
||||
+beq shell_main_loop ; branch if end of program reached
|
||||
|
||||
// Skip pointer and line number to get address of first statement
|
||||
; Skip pointer and line number to get address of first statement
|
||||
|
||||
lda OLDTXT+0
|
||||
clc
|
||||
@@ -253,25 +247,25 @@ execute_line:
|
||||
|
||||
ldy #$02
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
!ifdef CONFIG_MEMORY_MODEL_60K {
|
||||
ldx #<OLDTXT
|
||||
jsr peek_under_roms
|
||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
jsr peek_under_roms_via_OLDTXT
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
} else ifdef CONFIG_MEMORY_MODEL_46K_OR_50K {
|
||||
jsr peek_under_roms_via_OLDTXT ; XXX! speed-optimize - combine whole flow into one routine
|
||||
} else { ; CONFIG_MEMORY_MODEL_38K
|
||||
lda (OLDTXT),y
|
||||
#endif
|
||||
}
|
||||
|
||||
sta CURLIN+0
|
||||
iny
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
!ifdef CONFIG_MEMORY_MODEL_60K {
|
||||
jsr peek_under_roms
|
||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
} else ifdef CONFIG_MEMORY_MODEL_46K_OR_50K {
|
||||
jsr peek_under_roms_via_OLDTXT
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
} else { ; CONFIG_MEMORY_MODEL_38K
|
||||
lda (OLDTXT),y
|
||||
#endif
|
||||
}
|
||||
|
||||
sta CURLIN+1
|
||||
|
||||
@@ -280,22 +274,22 @@ execute_line:
|
||||
|
||||
execute_statements_var_assign:
|
||||
|
||||
// Prevent wedges from being executed within a program
|
||||
; Prevent wedges from being executed within a program
|
||||
|
||||
#if CONFIG_TAPE_WEDGE
|
||||
!ifdef CONFIG_TAPE_WEDGE {
|
||||
cpx #$40
|
||||
beq_16 do_DIRECT_MODE_ONLY_error
|
||||
#endif
|
||||
#if CONFIG_DOS_WEDGE
|
||||
+beq do_DIRECT_MODE_ONLY_error
|
||||
}
|
||||
!ifdef CONFIG_DOS_WEDGE {
|
||||
cpx #$5F
|
||||
beq_16 do_DIRECT_MODE_ONLY_error
|
||||
#endif
|
||||
+beq do_DIRECT_MODE_ONLY_error
|
||||
}
|
||||
|
||||
// Try variable assignment - execute as LET command
|
||||
; Try variable assignment - execute as LET command
|
||||
|
||||
#if !HAS_OPCODES_65CE02
|
||||
!ifndef HAS_OPCODES_65CE02 {
|
||||
jsr unconsume_character
|
||||
#else
|
||||
} else {
|
||||
dew TXTPTR
|
||||
#endif
|
||||
}
|
||||
jmp assign_variable
|
||||
@@ -1,21 +1,21 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Fetches line number, stores it in LINNUM, sets Carry to indicate failure (not a number)
|
||||
//
|
||||
// Preserves both .X and .Y
|
||||
//
|
||||
;
|
||||
; Fetches line number, stores it in LINNUM, sets Carry to indicate failure (not a number)
|
||||
;
|
||||
; Preserves both .X and .Y
|
||||
;
|
||||
|
||||
fetch_line_number:
|
||||
|
||||
lda #IDX__EV7_26 // 'LINE NUMBER TOO LARGE'
|
||||
lda #IDX__EV7_26 ; 'LINE NUMBER TOO LARGE'
|
||||
jsr fetch_uint16
|
||||
bcs_16 do_SYNTAX_error
|
||||
+bcs do_SYNTAX_error
|
||||
|
||||
lda LINNUM+1
|
||||
cmp #$FF
|
||||
beq_16 do_LINE_NUMBER_TOO_LARGE_error
|
||||
+beq do_LINE_NUMBER_TOO_LARGE_error
|
||||
|
||||
rts
|
||||
@@ -1,30 +1,30 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Fetches an operator - for the expression parser
|
||||
//
|
||||
// Note: does not recognize unary operators
|
||||
//
|
||||
;
|
||||
; Fetches an operator - for the expression parser
|
||||
;
|
||||
; Note: does not recognize unary operators
|
||||
;
|
||||
|
||||
|
||||
fetch_operator: // XXX change the operator code to start from 0
|
||||
fetch_operator: ; XXX change the operator code to start from 0
|
||||
|
||||
// Retrieve the next character
|
||||
; Retrieve the next character
|
||||
|
||||
jsr fetch_character
|
||||
|
||||
// Check if within range
|
||||
; Check if within range
|
||||
|
||||
sec
|
||||
sbc #$AA
|
||||
bcc fetch_operator_failed // branch if below 0
|
||||
bcc fetch_operator_failed ; branch if below 0
|
||||
|
||||
cmp #$0A
|
||||
bcs fetch_operator_failed // branch if $0A or greater
|
||||
bcs fetch_operator_failed ; branch if $0A or greater
|
||||
|
||||
// Now we have to recognize '>=', '<=' and '<>' operators
|
||||
; Now we have to recognize '>=', '<=' and '<>' operators
|
||||
|
||||
cmp #$07
|
||||
beq fetch_operator_try_gteq
|
||||
@@ -32,7 +32,7 @@ fetch_operator: // XXX change the operator code to start from 0
|
||||
cmp #$09
|
||||
beq fetch_operator_try_lteq_neq
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
fetch_operator_success:
|
||||
|
||||
@@ -41,11 +41,11 @@ fetch_operator_success:
|
||||
|
||||
fetch_operator_failed:
|
||||
|
||||
#if !HAS_OPCODES_65CE02
|
||||
!ifndef HAS_OPCODES_65CE02 {
|
||||
jsr unconsume_character
|
||||
#else
|
||||
} else {
|
||||
dew TXTPTR
|
||||
#endif
|
||||
}
|
||||
|
||||
sec
|
||||
rts
|
||||
@@ -53,54 +53,54 @@ fetch_operator_failed:
|
||||
|
||||
fetch_operator_try_gteq:
|
||||
|
||||
// Here we distinguish between '>' and '>='
|
||||
; Here we distinguish between '>' and '>='
|
||||
|
||||
jsr fetch_character
|
||||
cmp #$B2 // '='
|
||||
beq !+
|
||||
cmp #$B2 ; '='
|
||||
beq @1
|
||||
|
||||
// This is a '>'
|
||||
; This is a '>'
|
||||
|
||||
#if !HAS_OPCODES_65CE02
|
||||
!ifndef HAS_OPCODES_65CE02 {
|
||||
jsr unconsume_character
|
||||
#else
|
||||
} else {
|
||||
dew TXTPTR
|
||||
#endif
|
||||
}
|
||||
lda #$07
|
||||
bne fetch_operator_success // branch always
|
||||
!:
|
||||
// This is a '>='
|
||||
bne fetch_operator_success ; branch always
|
||||
@1:
|
||||
; This is a '>='
|
||||
|
||||
lda #$0A
|
||||
bne fetch_operator_success // branch always
|
||||
bne fetch_operator_success ; branch always
|
||||
|
||||
|
||||
fetch_operator_try_lteq_neq:
|
||||
|
||||
// Here we distinguish between '<', '<=', and '<>'
|
||||
; Here we distinguish between '<', '<=', and '<>'
|
||||
|
||||
jsr fetch_character
|
||||
cmp #$B2 // '='
|
||||
beq !+
|
||||
cmp #$B1 // '>'
|
||||
beq !++
|
||||
cmp #$B2 ; '='
|
||||
beq @2
|
||||
cmp #$B1 ; '>'
|
||||
beq @3
|
||||
|
||||
// This is a '<'
|
||||
; This is a '<'
|
||||
|
||||
#if !HAS_OPCODES_65CE02
|
||||
!ifndef HAS_OPCODES_65CE02 {
|
||||
jsr unconsume_character
|
||||
#else
|
||||
} else {
|
||||
dew TXTPTR
|
||||
#endif
|
||||
}
|
||||
lda #$09
|
||||
bne fetch_operator_success // branch always
|
||||
!:
|
||||
// This is a '<='
|
||||
bne fetch_operator_success ; branch always
|
||||
@2:
|
||||
; This is a '<='
|
||||
|
||||
lda #$0B
|
||||
bne fetch_operator_success // branch always
|
||||
!:
|
||||
// This is a '<>'
|
||||
bne fetch_operator_success ; branch always
|
||||
@3:
|
||||
; This is a '<>'
|
||||
|
||||
lda #$0C
|
||||
bne fetch_operator_success // branch always
|
||||
bne fetch_operator_success ; branch always
|
||||
@@ -1,49 +1,49 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Fetches unsigned 16-bit integer, stores it in LINNUM, sets Carry to indicate failure (not a number)
|
||||
//
|
||||
// If value above 65535, error depends on .A opn entry
|
||||
//
|
||||
// Preserves both .X and .Y
|
||||
//
|
||||
;
|
||||
; Fetches unsigned 16-bit integer, stores it in LINNUM, sets Carry to indicate failure (not a number)
|
||||
;
|
||||
; If value above 65535, error depends on .A opn entry
|
||||
;
|
||||
; Preserves both .X and .Y
|
||||
;
|
||||
|
||||
fetch_uint16:
|
||||
|
||||
// Push the error code to stack
|
||||
; Push the error code to stack
|
||||
|
||||
pha
|
||||
|
||||
// Fetch the first character (skip spaces), check if 0-9
|
||||
; Fetch the first character (skip spaces), check if 0-9
|
||||
|
||||
jsr fetch_character_skip_spaces
|
||||
|
||||
jsr convert_PETSCII_to_digit
|
||||
bcs fetch_uint16_rts
|
||||
|
||||
// First character seems to be correct - store it
|
||||
; First character seems to be correct - store it
|
||||
|
||||
sta LINNUM+0
|
||||
lda #$00
|
||||
sta LINNUM+1
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
fetch_uint16_loop:
|
||||
|
||||
// Try to fetch another digit
|
||||
; Try to fetch another digit
|
||||
|
||||
jsr fetch_character
|
||||
jsr convert_PETSCII_to_digit
|
||||
bcs fetch_uint16_end
|
||||
|
||||
// We got another digit - store it
|
||||
; We got another digit - store it
|
||||
|
||||
pha
|
||||
|
||||
// Multiply current LINNUM by 10 (x * 10 = (x * 2) + (x * 2) * 4)
|
||||
; Multiply current LINNUM by 10 (x * 10 = (x * 2) + (x * 2) * 4)
|
||||
|
||||
jsr fetch_uint16_mul_LINNUM_2
|
||||
bcs fetch_uint16_1PLA_error
|
||||
@@ -67,7 +67,7 @@ fetch_uint16_loop:
|
||||
sta LINNUM+1
|
||||
bcs fetch_uint16_1PLA_error
|
||||
|
||||
// Add the new digit to LINNUM
|
||||
; Add the new digit to LINNUM
|
||||
|
||||
pla
|
||||
clc
|
||||
@@ -78,20 +78,20 @@ fetch_uint16_loop:
|
||||
sta LINNUM+1
|
||||
bcs fetch_uint16_error
|
||||
|
||||
// Next iteration
|
||||
; Next iteration
|
||||
|
||||
jmp_8 fetch_uint16_loop
|
||||
+bra fetch_uint16_loop
|
||||
|
||||
fetch_uint16_end:
|
||||
|
||||
#if !HAS_OPCODES_65CE02
|
||||
!ifndef HAS_OPCODES_65CE02 {
|
||||
jsr unconsume_character
|
||||
#else
|
||||
} else {
|
||||
dew TXTPTR
|
||||
#endif
|
||||
}
|
||||
clc
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
fetch_uint16_rts:
|
||||
|
||||
@@ -110,15 +110,15 @@ fetch_uint16_3PLA_error:
|
||||
pla
|
||||
pla
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
fetch_uint16_1PLA_error:
|
||||
|
||||
pla
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
fetch_uint16_error:
|
||||
|
||||
plx_trash_a
|
||||
+plx_trash_a
|
||||
jmp do_basic_error
|
||||
@@ -1,27 +1,31 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Fetches 8-bit unsigned integer
|
||||
//
|
||||
;
|
||||
; Fetches 8-bit unsigned integer
|
||||
;
|
||||
|
||||
|
||||
fetch_coma_uint8:
|
||||
|
||||
jsr injest_comma
|
||||
bcs !+
|
||||
bcs fetch_uint8_end
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
fetch_uint8:
|
||||
|
||||
lda #IDX__EV2_0E // 'ILLEGAL QUANTITY ERROR'
|
||||
lda #IDX__EV2_0E ; 'ILLEGAL QUANTITY ERROR'
|
||||
jsr fetch_uint16
|
||||
bcs !+
|
||||
bcs fetch_uint8_end
|
||||
lda LINNUM+1
|
||||
bne_16 do_ILLEGAL_QUANTITY_error
|
||||
+bne do_ILLEGAL_QUANTITY_error
|
||||
lda LINNUM+0
|
||||
clc
|
||||
!:
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
fetch_uint8_end:
|
||||
|
||||
rts
|
||||
@@ -1,30 +1,32 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
follow_link_to_next_line:
|
||||
|
||||
ldy #0
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
; XXX! for models 46K/50K provide optimized version
|
||||
|
||||
!ifdef CONFIG_MEMORY_MODEL_60K {
|
||||
ldx #<OLDTXT+0
|
||||
jsr peek_under_roms
|
||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
} else ifdef CONFIG_MEMORY_MODEL_46K_OR_50K {
|
||||
jsr peek_under_roms_via_OLDTXT
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
} else { ; CONFIG_MEMORY_MODEL_38K
|
||||
lda (OLDTXT),y
|
||||
#endif
|
||||
}
|
||||
|
||||
pha
|
||||
iny
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
!ifdef CONFIG_MEMORY_MODEL_60K {
|
||||
jsr peek_under_roms
|
||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
} else ifdef CONFIG_MEMORY_MODEL_46K_OR_50K {
|
||||
jsr peek_under_roms_via_OLDTXT
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
} else { ; CONFIG_MEMORY_MODEL_38K
|
||||
lda (OLDTXT),y
|
||||
#endif
|
||||
}
|
||||
|
||||
sta OLDTXT+1
|
||||
pla
|
||||
|
||||
+144
-141
@@ -1,87 +1,87 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
// Well-known BASIC routine, described in:
|
||||
//
|
||||
// - [CM64] Computes Mapping the Commodore 64 - page 102
|
||||
// - https://sta.c64.org/cbm64basconv.html
|
||||
//
|
||||
// Output:
|
||||
// - VALTYP - $00 = floating number, $FF = string
|
||||
// - for float: FAC1
|
||||
// - for string: __FAC1 + 0 = length, __FAC1 + 1 = pointer to string
|
||||
//
|
||||
// Idea:
|
||||
// - use a stack to reorder operations, so that they can be executed
|
||||
// in a correct order
|
||||
//
|
||||
; Well-known BASIC routine, described in:
|
||||
;
|
||||
; - [CM64] Computes Mapping the Commodore 64 - page 102
|
||||
; - https://sta.c64.org/cbm64basconv.html
|
||||
;
|
||||
; Output:
|
||||
; - VALTYP - $00 = floating number, $FF = string
|
||||
; - for float: FAC1
|
||||
; - for string: __FAC1 + 0 = length, __FAC1 + 1 = pointer to string
|
||||
;
|
||||
; Idea:
|
||||
; - use a stack to reorder operations, so that they can be executed
|
||||
; in a correct order
|
||||
;
|
||||
|
||||
// XXX finish the implementation: invoking functions, fetching floats
|
||||
; XXX finish the implementation: invoking functions, fetching floats
|
||||
|
||||
|
||||
FRMEVL:
|
||||
|
||||
// Push the sentinel to the stack
|
||||
; Push the sentinel to the stack
|
||||
|
||||
lda #$00
|
||||
pha
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
FRMEVL_loop:
|
||||
|
||||
// At this point there are 4 valid possibilities:
|
||||
// - a string, a float, pi, or a variable (in short: a value to fetch)
|
||||
// - a token (whichj means function to execute)
|
||||
// - an unary operator
|
||||
// - an opening bracket
|
||||
; At this point there are 4 valid possibilities:
|
||||
; - a string, a float, pi, or a variable (in short: a value to fetch)
|
||||
; - a token (whichj means function to execute)
|
||||
; - an unary operator
|
||||
; - an opening bracket
|
||||
|
||||
// Check if end of statement, fetch the character
|
||||
; Check if end of statement, fetch the character
|
||||
|
||||
jsr is_end_of_statement
|
||||
bcs_16 do_SYNTAX_error
|
||||
+bcs do_SYNTAX_error
|
||||
jsr fetch_character
|
||||
|
||||
// Check for a string or opening bracket
|
||||
; Check for a string or opening bracket
|
||||
|
||||
cmp #$22 // check for opening quote
|
||||
cmp #$22 ; check for opening quote
|
||||
beq FRMEVL_fetch_string
|
||||
cmp #$28 // check for opening bracket
|
||||
cmp #$28 ; check for opening bracket
|
||||
beq FRMEVL_handle_bracket
|
||||
|
||||
// Check for unary operators
|
||||
; Check for unary operators
|
||||
|
||||
cmp #$AB // check for unary minus
|
||||
beq_16 FRMEVL_unary_minus
|
||||
cmp #$A8 // check for NOT
|
||||
beq_16 FRMEVL_unary_not
|
||||
cmp #$AB ; check for unary minus
|
||||
+beq FRMEVL_unary_minus
|
||||
cmp #$A8 ; check for NOT
|
||||
+beq FRMEVL_unary_not
|
||||
|
||||
// Check for the PI
|
||||
; Check for the PI
|
||||
|
||||
cmp #$FF // check for PI
|
||||
beq_16 FRMEVL_fetch_PI
|
||||
cmp #$FF ; check for PI
|
||||
+beq FRMEVL_fetch_PI
|
||||
|
||||
// If not a PI and not an unary operator, than everything above
|
||||
// $7F has to be a function
|
||||
; If not a PI and not an unary operator, than everything above
|
||||
; $7F has to be a function
|
||||
|
||||
cmp #$80 // check for a token
|
||||
cmp #$80 ; check for a token
|
||||
bcs FRMEVL_execute_function
|
||||
|
||||
// Check for a variable
|
||||
; Check for a variable
|
||||
|
||||
#if !HAS_OPCODES_65CE02
|
||||
!ifndef HAS_OPCODES_65CE02 {
|
||||
jsr unconsume_character
|
||||
#else
|
||||
} else {
|
||||
dew TXTPTR
|
||||
#endif
|
||||
}
|
||||
jsr fetch_variable
|
||||
bcs FRMEVL_fetch_float
|
||||
|
||||
// Found the variable - copy descriptor to FAC1
|
||||
; Found the variable - copy descriptor to FAC1
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
!ifdef CONFIG_MEMORY_MODEL_60K {
|
||||
|
||||
ldx #<VARPNT
|
||||
|
||||
@@ -95,11 +95,11 @@ FRMEVL_loop:
|
||||
jsr peek_under_roms
|
||||
sta __FAC1+2
|
||||
|
||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
} else ifdef CONFIG_MEMORY_MODEL_46K_OR_50K {
|
||||
|
||||
jsr helper_frmevl_strdesccpy
|
||||
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
} else { ; CONFIG_MEMORY_MODEL_38K
|
||||
|
||||
ldy #$00
|
||||
lda (VARPNT),y
|
||||
@@ -110,56 +110,55 @@ FRMEVL_loop:
|
||||
iny
|
||||
lda (VARPNT),y
|
||||
sta __FAC1+2
|
||||
}
|
||||
|
||||
#endif
|
||||
+bra FRMEVL_got_value
|
||||
|
||||
jmp_8 FRMEVL_got_value
|
||||
|
||||
//
|
||||
// This subroutine handles the situation when we have to execute a BASIC function
|
||||
// in place when parser normally expects a value
|
||||
//
|
||||
;
|
||||
; This subroutine handles the situation when we have to execute a BASIC function
|
||||
; in place when parser normally expects a value
|
||||
;
|
||||
|
||||
FRMEVL_execute_function:
|
||||
|
||||
// XXX implement this - use function_jumptable*
|
||||
; XXX implement this - use function_jumptable*
|
||||
|
||||
jmp do_NOT_IMPLEMENTED_error
|
||||
|
||||
//
|
||||
// These two subroutines handles the situation when we got an unary operator
|
||||
// in place when parser normally expects a value
|
||||
//
|
||||
;
|
||||
; These two subroutines handles the situation when we got an unary operator
|
||||
; in place when parser normally expects a value
|
||||
;
|
||||
|
||||
FRMEVL_unary_not:
|
||||
|
||||
ldy #$0D // our code for unary NOT
|
||||
skip_2_bytes_trash_nvz
|
||||
ldy #$0D ; our code for unary NOT
|
||||
+skip_2_bytes_trash_nvz
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
FRMEVL_unary_minus:
|
||||
|
||||
ldy #$0E // our code for unary NOT
|
||||
ldy #$0E ; our code for unary NOT
|
||||
jmp FRMEVL_push_operator_address
|
||||
|
||||
//
|
||||
// This subroutine handle brackets - it just calls FRMEVL recursively
|
||||
// and consumes the closing bracket afterwards
|
||||
//
|
||||
;
|
||||
; This subroutine handle brackets - it just calls FRMEVL recursively
|
||||
; and consumes the closing bracket afterwards
|
||||
;
|
||||
|
||||
FRMEVL_handle_bracket:
|
||||
|
||||
jsr FRMEVL
|
||||
jsr fetch_character
|
||||
cmp #$29 // closing bracket
|
||||
cmp #$29 ; closing bracket
|
||||
beq FRMEVL_got_value
|
||||
|
||||
jmp do_SYNTAX_error
|
||||
|
||||
//
|
||||
// This subroutine handles the situation when our value to fetch is PI
|
||||
//
|
||||
;
|
||||
; This subroutine handles the situation when our value to fetch is PI
|
||||
;
|
||||
|
||||
FRMEVL_fetch_PI:
|
||||
|
||||
@@ -167,19 +166,19 @@ FRMEVL_fetch_PI:
|
||||
ldy #>const_PI
|
||||
jsr mov_MEM_FAC1
|
||||
|
||||
jmp_8 FRMEVL_got_value_float
|
||||
+bra FRMEVL_got_value_float
|
||||
|
||||
//
|
||||
// This subroutine fetches the floating point value from the 'outside world'
|
||||
//
|
||||
;
|
||||
; This subroutine fetches the floating point value from the 'outside world'
|
||||
;
|
||||
|
||||
FRMEVL_fetch_float:
|
||||
|
||||
// XXX implement this
|
||||
; XXX implement this
|
||||
|
||||
jmp do_NOT_IMPLEMENTED_error
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
FRMEVL_got_value_float:
|
||||
|
||||
@@ -187,13 +186,13 @@ FRMEVL_got_value_float:
|
||||
sta VALTYP
|
||||
beq FRMEVL_got_value
|
||||
|
||||
//
|
||||
// This subroutine fetches the string value from the 'outside world'
|
||||
//
|
||||
;
|
||||
; This subroutine fetches the string value from the 'outside world'
|
||||
;
|
||||
|
||||
FRMEVL_fetch_string:
|
||||
|
||||
// Mark return value as a string, set initial length as 0
|
||||
; Mark return value as a string, set initial length as 0
|
||||
|
||||
ldx #$FF
|
||||
stx VALTYP
|
||||
@@ -201,69 +200,69 @@ FRMEVL_fetch_string:
|
||||
inx
|
||||
stx __FAC1 + 0
|
||||
|
||||
// Set pointer to start of the string
|
||||
; Set pointer to start of the string
|
||||
|
||||
ldx TXTPTR + 0
|
||||
stx __FAC1 + 1
|
||||
ldx TXTPTR + 1
|
||||
stx __FAC1 + 2
|
||||
!:
|
||||
// Search for closing quote
|
||||
@1:
|
||||
; Search for closing quote
|
||||
|
||||
jsr fetch_character
|
||||
cmp #$22
|
||||
beq FRMEVL_got_value
|
||||
cmp #$00
|
||||
beq !+
|
||||
beq @2
|
||||
|
||||
inc __FAC1 + 0
|
||||
bne !-
|
||||
bne @1
|
||||
|
||||
jmp do_STRING_TOO_LONG_error
|
||||
!:
|
||||
// No closing quote, but end of the data
|
||||
@2:
|
||||
; No closing quote, but end of the data
|
||||
|
||||
#if !HAS_OPCODES_65CE02
|
||||
!ifndef HAS_OPCODES_65CE02 {
|
||||
jsr unconsume_character
|
||||
#else
|
||||
} else {
|
||||
dew TXTPTR
|
||||
#endif
|
||||
}
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
|
||||
//
|
||||
// This subroutine handles the situation after fetching the value from 'outside world':
|
||||
// - either there is nothing sane remaining there; if so, this value is or final result
|
||||
// - or there is an operator following the value; in such case we have much more work to do;
|
||||
// we push the current value and the operator to the stack and we proceed to fetch the next
|
||||
// value (which is mandatory)
|
||||
// small catch: if the priority of the new operator is not higher than priority of the last
|
||||
// operator on the stack (sentinel is considered as the lowest priority operator) we first
|
||||
// compute what currently is present on the stack - this enforces proper operator precedence
|
||||
//
|
||||
;
|
||||
; This subroutine handles the situation after fetching the value from 'outside world':
|
||||
; - either there is nothing sane remaining there; if so, this value is or final result
|
||||
; - or there is an operator following the value; in such case we have much more work to do;
|
||||
; we push the current value and the operator to the stack and we proceed to fetch the next
|
||||
; value (which is mandatory)
|
||||
; small catch: if the priority of the new operator is not higher than priority of the last
|
||||
; operator on the stack (sentinel is considered as the lowest priority operator) we first
|
||||
; compute what currently is present on the stack - this enforces proper operator precedence
|
||||
;
|
||||
|
||||
FRMEVL_got_value:
|
||||
|
||||
jsr is_end_of_statement
|
||||
bcs FRMEVL_compute_all // compute the stack if expression ended
|
||||
bcs FRMEVL_compute_all ; compute the stack if expression ended
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
FRMEVL_fetch_operator:
|
||||
|
||||
// We have a value, but this is not the end of expression. Check if
|
||||
// there is an operator waiting to be served
|
||||
; We have a value, but this is not the end of expression. Check if
|
||||
; there is an operator waiting to be served
|
||||
|
||||
jsr fetch_operator
|
||||
bcs FRMEVL_compute_all // if operator not recognized, compute what we have
|
||||
// on stack and quit
|
||||
bcs FRMEVL_compute_all ; if operator not recognized, compute what we have
|
||||
; on stack and quit
|
||||
|
||||
// Move the new operator ID to .Y
|
||||
; Move the new operator ID to .Y
|
||||
|
||||
tay
|
||||
|
||||
// Compare the priority of the last operator with the new one
|
||||
; Compare the priority of the last operator with the new one
|
||||
|
||||
pla
|
||||
pha
|
||||
@@ -271,39 +270,43 @@ FRMEVL_fetch_operator:
|
||||
cmp operator_priorities, y
|
||||
bcc FRMEVL_push_value_operator
|
||||
|
||||
// Here the priority is not higher - so compute what we already have on stack
|
||||
// but do not finish proccessing
|
||||
; Here the priority is not higher - so compute what we already have on stack
|
||||
; but do not finish proccessing
|
||||
|
||||
sty OPPTR+1 // store .Y, we want to preserve it
|
||||
lda #$FF // mark that we want to return here
|
||||
sty OPPTR+1 ; store .Y, we want to preserve it
|
||||
lda #$FF ; mark that we want to return here
|
||||
sta OPPTR+0
|
||||
!:
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
FRMEVL_fetch_operator_end:
|
||||
|
||||
jmp FRMEVL_compute_partial
|
||||
|
||||
FRMEVL_compute_partial_return:
|
||||
|
||||
pla
|
||||
pha
|
||||
bne !-
|
||||
bne FRMEVL_fetch_operator_end
|
||||
|
||||
ldy OPPTR+1
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
FRMEVL_push_value_operator:
|
||||
|
||||
// Push the value from FAC1
|
||||
; Push the value from FAC1
|
||||
|
||||
ldx VALTYP
|
||||
bmi FRMEVL_push_string
|
||||
|
||||
// Push float
|
||||
; Push float
|
||||
|
||||
// XXX implement this
|
||||
; XXX implement this
|
||||
|
||||
FRMEVL_push_string:
|
||||
|
||||
// Push string - length, address, type
|
||||
; Push string - length, address, type
|
||||
|
||||
lda __FAC1+0
|
||||
pha
|
||||
@@ -316,56 +319,56 @@ FRMEVL_push_string:
|
||||
txa
|
||||
pha
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
FRMEVL_push_operator_address:
|
||||
|
||||
// Check if there is enough stack space; this could not have been done earlier,
|
||||
// as this is the place where unary operator support calls
|
||||
; Check if there is enough stack space; this could not have been done earlier,
|
||||
; as this is the place where unary operator support calls
|
||||
|
||||
jsr check_stack_space
|
||||
|
||||
// Push the operator address to stack, in a form
|
||||
// suitable for RTS
|
||||
; Push the operator address to stack, in a form
|
||||
; suitable for RTS
|
||||
|
||||
lda operator_jumptable_hi, y
|
||||
pha
|
||||
lda operator_jumptable_lo, y
|
||||
pha
|
||||
|
||||
// Push operator priority
|
||||
; Push operator priority
|
||||
|
||||
lda operator_priorities, y
|
||||
pha
|
||||
|
||||
// Continue
|
||||
; Continue
|
||||
|
||||
jmp FRMEVL_loop
|
||||
|
||||
//
|
||||
// This part serves two purposes:
|
||||
// - it is an exit point for the concrete operator implementations
|
||||
// - it causes computation of everything which is stored on the stack
|
||||
//
|
||||
;
|
||||
; This part serves two purposes:
|
||||
; - it is an exit point for the concrete operator implementations
|
||||
; - it causes computation of everything which is stored on the stack
|
||||
;
|
||||
|
||||
FRMEVL_compute_all:
|
||||
|
||||
lda #$00
|
||||
sta OPPTR+0
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
FRMEVL_continue:
|
||||
|
||||
lda OPPTR+0
|
||||
bne FRMEVL_compute_partial_return
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
FRMEVL_compute_partial:
|
||||
|
||||
// Now, we have to compute operation; at this point we should have a value
|
||||
// in FAC1 and (most likely) operator on a stack
|
||||
; Now, we have to compute operation; at this point we should have a value
|
||||
; in FAC1 and (most likely) operator on a stack
|
||||
|
||||
pla // priority does not matter here, get rid of it
|
||||
rts // this either jumps to operator, or quits FRMEVL
|
||||
pla ; priority does not matter here, get rid of it
|
||||
rts ; this either jumps to operator, or quits FRMEVL
|
||||
@@ -1,24 +1,24 @@
|
||||
// #LAYOUT# STD * #TAKE-HIGH
|
||||
// #LAYOUT# * BASIC_0 #TAKE-HIGH
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE-HIGH
|
||||
;; #LAYOUT# * BASIC_0 #TAKE-HIGH
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
// This has to go $E000 or above - routines below banks out the main BASIC ROM!
|
||||
; This has to go $E000 or above - routines below banks out the main BASIC ROM!
|
||||
|
||||
//
|
||||
// Helper routine to copy string descriptor, for expression evaluator
|
||||
//
|
||||
;
|
||||
; Helper routine to copy string descriptor, for expression evaluator
|
||||
;
|
||||
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
!ifdef CONFIG_MEMORY_MODEL_46K_OR_50K {
|
||||
|
||||
helper_frmevl_strdesccpy:
|
||||
|
||||
// Unmap BASIC lower ROM
|
||||
; Unmap BASIC lower ROM
|
||||
|
||||
lda #$26
|
||||
sta CPU_R6510
|
||||
|
||||
// Copy string descriptor
|
||||
; Copy string descriptor
|
||||
|
||||
ldy #$00
|
||||
lda (VARPNT),y
|
||||
@@ -30,15 +30,14 @@ helper_frmevl_strdesccpy:
|
||||
lda (VARPNT),y
|
||||
sta __FAC1+2
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
remap_BASIC:
|
||||
|
||||
// Restore default memory mapping
|
||||
; Restore default memory mapping
|
||||
|
||||
lda #$27
|
||||
sta CPU_R6510
|
||||
|
||||
rts
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
init_oldtxt:
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Consummes assign operator in a BASIC code, triggers error if not found
|
||||
//
|
||||
;
|
||||
; Consummes assign operator in a BASIC code, triggers error if not found
|
||||
;
|
||||
|
||||
|
||||
injest_assign:
|
||||
|
||||
jsr fetch_character_skip_spaces
|
||||
cmp #$B2 // assign operator character
|
||||
bne_16 do_SYNTAX_error
|
||||
cmp #$B2 ; assign operator character
|
||||
+bne do_SYNTAX_error
|
||||
|
||||
rts
|
||||
@@ -1,25 +1,25 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Consummes a comma in a BASIC code, Carry set if not found. Injests all spaces.
|
||||
//
|
||||
;
|
||||
; Consummes a comma in a BASIC code, Carry set if not found. Injests all spaces.
|
||||
;
|
||||
|
||||
|
||||
injest_comma:
|
||||
|
||||
jsr fetch_character_skip_spaces
|
||||
cmp #$2C // comma character
|
||||
cmp #$2C ; comma character
|
||||
beq injest_comma_found
|
||||
|
||||
// Not found
|
||||
; Not found
|
||||
|
||||
#if !HAS_OPCODES_65CE02
|
||||
!ifndef HAS_OPCODES_65CE02 {
|
||||
jsr unconsume_character
|
||||
#else
|
||||
} else {
|
||||
dew TXTPTR
|
||||
#endif
|
||||
}
|
||||
|
||||
sec
|
||||
rts
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# M65 BASIC_1 #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# M65 BASIC_1 #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Check .A content, if within 0-9, A-Z ranges, sets Carry if check fails
|
||||
//
|
||||
;
|
||||
; Check .A content, if within 0-9, A-Z ranges, sets Carry if check fails
|
||||
;
|
||||
|
||||
|
||||
is_09_AZ:
|
||||
@@ -17,19 +17,19 @@ is_09_AZ:
|
||||
|
||||
is_09:
|
||||
|
||||
cmp #$30 // if below '0' - check failed
|
||||
cmp #$30 ; if below '0' - check failed
|
||||
bcc is_alphanumeric_fail
|
||||
|
||||
cmp #$3A // if above '9' - check failed
|
||||
cmp #$3A ; if above '9' - check failed
|
||||
rts
|
||||
|
||||
|
||||
is_AZ:
|
||||
|
||||
cmp #$41 // if below 'A' - check failed
|
||||
cmp #$41 ; if below 'A' - check failed
|
||||
bcc is_alphanumeric_fail
|
||||
|
||||
cmp #$7B // if above 'Z' - check failed
|
||||
cmp #$7B ; if above 'Z' - check failed
|
||||
rts
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Check for end of statement, sets Carry if so. Injests all spaces.
|
||||
//
|
||||
;
|
||||
; Check for end of statement, sets Carry if so. Injests all spaces.
|
||||
;
|
||||
|
||||
|
||||
is_end_of_statement:
|
||||
@@ -12,28 +12,28 @@ is_end_of_statement:
|
||||
jsr fetch_character_skip_spaces
|
||||
|
||||
cmp #$00
|
||||
beq !+
|
||||
beq @1
|
||||
cmp #$3A
|
||||
beq !+
|
||||
beq @1
|
||||
|
||||
// Not end of statement
|
||||
; Not end of statement
|
||||
|
||||
#if !HAS_OPCODES_65CE02
|
||||
!ifndef HAS_OPCODES_65CE02 {
|
||||
jsr unconsume_character
|
||||
#else
|
||||
} else {
|
||||
dew TXTPTR
|
||||
#endif
|
||||
}
|
||||
|
||||
clc
|
||||
rts
|
||||
!:
|
||||
// End of statement
|
||||
@1:
|
||||
; End of statement
|
||||
|
||||
#if !HAS_OPCODES_65CE02
|
||||
!ifndef HAS_OPCODES_65CE02 {
|
||||
jsr unconsume_character
|
||||
#else
|
||||
} else {
|
||||
dew TXTPTR
|
||||
#endif
|
||||
}
|
||||
|
||||
sec
|
||||
rts
|
||||
@@ -1,37 +1,36 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
// Return pointer in BASIC memory space status in Z flag
|
||||
; Return pointer in BASIC memory space status in Z flag
|
||||
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_60K
|
||||
!ifndef CONFIG_MEMORY_MODEL_46K_OR_50K {
|
||||
|
||||
is_line_pointer_null:
|
||||
|
||||
// Check the pointer
|
||||
; Check the pointer
|
||||
|
||||
ldy #$01 // for non-NULL pointer, high byte is almost certainly not NULL
|
||||
ldy #$01 ; for non-NULL pointer, high byte is almost certainly not NULL
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
!ifdef CONFIG_MEMORY_MODEL_60K {
|
||||
ldx #<OLDTXT+0
|
||||
jsr peek_under_roms
|
||||
cmp #$00
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
} else { ; CONFIG_MEMORY_MODEL_38K
|
||||
lda (OLDTXT),y
|
||||
#endif
|
||||
}
|
||||
|
||||
bne !+
|
||||
bne @1
|
||||
dey
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
!ifdef CONFIG_MEMORY_MODEL_60K {
|
||||
jsr peek_under_roms
|
||||
cmp #$00
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
} else { ; CONFIG_MEMORY_MODEL_38K
|
||||
lda (OLDTXT),y
|
||||
#endif
|
||||
}
|
||||
|
||||
!:
|
||||
@1:
|
||||
rts
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -1,30 +1,30 @@
|
||||
// #LAYOUT# STD * #TAKE-HIGH
|
||||
// #LAYOUT# * BASIC_0 #TAKE-HIGH
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE-HIGH
|
||||
;; #LAYOUT# * BASIC_0 #TAKE-HIGH
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
// This has to go $E000 or above - routine below banks out the main BASIC ROM!
|
||||
; This has to go $E000 or above - routine below banks out the main BASIC ROM!
|
||||
|
||||
// Return pointer in BASIC memory space status in Z flag
|
||||
; Return pointer in BASIC memory space status in Z flag
|
||||
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
!ifdef CONFIG_MEMORY_MODEL_46K_OR_50K {
|
||||
|
||||
is_line_pointer_null:
|
||||
|
||||
// Unmap BASIC lower ROM
|
||||
; Unmap BASIC lower ROM
|
||||
|
||||
lda #$26
|
||||
sta CPU_R6510
|
||||
|
||||
// Check the pointer - reuse code from other routine
|
||||
; Check the pointer - reuse code from other routine
|
||||
|
||||
jsr line_pointer_null_check
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
remap_BASIC_preserve_P:
|
||||
|
||||
// Restore memory mapping and quit
|
||||
; Restore memory mapping and quit
|
||||
|
||||
php
|
||||
lda #$27
|
||||
@@ -32,5 +32,4 @@ remap_BASIC_preserve_P:
|
||||
plp
|
||||
|
||||
rts
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -1,38 +1,38 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# M65 BASIC_1 #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# M65 BASIC_1 #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Prepare interpreter to execute commands in direct mode
|
||||
//
|
||||
;
|
||||
; Prepare interpreter to execute commands in direct mode
|
||||
;
|
||||
|
||||
prepare_direct_execution:
|
||||
|
||||
#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_0)
|
||||
!ifdef SEGMENT_M65_BASIC_0 {
|
||||
|
||||
jsr map_BASIC_1
|
||||
jsr_ind VB1__prepare_direct_execution
|
||||
jmp map_NORMAL
|
||||
jsr map_BASIC_1
|
||||
jsr (VB1__prepare_direct_execution)
|
||||
jmp map_NORMAL
|
||||
|
||||
#else
|
||||
} else {
|
||||
|
||||
// Setup pointer to the statement
|
||||
; Setup pointer to the statement
|
||||
lda #<BUF
|
||||
sta TXTPTR+0
|
||||
lda #>BUF
|
||||
sta TXTPTR+1
|
||||
|
||||
// There is no stored line, so zero that pointer out
|
||||
; There is no stored line, so zero that pointer out
|
||||
lda #$00
|
||||
sta OLDTXT+0
|
||||
sta OLDTXT+1
|
||||
|
||||
// Put invalid line number in current line number value,
|
||||
// so that we know we are in direct mode (Computes Mapping the 64 p19)
|
||||
; Put invalid line number in current line number value,
|
||||
; so that we know we are in direct mode (Computes Mapping the 64 p19)
|
||||
lda #$FF
|
||||
sta CURLIN+1
|
||||
|
||||
rts
|
||||
|
||||
#endif // ROM layout
|
||||
} ; ROM layout
|
||||
@@ -1,12 +1,12 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Reverses character fetch
|
||||
//
|
||||
;
|
||||
; Reverses character fetch
|
||||
;
|
||||
|
||||
#if !HAS_OPCODES_65CE02
|
||||
!ifndef HAS_OPCODES_65CE02 {
|
||||
|
||||
unconsume_character:
|
||||
|
||||
@@ -19,5 +19,4 @@ unconsume_character:
|
||||
sta TXTPTR+1
|
||||
|
||||
rts
|
||||
|
||||
#endif
|
||||
}
|
||||
Reference in new issue
Block a user