You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: basic80.asm
+74-57
Original file line number
Diff line number
Diff line change
@@ -387,7 +387,9 @@ ERR_US EQU 0EH
387
387
ERR_DD EQU 12H
388
388
ERR_DZ EQU 14H
389
389
ERR_TM EQU 18H
390
-
ERR_CN EQU 20h
390
+
ERR_ST EQU 1EH
391
+
ERR_CN EQU 20H
392
+
ERR_UF EQU 22H
391
393
392
394
PrintString EQU 0F818H
393
395
ENDIF
@@ -675,27 +677,38 @@ MessageFound:
675
677
ENDIF
676
678
LD HL, szError
677
679
PrintInLine:
678
-
CALL PrintString
679
-
LD HL, (CURRENT_LINE)
680
-
LD A,H
681
-
AND L
682
-
INC A
683
-
CALL NZ, PrintIN
680
+
CALL PrintString
681
+
LD HL, (CURRENT_LINE)
682
+
LD A,H
683
+
AND L
684
+
INC A
685
+
686
+
CALL NZ, PrintIN
684
687
685
688
;
686
689
; Main
687
690
; Here's where a BASIC programmer in 1975 spent most of their time : typing at an "OK" prompt, one line at a time. A line of input would either be exec'd immediately (eg "PRINT 2+2"), or it would be a line of a program to be RUN later. Program lines would be prefixed with a line number. The code below looks for that line number, and jumps ahead to Exec if it's not there.
688
691
;
689
692
690
693
Main:
691
-
XOR A
692
-
LD (ControlChar),A ; Включаем вывод на экран (не управляющий символ)
694
+
IF MICRON
695
+
LD HL, szOK ; szOK
696
+
CALL PrintString
697
+
ELSE
698
+
XOR A
699
+
LD (ControlChar),A ; Включаем вывод на экран (не управляющий символ)
;Likewise, if subscript is >32767 then fall into FC error, otherwise exit to FAsInteger.
1428
1443
FTestIntegerExpression:
1429
-
LD A,(FACCUM+3)
1444
+
LD A,(FACCUM+3)
1430
1445
CP 90H
1431
1446
JP C,FAsInteger
1432
1447
LD BC,9080H
@@ -1437,7 +1452,7 @@ FTestIntegerExpression:
1437
1452
1438
1453
; Invalid function call (FC) error..
1439
1454
FunctionCallError:
1440
-
LD E,ERR_FC
1455
+
LD E,ERR_FC
1441
1456
JP Error
1442
1457
1443
1458
;1.11 Jumping to Program Lines
@@ -1528,9 +1543,12 @@ NextLineNumChar:
1528
1543
1529
1544
IF BASICNEW
1530
1545
ELSE
1546
+
IF MICRON
1547
+
ELSE
1531
1548
; Похоже, это мертвый код
1532
1549
DEC HL
1533
1550
ENDIF
1551
+
ENDIF
1534
1552
1535
1553
PrintLoop:
1536
1554
RST NextChar
@@ -1626,12 +1644,12 @@ PrintNullLoop:
1626
1644
;Calculate how many spaces are needed to get us to the next tab-break then jump to PrintSpaces to do it.
1627
1645
1628
1646
ToNextTabBreak:
1629
-
LD A,(TERMINAL_X)
1647
+
LD A,(TERMINAL_X)
1630
1648
CP 30H
1631
1649
CALL NC,NewLine
1632
1650
JP NC,ExitTab
1633
1651
CalcSpaceCount:
1634
-
SUB0EH
1652
+
SUB0EH
1635
1653
JP NC,CalcSpaceCount
1636
1654
CPL
1637
1655
JP PrintSpaces
@@ -1655,16 +1673,16 @@ Tab:
1655
1673
ADD A,E
1656
1674
JP NC,ExitTab
1657
1675
PrintSpaces:
1658
-
INC A
1676
+
INC A
1659
1677
Spc:
1660
-
LD B,A
1678
+
LD B,A
1661
1679
LD A,' '
1662
1680
PrintSpaceLoop:
1663
-
RST OutChar
1681
+
RST OutChar
1664
1682
DEC B
1665
1683
JP NZ,PrintSpaceLoop
1666
1684
ExitTab:
1667
-
POP HL
1685
+
POP HL
1668
1686
RST NextChar
1669
1687
JP L0794
1670
1688
@@ -1685,13 +1703,13 @@ L0840: LD A, (INPUT_OR_READ)
1685
1703
1686
1704
CHK 0852h,"Сдвижка кода"
1687
1705
Input:
1688
-
CP '"' ; 22H
1706
+
CP '"'
1689
1707
LD A,00H
1690
1708
LD (ControlChar),A
1691
1709
JP NZ,NoPrompt
1692
1710
CALL GetStringConstant
1693
1711
RST SyntaxCheck
1694
-
DB';'
1712
+
DB';'
1695
1713
PUSH HL
1696
1714
CALL L0D96
1697
1715
POP HL
@@ -1752,7 +1770,7 @@ GotDataItem:
1752
1770
RST NextChar
1753
1771
LD D,A
1754
1772
LD B,A
1755
-
CP '"' ; 22H
1773
+
CP '"'
1756
1774
JP Z,L08B2
1757
1775
LD D,':'
1758
1776
LD B,','
@@ -1763,7 +1781,7 @@ L08B2: CALL L0D53
1763
1781
EX (SP),HL
1764
1782
PUSH DE
1765
1783
JP L072B
1766
-
1784
+
1767
1785
L08BE: RST NextChar
1768
1786
CALL FIn
1769
1787
EX (SP),HL
@@ -1858,7 +1876,7 @@ L0978:
1858
1876
CALL EvalTerm
1859
1877
LD (PROG_PTR_TEMP2),HL
1860
1878
ArithParse:
1861
-
LD HL,(PROG_PTR_TEMP2)
1879
+
LD HL,(PROG_PTR_TEMP2)
1862
1880
L0986: POP BC
1863
1881
LD A,B
1864
1882
CP 78H
@@ -1924,14 +1942,13 @@ L09D2: PUSH BC
1924
1942
RST PushNextWord
1925
1943
LD HL,(CUR_TOKEN_ADR)
1926
1944
JP L0978
1927
-
1928
-
;EvalTerm
1929
1945
1946
+
;EvalTerm
1930
1947
;Evaluates a term in an expression. This can be a numeric constant, a variable, an inline function call taking a full expression as an argument, or a bracketed expression.
1931
1948
;Get first character of term, and if it's a digit (as indicated by the carry flag) then jump to FIn
1932
1949
1933
1950
EvalTerm:
1934
-
XOR A
1951
+
XOR A
1935
1952
L09E6: LD (VALTYP),A
1936
1953
RST NextChar
1937
1954
JP C,FIn
@@ -1945,9 +1962,9 @@ L09E6: LD (VALTYP),A
1945
1962
CP '.' ;2EH
1946
1963
JP Z,FIn
1947
1964
;If the character is a leading '-' then jump head to EvalMinusTerm
1948
-
CP TK_MINUS ;0A5H
1949
-
JP Z,EvalMinusTerm ; L0A1E
1950
-
CP '"' ; 22H
1965
+
CP TK_MINUS
1966
+
JP Z,EvalMinusTerm
1967
+
CP '"'
1951
1968
JP Z,GetStringConstant
1952
1969
CP TK_NOT ; 0A2H
1953
1970
JP Z,L0AF9
@@ -1959,20 +1976,20 @@ L09E6: LD (VALTYP),A
1959
1976
;The only possibility left is a bracketed expression. Here we check for an opening bracket, recurse into EvalExpression, and return.
1960
1977
L0A16: RST SyntaxCheck
1961
1978
DB'('
1962
-
CALL EvalExpression
1979
+
CALL EvalExpression
1963
1980
RST SyntaxCheck
1964
1981
L0A1C: DB ')'
1965
1982
RET
1966
1983
1967
1984
EvalMinusTerm:
1968
-
L0A1E: LD D,7DH
1985
+
LD D,7DH
1969
1986
CALL L0978
1970
1987
LD HL,(PROG_PTR_TEMP2)
1971
1988
PUSH HL
1972
1989
CALL FNegate
1973
1990
L0A2A: CALL IsNumeric
1974
1991
POP HL
1975
-
RET
1992
+
RET
1976
1993
1977
1994
;Evaluate a variable. The call to GetVar returns the address of the variable's value in DE, which is then moved to HL then the call to FLoadFromMem loads FACCUM with the variable's value.
1978
1995
EvalVarTerm:
@@ -1988,13 +2005,13 @@ EvalVarTerm:
1988
2005
1989
2006
; Evaluate an inline function. First we get the offset into the KW_INLINE_FNS table into BC and stick it on the stack.
1990
2007
EvalInlineFn:
1991
-
LD B,00H
1992
-
RLCA
1993
-
LD C,A
1994
-
PUSH BC
2008
+
LD B,00H
2009
+
RLCA
2010
+
LD C,A
2011
+
PUSH BC
1995
2012
;Evaluate function argument
1996
-
RST NextChar
1997
-
LD A,C
2013
+
RST NextChar
2014
+
LD A,C
1998
2015
CP 2*(TK_LEFTS-TK_SGN)-1 ; Это строковые функции fn$ с несколькими параметрами?
1999
2016
JP C,L0A65 ; Нет, обычная
2000
2017
@@ -2032,7 +2049,7 @@ SkipFnArgs:
2032
2049
EX (SP),HL
2033
2050
LD DE,L0A2A
2034
2051
PUSH DE
2035
-
L0A6D: LD BC, KW_INLINE_FNS ; 0043H
2052
+
L0A6D: LD BC, KW_INLINE_FNS
2036
2053
ADD HL,BC
2037
2054
LD C,(HL)
2038
2055
INC HL
@@ -2136,15 +2153,15 @@ L0AD7: LD A,E
2136
2153
JP Z,L0AD7
2137
2154
CCF
2138
2155
JP L12D0
2139
-
2156
+
2140
2157
L0AEF: INC A
2141
2158
ADC A,A
2142
2159
POP BC
2143
2160
AND B
2144
2161
ADD A,0FFH
2145
2162
SBC A,A
2146
2163
JP FCharToFloat
2147
-
2164
+
2148
2165
L0AF9: LD D,5AH
2149
2166
CALL L0978
2150
2167
CALL IsNumeric
@@ -2192,11 +2209,11 @@ L0B35: RST NextChar
2192
2209
JP C,L0B35
2193
2210
CALL CharIsAlpha
2194
2211
JP NC,L0B35
2195
-
L0B3F: SUB'$' ; 24H
2212
+
L0B3F: SUB'$'
2196
2213
JP NZ,L0B4C
2197
2214
INC A ; A=1, т.е. строковая переменная
2198
2215
LD (VALTYP),A
2199
-
RRCA
2216
+
RRCA
2200
2217
ADD A,C
2201
2218
LD C,A
2202
2219
RST NextChar
@@ -2214,8 +2231,8 @@ L0B4C: LD A,(NO_ARRAY)
2214
2231
2215
2232
;Loop to find the variable if it's already been allocated. If HL==DE then we've reached VAR_ARRAY_BASE without finding it, and so can jump ahead to allocate a new variable.
0 commit comments