diff options
Diffstat (limited to 'jefs.fs')
| -rw-r--r-- | jefs.fs | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -114,8 +114,9 @@ hex : ret, c3 c, ; decimal hex variable rex variable modrm +variable disp -: asm$ 0 rex ! c0 modrm ! ; +: asm$ 0 rex ! c0 modrm ! 0 disp ! ; : rex.w rex @ 48 or rex ! ; : rex.r rex @ 44 or rex ! ; @@ -147,10 +148,11 @@ variable modrm : /2 modrm @ 10 or modrm ! ; : /3 modrm @ 18 or modrm ! ; : /4 modrm @ 20 or modrm ! ; : /5 modrm @ 28 or modrm ! ; : /6 modrm @ 30 or modrm ! ; : /7 modrm @ 38 or modrm ! ; +: modrm, ; \ TODO store and write the displacement if given : mod0 modrm @ 3f and modrm ! ; -: d) mod0 0<> if modrm @ 40 or modrm ! then ; \ disp8 or 0 only for now +: d) disp ! mod0 0<> if modrm @ 40 or modrm ! then ; \ disp8 or 0 only for now : mov, rex, 8b c, modrm @ c, asm$ ; @@ -161,6 +163,7 @@ variable modrm decimal \ }}} +: not 0= ; : / /mod swap drop ; : mod /mod drop ; : negate 0 swap - ; @@ -205,8 +208,9 @@ variable hld : ? @ . ; : .s sp cell+ ( skip sp itself ) begin dup s0 @ > while dup @ .qword cell+ repeat drop cr ; : .rs rp cell+ ( skip rsp itself ) begin dup rs0 @ > while dup @ .qword cell+ repeat drop cr ; -: bytes-allocated hend @ h0 @ - ; -: bytes-used here @ h0 @ - ; + +: bytes-allocated heremax @ herestart @ - ; +: bytes-used here @ herestart @ - ; : bytes-free bytes-allocated bytes-used - ; : .free bytes-free u. ." of " bytes-allocated u. ." bytes free (used " bytes-used (.) say ." )" cr ; @@ -244,7 +248,7 @@ variable hld endcase cr then ; \ }}} -\ FILE I/O {{{ +\ I/O {{{ 0 constant stdin 1 constant stdout 2 constant stderr @@ -263,6 +267,7 @@ make file-buffer file-buffer-length allot \ TODO error handling (0< abs → errno i think) \ flags are zero on success +\ maybe there should be some sort of read buffering support here : open-file ( mode zstr -- ?fd flag ) 0 -rot sysopen errno ; : close-file ( fd -- flag ) sysclose errno-flag ; : read-file ( c-addr u fd -- ?u flag ) >r swap r> sysread errno ; @@ -270,6 +275,9 @@ make file-buffer file-buffer-length allot \ }}} \ INTERACTIVITY {{{ +\ i hate dealing with user input!!! +\ but my idea is: when reading forth from a file, +\ words are read into a buffer, and read from there. \ }}} .free |
