Added port support, and removed things from BASIC_DEVELOPMENT it does not yet support
This commit is contained in:
@@ -1,17 +1,2 @@
|
|||||||
$1 = "_________"
|
PORT OUT 80 5
|
||||||
A = & $1
|
|
||||||
FOR X = 1 TO 9
|
|
||||||
FOR Y = 1 TO 9
|
|
||||||
PEEK B A
|
|
||||||
IF B = 95 THEN PRINT "_" ;
|
|
||||||
IF B = 88 THEN PRINT "X" ;
|
|
||||||
IF B = 79 THEN PRINT "O" ;
|
|
||||||
C = A % 3
|
|
||||||
IF C = 0 THEN PRINT " "
|
|
||||||
A = A + 1
|
|
||||||
NEXT Y
|
|
||||||
Z = X % 2
|
|
||||||
IF Z = 0 THEN PRINT "You are X"
|
|
||||||
IF Z = 1 THEN PRINT "You are O"
|
|
||||||
NEXT X
|
|
||||||
END
|
END
|
||||||
|
|||||||
@@ -81,19 +81,6 @@ input $1
|
|||||||
|
|
||||||
## Keywords
|
## Keywords
|
||||||
|
|
||||||
You can do this to get the MikeOS API version number:
|
|
||||||
```
|
|
||||||
x = VERSION
|
|
||||||
```
|
|
||||||
Or you can retrieve the lower word of the system clock like this:
|
|
||||||
```
|
|
||||||
x = TIMER
|
|
||||||
```
|
|
||||||
To get the current ink colour, use:
|
|
||||||
```
|
|
||||||
x = INK
|
|
||||||
```
|
|
||||||
|
|
||||||
## The editor
|
## The editor
|
||||||
|
|
||||||
You can run your .BAS programs by using the BAS core util eg.
|
You can run your .BAS programs by using the BAS core util eg.
|
||||||
@@ -176,13 +163,6 @@ Get the position of the cursor. Example:
|
|||||||
curspos a b
|
curspos a b
|
||||||
```
|
```
|
||||||
|
|
||||||
## DELETE
|
|
||||||
|
|
||||||
Removes a file from the disk. Returns 0 in the R variable if the operation was a success, 1 if the delete operation couldn't be completed, or 2 if the file doesn't exist. Example:
|
|
||||||
```
|
|
||||||
delete "myfile.txt"
|
|
||||||
```
|
|
||||||
|
|
||||||
## DO
|
## DO
|
||||||
|
|
||||||
Perform a loop until a condition is met (UNTIL or WHILE). You can also set up an infinite loop with LOOP ENDLESS at the end. Example:
|
Perform a loop until a condition is met (UNTIL or WHILE). You can also set up an infinite loop with LOOP ENDLESS at the end. Example:
|
||||||
@@ -205,10 +185,6 @@ else print "Goodbye"
|
|||||||
|
|
||||||
Terminates execution of the BASIC program and hands control back to the operating system.
|
Terminates execution of the BASIC program and hands control back to the operating system.
|
||||||
|
|
||||||
## FILES
|
|
||||||
|
|
||||||
Prints a list of files that are on the disk on the screen.
|
|
||||||
|
|
||||||
## FOR
|
## FOR
|
||||||
|
|
||||||
Begins a loop, counting upwards using a variable. The loop must be finished with a NEXT instruction and the relevant variable. Example:
|
Begins a loop, counting upwards using a variable. The loop must be finished with a NEXT instruction and the relevant variable. Example:
|
||||||
@@ -423,15 +399,6 @@ print hex x
|
|||||||
```
|
```
|
||||||
In the first print command, the output is 109. In the second, the output is the ASCII character for 109 -- that is, 'm'. And in the third command, it shows the hexadecimal equivalent of 109.
|
In the first print command, the output is 109. In the second, the output is the ASCII character for 109 -- that is, 'm'. And in the third command, it shows the hexadecimal equivalent of 109.
|
||||||
|
|
||||||
## RAND
|
|
||||||
|
|
||||||
Generate a random integer number between two values (inclusive) and store it in a variable. Example:
|
|
||||||
```
|
|
||||||
Make X a random number between 50 and 2000
|
|
||||||
|
|
||||||
rand x 50 2000
|
|
||||||
```
|
|
||||||
|
|
||||||
## READ
|
## READ
|
||||||
|
|
||||||
Read data bytes from a label, first specifying the offset and a variable into which to read. For instance, in the following example we read a small program and poke it into memory locations 50000 to 50012. We then call that location to run the program:
|
Read data bytes from a label, first specifying the offset and a variable into which to read. For instance, in the following example we read a small program and poke it into memory locations 50000 to 50012. We then call that location to run the program:
|
||||||
@@ -453,14 +420,6 @@ mydata:
|
|||||||
190 87 195 232 173 60 195 89 111 33 13 10 0
|
190 87 195 232 173 60 195 89 111 33 13 10 0
|
||||||
```
|
```
|
||||||
|
|
||||||
## RENAME
|
|
||||||
|
|
||||||
Renames one file to another. Literal strings and string variables are allowed. Afterwards, R contains 0 if the operation was a success, 1 if the file was not found, 2 if the write operation failed, or 3 if the target file already exists. Example:
|
|
||||||
```
|
|
||||||
$1 = "myfile.dat"
|
|
||||||
rename "oldfile.txt" $1
|
|
||||||
```
|
|
||||||
|
|
||||||
## RETURN
|
## RETURN
|
||||||
|
|
||||||
Switches execution back to the position of the prior GOSUB statement. See GOSUB above for more information. Example:
|
Switches execution back to the position of the prior GOSUB statement. See GOSUB above for more information. Example:
|
||||||
@@ -468,17 +427,6 @@ Switches execution back to the position of the prior GOSUB statement. See GOSUB
|
|||||||
return
|
return
|
||||||
```
|
```
|
||||||
|
|
||||||
## SAVE
|
|
||||||
|
|
||||||
Saves data from memory to a file on the disk. The first parameter is the filename, the second the location in RAM where the data starts, and the third the number (in bytes) the amount of data to save. After execution, the R variable contains 1 if the file save operation failed (eg if it's a write-only medium), 2 if the file already exists, or 0 if it was successful. Examples:
|
|
||||||
```
|
|
||||||
save "myfile.txt" 40000 256
|
|
||||||
|
|
||||||
$1 = "myfile.txt"
|
|
||||||
x = 40000
|
|
||||||
y = 256
|
|
||||||
save $1 x y
|
|
||||||
```
|
|
||||||
|
|
||||||
## STRING
|
## STRING
|
||||||
|
|
||||||
|
|||||||
@@ -354,12 +354,12 @@ disk_list_contents:
|
|||||||
popa
|
popa
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
disk_file_list:
|
||||||
|
ret
|
||||||
disk_file_exists:
|
disk_file_exists:
|
||||||
ret
|
ret
|
||||||
disk_file_size:
|
disk_file_size:
|
||||||
ret
|
ret
|
||||||
disk_file_list:
|
|
||||||
ret
|
|
||||||
disk_remove_file:
|
disk_remove_file:
|
||||||
ret
|
ret
|
||||||
disk_rename_file:
|
disk_rename_file:
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
; AX = key pressed
|
; AX = key pressed
|
||||||
|
; Waits until key is pressed before returning
|
||||||
os_read_input:
|
os_read_input:
|
||||||
mov ah, 11h ; BIOS call to check for key
|
mov ah, 11h ; BIOS call to check for key
|
||||||
int 16h ; Interrupt
|
int 16h ; Interrupt
|
||||||
@@ -12,6 +13,16 @@ os_read_input:
|
|||||||
int 16h
|
int 16h
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; AX = key pressed
|
||||||
|
; Returns straight away
|
||||||
|
keyboard_check_key:
|
||||||
|
xor ax,ax
|
||||||
|
mov ah, 11h ; BIOS call to check for key
|
||||||
|
int 16h ; Interrupt
|
||||||
|
jz .no_key
|
||||||
|
.no_key:
|
||||||
|
xor ax,ax
|
||||||
|
ret
|
||||||
; -------------------------------------------
|
; -------------------------------------------
|
||||||
; IN:
|
; IN:
|
||||||
; AX = output address
|
; AX = output address
|
||||||
@@ -23,11 +34,6 @@ keyboard_display_input:
|
|||||||
mov ax, bx
|
mov ax, bx
|
||||||
mov bx,20
|
mov bx,20
|
||||||
|
|
||||||
.loop:
|
|
||||||
jmp .check_key_pressed
|
|
||||||
|
|
||||||
jmp .loop
|
|
||||||
|
|
||||||
.check_key_pressed:
|
.check_key_pressed:
|
||||||
call os_read_input
|
call os_read_input
|
||||||
|
|
||||||
@@ -43,7 +49,8 @@ keyboard_display_input:
|
|||||||
dec bx
|
dec bx
|
||||||
|
|
||||||
cmp bx, 0
|
cmp bx, 0
|
||||||
jae .print_current_input ; Echo the user input back
|
je .enter_key ; Once the limit is reached just enter it
|
||||||
|
ja .print_current_input ; Echo the user input back
|
||||||
|
|
||||||
jmp .check_key_pressed
|
jmp .check_key_pressed
|
||||||
|
|
||||||
@@ -59,7 +66,7 @@ keyboard_display_input:
|
|||||||
.backspace:
|
.backspace:
|
||||||
cmp bx, 20 ; Cannot backspace if the cursor is at the start
|
cmp bx, 20 ; Cannot backspace if the cursor is at the start
|
||||||
jb .move_cursor_back ; then .move_cursor_back
|
jb .move_cursor_back ; then .move_cursor_back
|
||||||
jmp .loop ; Else .loop
|
jmp .check_key_pressed ; Else check the next key
|
||||||
|
|
||||||
.move_cursor_back:
|
.move_cursor_back:
|
||||||
mov ah, 0Eh
|
mov ah, 0Eh
|
||||||
@@ -73,7 +80,7 @@ keyboard_display_input:
|
|||||||
|
|
||||||
inc bx
|
inc bx
|
||||||
dec di
|
dec di
|
||||||
jmp .loop
|
jmp .check_key_pressed
|
||||||
|
|
||||||
.print_current_input: ; Echo back that character and return the key inputing
|
.print_current_input: ; Echo back that character and return the key inputing
|
||||||
stosb
|
stosb
|
||||||
@@ -81,9 +88,9 @@ keyboard_display_input:
|
|||||||
int 10h
|
int 10h
|
||||||
jmp .check_key_pressed
|
jmp .check_key_pressed
|
||||||
|
|
||||||
keyboard_get_cursor_pos: ;TODO
|
keyboard_get_cursor_pos:
|
||||||
ret
|
ret
|
||||||
keyboard_wait_for_key: ;TODO
|
keyboard_wait_for_key:
|
||||||
ret
|
ret
|
||||||
keyboard_show_cursor:
|
keyboard_show_cursor:
|
||||||
ret
|
ret
|
||||||
@@ -91,5 +98,3 @@ keyboard_hide_cursor:
|
|||||||
ret
|
ret
|
||||||
keyboard_move_cursor:
|
keyboard_move_cursor:
|
||||||
ret
|
ret
|
||||||
keyboard_check_key:
|
|
||||||
ret
|
|
||||||
|
|||||||
@@ -1,7 +1,20 @@
|
|||||||
|
; IN:
|
||||||
|
; DX = port address
|
||||||
|
; AL = byte
|
||||||
port_byte_out:
|
port_byte_out:
|
||||||
|
pusha
|
||||||
|
out dx,al
|
||||||
|
popa
|
||||||
ret
|
ret
|
||||||
|
; -----------------------------------------
|
||||||
|
; IN:
|
||||||
|
; DX = port address
|
||||||
|
; OUT:
|
||||||
|
; AL = byte from port
|
||||||
port_byte_in:
|
port_byte_in:
|
||||||
|
in al, dx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
port_serial_enable:
|
port_serial_enable:
|
||||||
ret
|
ret
|
||||||
port_send_via_serial:
|
port_send_via_serial:
|
||||||
|
|||||||
@@ -331,7 +331,5 @@ string_lower_case: ; to lower case
|
|||||||
popa
|
popa
|
||||||
ret
|
ret
|
||||||
|
|
||||||
string_input:
|
|
||||||
ret
|
|
||||||
string_print_2hex:
|
string_print_2hex:
|
||||||
ret
|
ret
|
||||||
|
|||||||
Reference in New Issue
Block a user