diff --git a/asm.jrt b/asm.jrt index 7d34bbb..7fd4d3a 100755 --- a/asm.jrt +++ b/asm.jrt @@ -334,14 +334,14 @@ var ignoreimm : AX? oparg-reg? oparg-val @ 0x00 = and ; : >inout* ( base ) - arg2 oparg-reg? oparg-val @ 0x03 ( DX ) = and arg1 if + oparg-reg? oparg-val @ 0x03 ( DX ) = and swap-args if AL? if 8 + >t 2ret then AX? if 9 + >t 2ret then then - arg2 oparg-imm? arg1 if - AL? if >t oparg-val @ >t 2ret then - AX? if 1+ >t oparg-val @ >t 2ret then + swap-args oparg-imm? swap-args if + AL? if swap-args >t oparg-val @ >t 2ret then + AX? if swap-args 1+ >t oparg-val @ >t 2ret then then ; -2 :op IN 0xe4 >inout* ; -2 :op OUT 0xe6 >inout* ; +2 :op IN arg2 0xe4 >inout* ; +2 :op OUT 0xe6 >inout* ; diff --git a/assemble.com b/assemble.com index dd1bb14..c87cb60 100755 Binary files a/assemble.com and b/assemble.com differ diff --git a/beep.jrt b/beep.jrt new file mode 100755 index 0000000..a6ca975 --- /dev/null +++ b/beep.jrt @@ -0,0 +1,27 @@ +import timer.jrt + +:asm >spk ( div -- ) + MOV AL 0xb6 # + OUT 0x43 # AL + POP AX + OUT 0x42 # AL + MOV AL AH + OUT 0x42 # AL + IN AL 0x61 # + OR AL 0x03 # + OUT 0x61 # AL + NEXT + +:asm silence ( -- ) + IN AL 0x61 # + AND AL 0xfc # + OUT 0x61 # AL + NEXT + +: slide ( div count + -- ) + >r begin over >spk 1 sleep-csec swap r@ + swap 1- dup not until + rdrop drop drop silence ; +: boop ( div count -- ) swap >spk sleep-csec silence ; +: noise ( count -- ) + begin rand >spk 1 sleep-csec 1- dup not until drop silence ; + diff --git a/common.jrt b/common.jrt new file mode 100755 index 0000000..d10612c --- /dev/null +++ b/common.jrt @@ -0,0 +1,9 @@ +import text.jrt +import keys.jrt +import random.jrt + +: !+ ( v p -- ) dup @ t CLI PUSH AX ; + :timm ISR-DONE MOV AL 0x20 # OUT 0x20 # AL POP AX STI IRET ; + :timm CHAIN-ISR ( isr -- ) + POP AX + STI + JMP FAR CS: @+ ; } + +:asm get-cseg + PUSH CS + NEXT + +: isr>int ( isr -- int ) 2 cells + @ ; +: isr>code ( isr -- p ) 3 cells + ; +: uninstall-isr ( isr -- ) + >r r@ cell + @ r@ @ int intvect! ; +: install-isr ( isr -- ) + >r r@ isr>int intvect@ r@ ! r@ cell + ! + get-cseg r@ isr>code int intvect! ; + +var timer +0 irq :asmisr timer-isr + MOV AX CS: timer @+ + INC AX + MOV CS: timer @+ AX + AND AX 0x03 # + JZ 0 @> + ISR-DONE +0 <: + timer-isr CHAIN-ISR + +:asm set-timer-div ( div -- ) + MOV AL 0x36 # + OUT 0x43 # AL + POP AX + OUT 0x40 # AL + MOV AL AH + OUT 0x40 # AL + NEXT + +: sleep-csec ( cs -- ) + timer @ + begin dup timer @ <= until drop ; +: install-timer 0xffff 2 >> set-timer-div timer-isr install-isr ; +: uninstall-timer 0xffff set-timer-div timer-isr uninstall-isr ; + diff --git a/zipoff.com b/zipoff.com index fc20566..11ee562 100755 Binary files a/zipoff.com and b/zipoff.com differ diff --git a/zipoff.jrt b/zipoff.jrt index 40b6ff3..d8bd29e 100755 --- a/zipoff.jrt +++ b/zipoff.jrt @@ -162,5 +162,7 @@ dbg" boot" MOV BP 0x00 # NEXT +} import common.jrt { + here s", zipstub.seg" s" zipoff.com" writeenv diff --git a/zipstub.seg b/zipstub.seg index 6972113..a997669 100755 Binary files a/zipstub.seg and b/zipstub.seg differ