Information about calls in NEC PC-6001A basic rom

Post Reply
alank2
Member
Posts: 79
Joined: Wed Mar 01, 2017 7:24 pm

Information about calls in NEC PC-6001A basic rom

Post by alank2 »

By looking through some of the NEC PC-6001 files in z88dk, I found the calls to print a character on the screen and also GETK. Does anyone more information about available calls for this system? It has a BASIC ROM from 0x0000-0x3fff. I've been recently adapting a machine language monitor for it and it would be cool to turn off that bottom line that shows the F keys.
stefano
Well known member
Posts: 1798
Joined: Mon Jul 16, 2007 7:39 pm

Re: Information about calls in NEC PC-6001A basic rom

Post by stefano »

Try z88dk/support/basck/basck.c
It should be able to point out some of the ROM entries, if you use it to inspect the ROM files.
alank2
Member
Posts: 79
Joined: Wed Mar 01, 2017 7:24 pm

Re: Information about calls in NEC PC-6001A basic rom

Post by alank2 »

Thanks stefano; I'll give that a try!
stefano
Well known member
Posts: 1798
Joined: Mon Jul 16, 2007 7:39 pm

Re: Information about calls in NEC PC-6001A basic rom

Post by stefano »

In theory you can use it as an initial feed to the SKOOLKIT disassembly suite.
I'm not sure it is easy to use on the PC6001, though. I think it has some sort of relocation mechanism in the rom, but I'm not 100% sure.
alank2
Member
Posts: 79
Joined: Wed Mar 01, 2017 7:24 pm

Re: Information about calls in NEC PC-6001A basic rom

Post by alank2 »

Here is what it comes up with. I tried it on the basic rom, then the extended rom, then the basic+extended rom, but the extended rom part of it did not make any difference. They had a cartridge extended basic that added disk commands and a few others to regular basic.

I've been working on a machine language monitor for the PC-6001, and I wanted to try my luck and turning off the bottom function key line. This uses the console command which was found in the bottom report. I looked at it with a disassembler, but I didn't get too far figuring it out yet. I thought at first that maybe it was trying to parse the parameters of the console command because it was checking for a , and there are 3 parameters, but the memory location it was checking seems to be where the results of the console command are written in ram. I'm not sure why it would be looking through that for a comma so I must not be understanding it. I'd also like to figure out how to get the cursor to blink.

# File size: 16384

# Specific Z80 CPU code detected


# Microsoft 8080/Z80 BASIC found
# Earlier version
# Microsoft signature found


BASTXT = $FFFFFFFF ; BASIC program start ptr (aka TXTTAB)


# DCOMPR/CPDEHL (compare DE and HL), code found at $001F
# (Detected position for ORG: 0)

