Skip to content

Commit

Permalink
Make disk I/O work in alters other than 0
Browse files Browse the repository at this point in the history
  • Loading branch information
meithecatte committed Mar 12, 2023
1 parent 7b680db commit dbb276e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
14 changes: 7 additions & 7 deletions blocks/bootstrap.fth
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ create blk 1 ,
: sp 4 ; : bp 5 ; : si 6 ; : di 7 ;
: al 0 ; : cl 1 ; : dl 2 ; : bl 3 ;
: ah 4 ; : ch 5 ; : dh 6 ; : bh 7 ;
: es 0 ; : cs 1 ; : ss 2 ; : ds 3 ;
: stosb, AA c, ; : stosw, AB c, ; : lodsb, AC c, ;
: lodsw, AD c, ; : movsb, A4 c, ; : movsw, A5 c, ;
: rm-r, 3shl + C0 + c, ; : jmp-r, FF c, 4 rm-r, ;
: next, lodsw, ax jmp-r, ; : movw-rr, 8B c, rm-r, ;
: push, 50 + c, ; : pop, 58 + c, ; : int, cd c, c, ;
: movb-ir, B0 + c, c, ; : movw-ir, B8 + c, , ; -->




: push, 50 + c, ; : pop, 58 + c, ; : int, CD c, c, ;
: movb-ir, B0 + c, c, ; : movw-ir, B8 + c, , ;
: r-rm, swap rm-r, ;
: movw-sr, 8C c, r-rm, ; : movw-rs, 8E c, rm-r, ;
:code ds@ bx push, ds bx movw-sr, next, -->


create packet 10 allot
:code int13 si push, packet si movw-ir, bx ax movw-rr,
disk# dl movb-ir, 13 int, ax bx movw-rr, si pop, next,
variable pos : pos, pos @ ! 2 pos +! ;
: make-packet packet pos ! 10 pos, 2 pos, pos, 0 pos,
: make-packet packet pos ! 10 pos, 2 pos, pos, ds@ pos,
2* pos, 0 pos, 0 pos, 0 pos, ;
: read-block make-packet 4200 int13 ;
: write-block make-packet 4300 int13 ;
Expand Down
2 changes: 1 addition & 1 deletion blocks/filesystem.fth
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
packet pos !
10 pos, ( magic )
swap pos, ( count )
pos, 0 pos, ( buffer )
pos, ds@ pos, ( buffer )
swap pos, pos, 0 pos, 0 pos, ( LBA ) ;
:code do-int13 ( disk ax -- err? )
dx pop, si push, packet si movw-ir,
Expand Down
7 changes: 3 additions & 4 deletions files/alters.fth
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
( well, apparently I was too wasteful. )
( and reengineering everything is not my idea of a good time. )

: es 0 ; : cs 1 ; : ss 2 ; : ds 3 ;
: r-rm, swap rm-r, ;
: movw-sr, $8C c, r-rm, ;
: movw-rs, $8E c, rm-r, ;
: retf, $CB c, ;

:code ds>fs-cmove ( src dst count -- )
Expand Down Expand Up @@ -49,3 +45,6 @@ variable saved-rp
sp@ cell+ saved-sp !
rp@ saved-rp !
undirty >alter (switch) ;

( to make load work outside of alter 0 )
:noname dup blk ! 600 read-block 0 a00 c! 600 >in ! ; is load

0 comments on commit dbb276e

Please sign in to comment.