mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 12:58:09 +11:00
Allow file-to-file compilation in the emulated shell
This commit is contained in:
parent
fb99f4ad91
commit
3dde51ae98
24
doc/zasm.md
24
doc/zasm.md
@ -5,28 +5,22 @@ from within the shell. What you need is:
|
||||
|
||||
* A mounted filesystem with `zasm` on it.
|
||||
* A block device to read from (can be a file from mounted CFS)
|
||||
* A block device to write to (can theoretically be a file, but technical
|
||||
limitations temporary prevents us that. We'll use a mmap for now).
|
||||
* A block device to write to (can also be a file).
|
||||
|
||||
The emulated shell is already set up with all you need. If you want to run that
|
||||
on a real machine, you'll have to make sure to provide these requirements.
|
||||
|
||||
The emulated shell has a `hello.asm` file in its mounted filesystem that is
|
||||
ready to compile. It has two file handles 0 and 1, mapped to blk IDs 1 and 2.
|
||||
We only use file handle 0 (blk ID 1) and then tell zasm to output to mmap which
|
||||
is configured to start at `0xe00`
|
||||
We will open our source file in handle 0 and our dest file in handle 1. Then,
|
||||
with the power of the `pgm` module, we'll autoload our newly compiled file and
|
||||
execute it!
|
||||
|
||||
Collapse OS
|
||||
> fopn 0 hello.asm ; open file in handle 0
|
||||
> zasm 1 3 ; assemble opened file and spit result in mmap
|
||||
> bsel 3 ; select mmap
|
||||
> mptr e000 ; set memptr to mmap's beginning
|
||||
> peek 5
|
||||
210890CD3C ; looking good
|
||||
> mptr 4200 ; hello.asm is configured to run from 0x4200
|
||||
> load ff ; load compiled code from mmap
|
||||
> peek 5
|
||||
210890CD3C ; looking good
|
||||
> call 00 0000
|
||||
> fnew 1 dest ; create destination file
|
||||
> fopn 0 hello.asm ; open source file in handle 0
|
||||
> fopn 1 dest ; open dest binary in handle 1
|
||||
> zasm 1 3 ; assemble source file into binary file
|
||||
> dest ; call newly compiled file
|
||||
Assembled from the shell
|
||||
> ; Awesome!
|
||||
|
@ -32,9 +32,11 @@
|
||||
#define FS_DATA_PORT 0x01
|
||||
// Controls what address (24bit) the data port returns. To select an address,
|
||||
// this port has to be written to 3 times, starting with the MSB.
|
||||
// Reading this port returns an out-of-bounds indicator. 0 means addr is within
|
||||
// bounds, non zero means either that we're in the middle of an addr-setting
|
||||
// operation or that the address is not within bounds.
|
||||
// Reading this port returns an out-of-bounds indicator. Meaning:
|
||||
// 0 means addr is within bounds
|
||||
// 1 means that we're equal to fsdev size (error for reading, ok for writing)
|
||||
// 2 means more than fsdev size (always invalid)
|
||||
// 3 means incomplete addr setting
|
||||
#define FS_ADDR_PORT 0x02
|
||||
|
||||
static Z80Context cpu;
|
||||
@ -74,8 +76,11 @@ static uint8_t io_read(int unused, uint16_t addr)
|
||||
}
|
||||
} else if (addr == FS_ADDR_PORT) {
|
||||
if (fsdev_addr_lvl != 0) {
|
||||
return fsdev_addr_lvl;
|
||||
} else if (fsdev_ptr >= fsdev_size) {
|
||||
return 3;
|
||||
} else if (fsdev_ptr > fsdev_size) {
|
||||
fprintf(stderr, "Out of bounds FSDEV addr request at %d / %d\n", fsdev_ptr, fsdev_size);
|
||||
return 2;
|
||||
} else if (fsdev_ptr == fsdev_size) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
@ -101,11 +106,17 @@ static void io_write(int unused, uint16_t addr, uint8_t val)
|
||||
return;
|
||||
}
|
||||
if (fsdev_ptr < fsdev_size) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Writing to FSDEV (%d)\n", fsdev_ptr);
|
||||
#endif
|
||||
fsdev[fsdev_ptr] = val;
|
||||
} else if ((fsdev_ptr == fsdev_size) && (fsdev_ptr < MAX_FSDEV_SIZE)) {
|
||||
// We're at the end of fsdev, grow it
|
||||
fsdev[fsdev_ptr] = val;
|
||||
fsdev_size++;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Growing FSDEV (%d)\n", fsdev_ptr);
|
||||
#endif
|
||||
} else {
|
||||
fprintf(stderr, "Out of bounds FSDEV write at %d\n", fsdev_ptr);
|
||||
}
|
||||
|
@ -125,8 +125,8 @@ fsdevPutC:
|
||||
ld a, l
|
||||
out (FS_ADDR_PORT), a
|
||||
in a, (FS_ADDR_PORT)
|
||||
or a
|
||||
jr nz, .error
|
||||
cp 2 ; only A > 1 means error
|
||||
jr nc, .error ; A >= 2
|
||||
pop af
|
||||
out (FS_DATA_PORT), a
|
||||
cp a ; ensure Z
|
||||
|
Loading…
Reference in New Issue
Block a user