BUFFER = $FED9 ; Start of input buffer
TMPSTR = $FF39 ; Temporary string
VARTAB = $FF56 ; ; BASIC program end ptr (a.k.a. PROGND, Simple Variables)
ARYTAB = $FF58 ; End of variables, begin of array aariables (a.k.a. VAREND)
STREND = $FF5A ; End of arrays (a.k.a. ARREND, lowest free mem)
DIMFLG = $FF24 ; (word), aka LCRFLG (Locate/Create and Type
NXTOPR = $FF50 ; (word) temp. storage used by EVAL, a.k.a. TEMP2

HALFPI = $3E08 ; Half PI constant ptr


DCOMPR = $0020 ; compare DE and HL (aka CPDEHL)
FNDNUM = $0DE3 ; Load 'A' with the next number in BASIC program
GETINT = $0DE4 ; Get a number to 'A'
GETWORD = $0E06 ; Get a number to DE (0..65535)
DEPINT = $073D ; Get integer variable to DE, error if negative
SBSCPT = $33BA ; Sort out subscript
SCPTLP = $33C0 ; SBSCPT loop
GETVAR = $3307 ; Get variable address to DE
DIM = $3302 ; DIM command
CHKSTK = $34B0 ; Check for C levels of stack
OPRND = $0B81 ; Get next expression value
SYNCHR = $0008 ; Check syntax, 1 byte follows to be compared
LFRGNM = $32D6 ; number in program listing and check for ending ')'
ABPASS = $0D17 ; Get back from function passing an INT value in A+B registers
MIDNUM = $32D9 ; Get number in program listing

VSIGN = $0028 ; Test sign in number
NEG = $38BB ; Invert number sign
PUSHF = $38C3 ; a.k.a. STAKFP, Put FP value on stack
COS = $3F51 ; COS
SIN = $3F5A ; SIN
ABS = $38B9 ; ABS
ADDPHL = $3C80 ; ADD number at HL to BCDE
BCDEFP = $3907 ; Load FP reg to BCDE
LOADFP = $390A ; Load FP value pointed by HL to BCDE
DSUB = $3686 ; aka DECSUB, Double precision SUB (formerly SUBCDE)
DADD = $368C ; aka DECADD, Double precision ADD (formerly FPADD)
DMUL = $37B7 ; aka DECMUL, Double precision MULTIPLY
DDIV = $3806 ; aka DECDIV, Double precision DIVIDE
MLDEBC = $39FD ; Multiply DE by BC
_ASCTFP = $3A1B ; ASCII to FP number
H_ASCTFP = $3A16 ; ASCII to FP number (also '&' prefixes)
PRNTHL = $3AA5 ; Print number in HL
PRNUMS = $30CE ; Print number string
PRS = $30CF ; Create string entry and print it
PRS1 = $30D2 ; Print string at HL
STR = $305B ; STR BASIC function entry
SAVSTR = $3067 ; Save string in string area
MKTMST = $3082 ; Make temporary string
CRTMST = $3085 ; Create temporary string entry
SSTSA = $31EA ; Move string on stack to string area
TOSTRA = $31F3 ; Move string in BC, (len in L) to string area
TSALP = $31F4 ; TOSTRA loop
FOR = $067E ; 'FOR' BASIC instruction
FDTLP = $0AD6 ; Find next DATA statement
DATA = $07E0 ; DATA statement: find next DATA program line..
RESTOR = $3519 ; 'RESTORE' stmt, init ptr to DATA program line..
MAKINT = $0DE7 ; Convert tmp string to int in A register
CONCAT = $31B2 ; String concatenation
TESTR = $30E7 ; Test if enough room for string
TOPOOL = $3253 ; Save in string pool
OPNPAR = $0B07 ; Chk Syntax, make sure '(' follows
EVAL = $0B09 ; a.k.a. GETNUM, evaluate expression
EVAL1 = $0B0C ; Save precedence and eval until precedence break
EVAL2 = $0B15 ; Evaluate expression until precedence break
EVAL3 = $0B18 ; Evaluate expression until precedence break
STKTHS = $0B4F ; Stack expression item and get next one
CRTST = $3091 ; Create String
QTSTR = $3092 ; Create quote terminated String
DTSTR = $3095 ; Create String, termination char in D
BAKTMP = $321A ; Back to last tmp-str entry
GETSTR = $31FC ; Get string pointed by FPREG 'Type Error' if it is not
GSTRCU = $31FF ; Get string pointed by FPREG
GSTRHL = $3202 ; Get string pointed by HL
GSTRDE = $3203 ; Get string pointed by DE
TSTSTR = $0AFA ; Test a string, 'Type Error' if it is not
NUMASC = $3AAC ; Number to ASCII conversion
ATOH = $075F ; ASCII to Integer, result in DE

LNUM_RANGE = $04E5 ; Read numeric range function parameters
LNUM_PARM = $075F ; Read numeric function parameter
CHRGTB = $0010 ; (a.k.a. GETCHR, GETNEXT), pick next char from program
_CHRGTB = $072A ; Pick next char from program
MAKUPL = $0BEE ; Get char from (HL) and make upper case
UCASE = $0BEF ; Make char in 'A' upper case
ISLETTER_A = $35A2 ; Check char in 'A' being in the 'A'..'Z' range
OUTDO = $26C7 ; Output char in 'A' to console

DATSNR = $03E4 ; 'SN err' entry for Input STMT
SN_ERR = $03EA ; entry for '?SN ERROR'
UL_ERR = $07B7 ; entry for '?UL ERROR'



# JP table for statements = $FA61


# (applying a PC-6001 table shift hack, new pos: $0195)



# TOKEN table position = $021D, word list in classic encoding mode

# -- STATEMENTS --

# ---
$3535 - [128] END
$067E - [129] FOR
$35F7 - [130] NEXT
$07E0 - [131] DATA
$09AB - [132] INPUT
$3302 - [133] DIM
$0A09 - [134] READ
$07F5 - [135] LET
$07A0 - [136] GOTO
$0781 - [137] RUN
$0861 - [138] IF
$3519 - [139] RESTORE
$078F - [140] GOSUB
$07BC - [141] RETURN
$07E2 - [142] REM
$3533 - [143] STOP
$0DD6 - [144] OUT
$0844 - [145] ON
$087A - [146] LPRINT
$0D3A - [147] DEF
$0DFA - [148] POKE
$087E - [149] PRINT
$356B - [150] CONT
$05DB - [151] LIST
$05D6 - [152] LLIST
$35A9 - [153] CLEAR
$1D9B - [154] COLOR
$2D3C - [155] PSET
$2D37 - [156] PRESET
$2DC7 - [157] LINE
$2EDC - [158] PAINT
$1E04 - [159] SCREEN
$1DF8 - [160] CLS
$1CD2 - [161] LOCATE
$1CF6 - [162] CONSOLE
$2496 - [163] CLOAD
$247E - [164] CSAVE
$261D - [165] EXEC
$1E9B - [166] SOUND
$1EB3 - [167] PLAY
$2353 - [168] KEY
$22A6 - [169] LCOPY
$34CD - [170] NEW

# -- OPERATORS & extras --

# 171 TAB(
# 172 TO
# 173 FN
# 174 SPC(
# 175 INKEY$
# 176 THEN
# 177 NOT
# 178 STEP
# 179 +
# 180 -
# 181 *
# 182 /
# 183 ^
# 184 AND
# 185 OR
# 186 >
# 187 =
# 188 <

# JP table for functions = $FAE5


# (applying a PC-6001 table shift hack, new pos: $01EB)


# -- FUNCTIONS --

$3898 - [189] SGN
$39E7 - [190] INT
$38B9 - [191] ABS
$0755 - [192] USR
$32DE - [193] FRE
$0DCC - [194] INP
$0D22 - [195] LPOS
$0D27 - [196] POS
$3F92 - [197] SQR
$3BA3 - [198] RND
$3EA5 - [199] LOG
$3E21 - [200] EXP
$3F51 - [201] COS
$3F57 - [202] SIN
$3FD3 - [203] TAN
$0DF3 - [204] PEEK
$3229 - [205] LEN
$03EA - [206] HEX$
$305B - [207] STR$
$32BA - [208] VAL
$3238 - [209] ASC
$3249 - [210] CHR$
$3257 - [211] LEFT$
$3286 - [212] RIGHT$
$328F - [213] MID$
$4EC5 - [214] POINT
$C644 - [215] CSRLIN
$524F - [216] STICK
$45CE - [217] STRIG
$5458 - [218] TIME
stefano
Well known member
Posts: 1798
Joined: Mon Jul 16, 2007 7:39 pm

Re: Information about calls in NEC PC-6001A basic rom

Post by stefano »

You should look around here: $2353 - [168] KEY

The MS BASIC versions are usually close one each other.
Here you are the commented version for the MSX.

https://github.com/z88dk/techdocs/blob/ ... asm#L25373

The command syntax on the MSX includes KEY ON, KEY OFF, and KEY LIST.
It firs checks for the 'LIST' token code. If it is missing, then it jumps to the KEY configuration section (KEY_CONFIG: label).

There, it first check for the open parenthesis. If not, it is not a configuration statement.
Thus, it checks for the "ON" and "OFF" tokens and, if it finds one of them, deals with the "display function key" subroutines (DISPFNK, ERAFNK).


Obviously your disassembly will lack a lot of labels, but if you carefully look at the code around the entry, you should catch some similarity, e.g. the open parenthesis is 28h. Here's what you could find on the N80 BASIC for the PC88:

https://github.com/z88dk/techdocs/blob/ ... .asm#L3838
(if you scroll upwards you will get to "; __KEY BASIC command [$1343]")
alank2
Member
Posts: 79
Joined: Wed Mar 01, 2017 7:24 pm

Re: Information about calls in NEC PC-6001A basic rom

Post by alank2 »

Thanks stefano; I appreciate the help!
alank2
Member
Posts: 79
Joined: Wed Mar 01, 2017 7:24 pm

Re: Information about calls in NEC PC-6001A basic rom

Post by alank2 »

Do you have any info on the custom loaded used to load z88dk programs from cassette? Is this in the source of z88dk somewhere? It looks like there is a small loader that you can CLOAD and RUN and then it loads the rest of the program from tape. Can the rest of the program be loaded to a specific location?
stefano
Well known member
Posts: 1798
Joined: Mon Jul 16, 2007 7:39 pm

Re: Information about calls in NEC PC-6001A basic rom

Post by stefano »

Yup, it is treated as a byte stream prefix, but a bit of ASM source is in the comments.

https://github.com/z88dk/z88dk/blob/65d ... nec.c#L127


This prefix is then patched depending on the selected 'MODE',

https://github.com/z88dk/z88dk/blob/65d ... nec.c#L296


..but the start address is sort of fixed and used to identify the MODE.

https://github.com/z88dk/z88dk/blob/65d ... nec.c#L237
alank2
Member
Posts: 79
Joined: Wed Mar 01, 2017 7:24 pm

Re: Information about calls in NEC PC-6001A basic rom

Post by alank2 »

Thanks stefano; that is exactly what I needed to see!
Post Reply