Commit 227d8ed8 authored by John P. Willis's avatar John P. Willis

Add online help; begin rewrite of console device

parent 207a762e
......@@ -8,6 +8,14 @@ data_bits=8
stop_bits=1
[disk]
count=2
count=10
0=disk0.dsk
1=disk1.dsk
\ No newline at end of file
1=disk1.dsk
2=disk2.dsk
3=disk3.dsk
4=disk4.dsk
5=disk5.dsk
6=disk6.dsk
7=disk7.dsk
8=disk8.dsk
9=disk9.dsk
\ No newline at end of file
VM_OBJS = ilxi.o asm.o cpu.o error.o host.o storage.o lexer.o inst.o util.o bus.o console.o signal.o message.o profile.o config.o disk.o
VM_OBJS = ilxi.o asm.o cpu.o error.o host.o storage.o lexer.o inst.o util.o bus.o console.o signal.o message.o profile.o config.o disk.o help.o
XIASM_OBJS = xiasm.o asm.o cpu.o lexer.o storage.o inst.o error.o util.o console.o bus.o signal.o message.o profile.o config.o
MKDISK_OBJS = mkdisk.o disk.o asm.o cpu.o error.o host.o storage.o lexer.o inst.o util.o bus.o console.o signal.o message.o profile.o config.o
FBCFLAGS = -g -mt #-d STACKDEBUG -d INSTDEBUG #-d LEXDEBUG
all: vm assembler diskutil rom test
diskutil: mkdisk
vm: ilxim
vm: ilxi
test: t_stack.bin
......@@ -37,8 +38,11 @@ xiasm.o: xiasm.bas
mkdisk.o: mkdisk.bas
fbc $(FBCFLAGS) -m mkdisk -o mkdisk.o -c mkdisk.bas
ilxim: $(VM_OBJS)
fbc $(FBCFLAGS) -x ilxim $(VM_OBJS)
ilxi: $(VM_OBJS)
fbc $(FBCFLAGS) -x ilxi $(VM_OBJS)
help.o: help.bas
fbc $(FBCFLAGS) -o help.o -c help.bas
disk.o: disk.bas
fbc $(FBCFLAGS) -o disk.o -c disk.bas
......@@ -89,4 +93,4 @@ message.o: message.bas
fbc $(FBCFLAGS) -o message.o -c message.bas
clean:
rm -f *.o ilxim xiasm rom.bin t_stack.bin
rm -f *.o ilxi xiasm rom.bin t_stack.bin mkdisk diskboot.bin
......@@ -36,7 +36,7 @@ sub console_attach()
console_refresh = @console_refresh_local
message_print "console_attach(): local console"
message_print "console_attach(): local console configured at I/O port " & console_device.io_base & "h"
case "serial"
......@@ -59,7 +59,7 @@ sub console_attach()
console_data_bits = config_get("console", "data_bits")
console_stop_bits = config_get("console", "stop_bits")
message_print "console_attach(): serial console at " & console_port & ": (" & console_bps & " " & console_parity & console_data_bits & console_stop_bits & ")"
message_print "console_attach(): serial console configured at I/O port " & console_device.io_base & "h (host device " & console_port & "): (" & console_bps & " " & console_parity & console_data_bits & console_stop_bits & ")"
end select
......@@ -111,8 +111,8 @@ function console_input(port_number as ushort) as ushort
return horizontal_offset
case (console_io_base + 3)
return vertical_offset
case (console_io_base + 4)
return len(console_input_buffer)
case (console_io_base + 4)
case else
return 0
end select
......@@ -147,27 +147,9 @@ sub console_output(port_number as ushort, value as ushort)
case (console_io_base + 4)
for i = CONSOLE_OFFSET to CONSOLE_LIMIT - 1
st_write_byte CONSOLE_PAGE, i, 0
next i
case (console_io_base + 5)
console_refresh()
case (console_io_base + 6)
mutexlock console_mutex
for i = 1 to value
st_write_byte cpu_state.ds, cpu_state.di, asc(mid(console_input_buffer, i, 1))
cpu_state.di += 1
st_write_byte CONSOLE_PAGE, i, value
next i
console_input_buffer = mid(console_input_buffer, value + 1)
mutexunlock console_mutex
end select
end sub
......@@ -176,7 +158,9 @@ sub console_cycle_local(byval userdata as any ptr)
do
sleep sleep_duration, 1
sleep sleep_duration, 1
console_refresh_local
if bus_get_stop_flag(0) = 1 then exit do
loop
......@@ -187,19 +171,9 @@ sub console_cycle_serial(byval userdata as any ptr)
do
' mutexlock console_mutex
console_bytes_waiting = loc(console_file_number)
if console_bytes_waiting > 0 then
message_print "console_cycle_serial(): reading " & console_bytes_waiting & " bytes from console"
console_input_buffer &= input(console_bytes_waiting, console_file_number)
message_print "console_cycle_serial(): console buffer now " & console_input_buffer
end if
' mutexunlock console_mutex
sleep sleep_duration, 1
sleep sleep_duration, 1
console_refresh_serial
if bus_get_stop_flag(0) = 1 then exit do
loop
......
......@@ -11,9 +11,7 @@
' 1: Set cycle sleep value (ms)
' 2: Set horizontal offset
' 3: Set vertical offset
' 4: Write to this port to clear video buffer
' 5: Refresh console
' 6: Copy <value> bytes from console buffer to DS:DI
' 4: Fill video buffer
'
' IN
'
......@@ -21,8 +19,8 @@
' 1: Read refresh sleep value (ms)
' 2: Read horizontal offset
' 3: Read vertical offset
' 4: Get byte count of console buffer
' 4: Read one character from console
'
#define CONSOLE_PAGE &H0001
#define CONSOLE_OFFSET &H0000
......@@ -44,9 +42,6 @@ dim shared vertical_offset as ushort = 0
dim shared sleep_duration as ushort = 50
dim shared cursor_enabled as ushort = 1
dim shared console_input_buffer as string
dim shared console_bytes_waiting as ushort
dim shared console_file_number as integer
dim shared console_io_base as ushort
......
......@@ -45,7 +45,8 @@ sub disk_init()
redim installed_disks(installed_disk_count) as installed_disk_t
message_print "disk_init(): disk adapter configured"
message_print "disk_init(): disk adapter configured at I/O port " & disk_io_base & "h"
message_print "disk_init(): " & installed_disk_count & " storage devices attached"
for i = 0 to installed_disk_count - 1
......
'
' help
'
#include "help.bi"
function help_get_topic(input_file as string, topic as string) as string
#ifndef __FB_LINUX__
const endl as string = chr(13) & chr(10)
#else
const endl as string = chr(10)
#endif
dim file_no as integer
dim current_line as string
dim topic_part as string
dim topic_found as integer
dim in_topic as integer
dim topic_text as string
file_no = freefile()
topic_found = 0
in_topic = 0
open input_file for input as #file_no
do while not eof(file_no)
line input #file_no, current_line
if left(current_line, 1) = "@" Then
if topic_found = 1 then exit do
topic_part = lcase(trim(mid(current_line, 2, len(current_line))))
if topic_part = lcase(topic) then
topic_found = 1
else
topic_found = 0
end if
else
if topic_found = 1 then
topic_text = topic_text & current_line & endl
end if
end if
loop
if topic_found = 0 then
topic_text = "Topic " & topic & " not found."
end if
close #file_no
return topic_text
end function
'
' help.bi
'
declare function help_get_topic(input_file as string, topic as string) as string
......@@ -12,6 +12,7 @@
#include "disk.bi"
#include "bus.bi"
#include "message.bi"
#include "help.bi"
startup
......@@ -23,7 +24,7 @@ sub startup()
message_init
message_print "ILXIM Virtual Machine"
message_print "ILXI Virtual Machine"
message_print " Copyright (C) 2015 Coherent Logic Development LLC"
message_print ""
......@@ -51,7 +52,7 @@ sub cli()
last_cmd = cli_cmd
mutexlock console_mutex
line input "ilxim> ", cli_cmd
line input "ilxi> ", cli_cmd
mutexunlock console_mutex
if cli_cmd = "" then cli_cmd = last_cmd
......@@ -264,8 +265,12 @@ sub cli()
cpu_clear_flag FL_TRACE
else
cpu_set_flag FL_TRACE
end if
case "ver"
end If
Case "?"
print help_get_topic("ilxi.xmf", "index")
case "help"
print help_get_topic("ilxi.xmf", get_lexer_entry(1).strval)
case "ver"
print "ILXI 0.1"
case "run"
if cpu_get_flag(FL_HALT) = 0 then
......@@ -276,7 +281,7 @@ sub cli()
end if
case "reset"
init_cpu
case "exit"
case "exit", "quit"
end
case else
message_print "cli(): invalid command '" & cmd_name & "'"
......
@index
ILXI Interactive Commands
loadpage, lp - load memory segment from host file
savepage, sp - save memory segment to host file
writesect, ws - write sector to disk
assemble, a - interactively assemble instructions to a memory segment
disassemble, di - disassemble instructions in memory
step - single-step through a program
pushb - push a byte to the stack
pushw - push a word to the stack
getm - dump memory segments to the screen
setm - set the value of bytes or words in memory
getr - get the value of a CPU register
setr - set the value of a CPU register
dumpcpu, d - display the current state of CPU registers
trace - toggles instruction tracing
ver - display the current version of ILXI
run - run the CPU
reset - re-initialize the CPU
help - display online help topics
? - display this list of ILXI operations
exit, quit - exit ILXI
@loadpage
loadpage - Load a memory segment from host file
Syntax: [loadpage|lp] <host-file> <segment-number>
Details:
loadpage loads a single 64Kb segment from a memory image file
on the host machine. This can be a program, assembled with
the xiasm assembler, or generated from other ILXI compilers.
@lp
lp - see help for "loadpage"
@savepage
savepage - Save a memory segment to host file
Syntax: [savepage|sp] <host-file> <segment-index>
Details:
savepage saves a single 64Kb segment from ilxi into the specified
memory image file on the host. When used with the assemble command,
this allows the user to use ILXI as an interactive program development
environment.
@sp
sp - see help for "savepage"
@writesect
writesect - Write to one sector of an attached disk
Syntax: [writesect|ws] <segment-number> <offset> <channel> <track> <sector>
Details:
writesect writes data from segment-number:offset to the specified disk sector.
@ws
ws - see help for "writesect"
@assemble
assemble - interactively assemble instructions directly into memory
Syntax: assemble <origin>
Details:
assemble allows you to interactively assemble instructions into ILXI memory.
The starting address is EP:<origin>, where EP is the CPU's EP register.
@disassemble
disassemble - disassemble instructions in memory
Syntax: [disassemble|di] <starting-offset> <instruction-count>
Details:
disassemble will convert <instruction-count> instructions of machine code
starting at CP:<starting-offset>
@di
di - see help for "disassemble"
@step
step - single-step through program instructions
Syntax: step
Details:
step will advance the program counter register and execute the next instruction.
@getr
getr - get the value of a CPU register
Syntax: getr <register-name>
Details:
getr will return the value contained in the CPU register denoted by <register-name>
@setr
setr - set the value of a CPU register
Syntax: setr <register-name> <value>
Details:
setr will set the CPU register denoted by <register-name> to <value>
@pushb
pushb - push a BYTE value onto the stack
Syntax: pushb <byte-value>
Details:
pushb will push <byte-value> onto the stack, and update CPU registers
accordingly.
@pushw
pushb - push a WORD value onto the stack
Syntax: pushb <word-value>
Details:
pushw will push <word-value> onto the stack, and update CPU registers
accordingly.
@getm
getm - dump memory contents to screen
Syntax: getm <start-offset> <end-offset>
Details:
getm will display the contents of memory from DP:<start-offset> to
DP:<end-offset> on the screen.
@setm
setm - set the value of bytes or words in memory
Syntax: setm <offset> <value>
Details:
setm will write <value> to memory address DP:<offset>.
The <value> can be either a BYTE or a WORD.
@dumpcpu
dumpcpu - displays the state of CPU registers
Syntax: [dumpcpu|d]
Details:
The dumpcpu command will display the current contents of
all CPU registers and flags.
@d
See help for "dumpcpu"
@trace
trace - toggle program trace
Syntax: trace <value>
Details:
trace will turn program trace on and off. <value> can be
either 1 or 0, where 1 turns tracing on and 0 turns tracing off.
In program trace mode, the CPU will halt after each instruction,
something like an automated single-step.
@ver
ver - display the current version of ILXI
Syntax: ver
Details:
Displays the current version of ILXI.
@run
run - run the CPU
Syntax: run
Details:
The "run" command will start the CPU running at address CP:PC
@reset
reset - re-initialize the CPU
Syntax: reset
Details:
This command resets the CPU. The interrupt queue will be cleared,
registers zeroed, the INTERRUPT flag enabled, the ROM firmware reloaded,
the bus initialized, and signals initialized.
This command must be used in order to perform single-step operations
on a program after a program-generated HALT is encountered.
@help
help - display online help
Syntax: help <topic>
Details:
Displays online help topic <topic> on the screen.
@?
? - display list of help topics
Syntax: ?
Details:
Displays a list of available help topics
@exit
exit - exit the ILXI environment
Syntax: exit
Details:
Exits the ILXI environment.
@quit
See help for "exit"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment