`0 | lipumusi: a v3 z-machine interpreter for the ilo computer | | Some design notes: | | - Story bytes are packed little-endian within ilo cells | - Z-machine words remain big-endian. | - The story starts at block 0 | - Saves follow the last story block as determined by the story | size header. | - This interpreter does not support stories missing the length | in the header :loader [ :.start | ( -- ) >&calls.frames !calls.frame >#1 !output.screen-output | Read the header first; the V3 length is in two-byte units. :.open | ( -- ) >#0 >&memory.story liio_ #2 >#4096 !memory.size >#0 ~memory.byte lieqlieq #3 #0 ?diagnostics.version-error >#26 ~memory.word limu_ #2 !memory.size | Block I/O cannot report EOF; early stories need an explicit length. @memory.size lilt_ #64 @memory.size ligtor_ #131072 ?diagnostics.bad-story @memory.size liad_ #4095 >#12 sr_ !save.data-base >#1 !.cursor :.load | ( -- ) @.cursor @save.data-base lt_ { @.cursor @.cursor >#10 slliad_ &memory.story liio_ #2 @.cursor liad_ #1 !.cursor ^.load } >#64 !.cursor >#0 !.file-checksum :.checksum-story | ( -- ) @.cursor @memory.size lt_ { @.file-checksum @.cursor ~memory.byte adlian_ #65535 !.file-checksum @.cursor liad_ #1 !.cursor ^.checksum-story } >&memory.story >&.identity >#16 cy_ >#0 ~memory.byte lieqlieq #3 #0 ?diagnostics.version-error >#14 ~memory.word !memory.static @memory.static lilt_ #64 @memory.static @memory.size gtor_ ?diagnostics.bad-story >#6 ~memory.word !cpu.pc @cpu.pc lilt_ #64 @cpu.pc @memory.size ltlieqor #0 ?diagnostics.bad-story >#12 ~memory.word !memory.globals @memory.globals lilt_ #64 @memory.globals liad_ #480 @memory.static gtor_ ?diagnostics.bad-story >#26 ~memory.word limu_ #2 !.declared @.declared { @.declared lilt_ #64 @.declared @memory.size gtor_ ?diagnostics.bad-story } >#0 !stack.sp >#0 !calls.depth >#0 !stack.eval-base >#0 !output.stream-depth >&calls.frames !calls.frame >#1 !output.screen-output >&save.zero-page >&calls.frames >#20 cy_ ~random.reseed >#17 ~memory.byte lian_ #252 @.preserve-flags or_ >#17 ~memory.write.write-byte ~memory.write.capabilities ^cpu.step \.cursor #0 \.declared #0 \.file-checksum #0 \.preserve-flags #0 \.identity *16 ] :cpu [ :.step | ( -- ) @.pc !.instruction-pc ~memory.next !.instruction >#0 !.argc @.instruction lilt_ #128 ?.long-form @.instruction lilt_ #192 ?.short-form @.instruction lian_ #31 !.opcode >#2 !.class @.instruction lian_ #32 { >#3 !.class } ~memory.next !.types >#6 !.type-shift :.variable-operands | ( -- ) @.types @.type-shift srlian_ #3 !.type @.type lieq_ #3 ?.dispatch ~decode.operand @.type-shift lisu_ #2 !.type-shift @.type-shift lilt_ #0 ?.dispatch ^.variable-operands :.long-form | ( -- ) >#2 !.class @.instruction lian_ #31 !.opcode @.instruction >#6 srlian_ #1 liad_ #1 !.type ~decode.operand @.instruction >#5 srlian_ #1 liad_ #1 !.type ~decode.operand ^.dispatch :.short-form | ( -- ) @.instruction lian_ #15 !.opcode @.instruction >#4 srlian_ #3 !.type >#0 !.class @.type lieq_ #3 ?.dispatch >#1 !.class ~decode.operand :.dispatch | ( -- ) @.operands !.a >&.operands liadfe_ #1 !.b @.class >#5 slliad_ &.dispatch-table @.opcode adfeju_ :.op-input-stream | ( -- ) @.argc line_ #1 ?diagnostics.unsupported @.a lieq_ #0 ?.step >&diagnostics.no-input-stream ^diagnostics.error :.op-print-char | ( -- ) @.argc line_ #1 ?diagnostics.unsupported @.a ~output.emit ^.step :.op-print-num | ( -- ) @.argc line_ #1 ?diagnostics.unsupported @.a ~format.signed ~format.number ^.step :.op-push | ( -- ) @.argc line_ #1 ?diagnostics.unsupported @.a ~stack.push ^.step :.op-pull | ( -- ) @.argc line_ #1 ?diagnostics.unsupported ~stack.pop !variables.result @.a !variables.variable ~variables.put-indirect ^.step :.op-rtrue | ( -- ) >#1 ^calls.return-value :.op-rfalse | ( -- ) >#0 ^calls.return-value :.op-print | ( -- ) @.pc ~text.ztext !.pc ^.step :.op-print-ret | ( -- ) @.pc ~text.ztext !.pc >#13 ~output.emit >#1 ^calls.return-value :.op-ret-popped | ( -- ) ~stack.pop ^calls.return-value :.op-verify | ( -- ) @loader.file-checksum >#28 ~memory.word eq_ ^control.branch :.op-restart | ( -- ) >#17 ~memory.byte lian_ #3 !loader.preserve-flags ^loader.open :.op-new-line | ( -- ) >#13 ~output.emit ^.step :.op-pop | ( -- ) ~stack.pop dr_ ^.step :.op-jz | ( -- ) @.a lieq_ #0 ^control.branch :.op-get-sibling-child | ( -- ) @.a ~objects.object @.opcode liadad_ #4 ~memory.byte du_ !.condition ~variables.store @.condition ^control.branch :.op-get-parent | ( -- ) @.a ~objects.object liad_ #4 ~memory.byte ~variables.store ^.step :.op-get-prop-len | ( -- ) @.a lieq_ #0 { >#0 ~variables.store ^.step } @.a lisu_ #1 ~memory.byte >#5 srliad_ #1 ~variables.store ^.step :.op-inc-dec | ( -- ) @.a ~calls.get-indirect @.opcode lieq_ #5 { liad_ #1 } @.opcode lieq_ #6 { lisu_ #1 } lian_ #65535 !variables.result @.a !variables.variable ~variables.put-indirect ^.step :.op-print-addr | ( -- ) @.a ~text.ztext dr_ ^.step :.op-remove-obj | ( -- ) @.a !objects.obj ~objects.remove-object ^.step :.op-print-obj | ( -- ) @.a ~objects.object liad_ #7 ~memory.word du_ ~memory.byte lieq_ #0 { dr_ ^.step } liad_ #1 ~text.ztext dr_ ^.step :.op-ret | ( -- ) @.a ^calls.return-value :.op-print-paddr | ( -- ) @.a limu_ #2 ~text.ztext dr_ ^.step :.op-load | ( -- ) @.a ~calls.get-indirect ~variables.store ^.step :.op-jump | ( -- ) @.a ~format.signed @.pc adlisu_ #2 !.pc ^.step :.op-not | ( -- ) @.a lixo_ #-1 ~variables.store ^.step :.op-je | ( -- ) >#0 !.condition >#1 !.index :.je-loop | ( -- ) @.index @.argc lt_ { @.operands @.index liadfeeq &.operands @.condition or_ !.condition @.index liad_ #1 !.index ^.je-loop } @.condition ^control.branch :.op-jl | ( -- ) @.argc line_ #2 ?diagnostics.unsupported @.a ~format.signed @.b ~format.signed lt_ ^control.branch :.op-jg | ( -- ) @.argc line_ #2 ?diagnostics.unsupported @.a ~format.signed @.b ~format.signed gt_ ^control.branch :.op-dec-inc-chk | ( -- ) @.argc line_ #2 ?diagnostics.unsupported @.a ~calls.get-indirect @.opcode lieq_ #4 { lisu_ #1 } @.opcode lieq_ #5 { liad_ #1 } lian_ #65535 !variables.result @.a !variables.variable ~variables.put-indirect @variables.result ~format.signed @.b ~format.signed @.opcode lieq_ #4 { lt_ ^control.branch } gt_ ^control.branch :.op-jin | ( -- ) @.argc line_ #2 ?diagnostics.unsupported @.a ~objects.object liad_ #4 ~memory.byte @.b eq_ ^control.branch :.op-test | ( -- ) @.argc line_ #2 ?diagnostics.unsupported @.a @.b an_ @.b eq_ ^control.branch :.op-attribute | ( -- ) @.argc line_ #2 ?diagnostics.unsupported ^objects.attribute :.op-insert-obj | ( -- ) @.argc line_ #2 ?diagnostics.unsupported ^objects.insert-object :.op-property | ( -- ) @.argc line_ #2 ?diagnostics.unsupported ^objects.property-op :.op-or | ( -- ) @.argc line_ #2 ?diagnostics.unsupported @.a @.b or_ ~variables.store ^.step :.op-and | ( -- ) @.argc line_ #2 ?diagnostics.unsupported @.a @.b an_ ~variables.store ^.step :.op-add | ( -- ) @.argc line_ #2 ?diagnostics.unsupported @.a @.b ad_ ~variables.store ^.step :.op-sub | ( -- ) @.argc line_ #2 ?diagnostics.unsupported @.a @.b su_ ~variables.store ^.step :.op-mul | ( -- ) @.argc line_ #2 ?diagnostics.unsupported @.a ~format.signed @.b ~format.signed mu_ ~variables.store ^.step :.op-store | ( -- ) @.argc line_ #2 ?diagnostics.unsupported @.a !variables.variable @.b !variables.result ~variables.put-indirect ^.step :.op-loadb | ( -- ) @.argc line_ #2 ?diagnostics.unsupported @.a @.b ad_ ~memory.byte ~variables.store ^.step :.op-loadw | ( -- ) @.argc line_ #2 ?diagnostics.unsupported @.a @.b limuad_ #2 ~memory.word ~variables.store ^.step :.op-div-mod | ( -- ) @.argc line_ #2 ?diagnostics.unsupported @.b lieq_ #0 ?diagnostics.division-error @.a ~format.signed @.b ~format.signed di_ @.opcode lieq_ #23 { swdr_ ~variables.store ^.step } dr_ ~variables.store ^.step :.store-memory | ( -- ) @.argc line_ #3 ?diagnostics.unsupported @.a @.b ad_ !.destination @.opcode lieq_ #1 { @.a @.b limuad_ #2 !.destination } >&.operands liadfe_ #2 @.destination @.opcode lieq_ #1 { ~memory.guest.guest-word ^.step } ~memory.guest.guest-byte ^.step \.pc #0 \.instruction #0 \.argc #0 \.dispatch-table | Class 0: 0OP &cpu.op-rtrue &cpu.op-rfalse &cpu.op-print &cpu.op-print-ret &cpu.step &save.save-game &save.restore-game &cpu.op-restart &cpu.op-ret-popped &cpu.op-pop &diagnostics.halt &cpu.op-new-line &cpu.step &cpu.op-verify &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported | Class 1: 1OP &cpu.op-jz &cpu.op-get-sibling-child &cpu.op-get-sibling-child &cpu.op-get-parent &cpu.op-get-prop-len &cpu.op-inc-dec &cpu.op-inc-dec &cpu.op-print-addr &diagnostics.unsupported &cpu.op-remove-obj &cpu.op-print-obj &cpu.op-ret &cpu.op-jump &cpu.op-print-paddr &cpu.op-load &cpu.op-not &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported | Class 2: 2OP &diagnostics.unsupported &cpu.op-je &cpu.op-jl &cpu.op-jg &cpu.op-dec-inc-chk &cpu.op-dec-inc-chk &cpu.op-jin &cpu.op-test &cpu.op-or &cpu.op-and &cpu.op-attribute &cpu.op-attribute &cpu.op-attribute &cpu.op-store &cpu.op-insert-obj &cpu.op-loadw &cpu.op-loadb &cpu.op-property &cpu.op-property &cpu.op-property &cpu.op-add &cpu.op-sub &cpu.op-mul &cpu.op-div-mod &cpu.op-div-mod &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported | Class 3: VAR &calls.call &cpu.store-memory &cpu.store-memory &objects.put-property &input.read-line &cpu.op-print-char &cpu.op-print-num &random.random &cpu.op-push &cpu.op-pull &cpu.step &cpu.step &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &output.output-stream &cpu.op-input-stream &cpu.step &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported &diagnostics.unsupported \.opcode #0 \.class #0 \.types #0 \.type-shift #0 \.type #0 \.a #0 \.b #0 \.destination #0 \.operands *4 \.instruction-pc #0 \.index #0 \.condition #0 ] :memory.guest [ :.guest-word | ( value address -- ) !memory.guest-address !memory.guest-value @memory.guest-value >#8 srlian_ #255 !memory.value @memory.guest-address !memory.byte-address ~.check-guest-byte @memory.guest-value lian_ #255 !memory.value @memory.guest-address liad_ #1 !memory.byte-address ~.check-guest-byte @memory.guest-value @memory.guest-address ~memory.write.write-word ; :.guest-byte | ( value address -- ) !memory.byte-address lian_ #255 !memory.value ~.check-guest-byte ^memory.write-byte-raw :.check-guest-byte | ( -- ) @memory.byte-address lilt_ #0 @memory.byte-address @memory.static ltlieqor #0 ?diagnostics.memory-error @memory.byte-address lilt_ #64 { @memory.byte-address ~memory.byte !memory.old-byte @memory.byte-address lieq_ #17 { @memory.old-byte lian_ #252 @memory.value lianne_ #252 ?diagnostics.memory-error ; } @memory.old-byte @memory.value ne_ ?diagnostics.memory-error } ; ] | Decode operands left-to-right. Guest stack is an ilo RAM array. :decode [ :.operand | ( -- ) @cpu.type lieq_ #0 { ~memory.next >#8 sl_ ~memory.next or_ ^.operand-ready } ~memory.next @cpu.type lieq_ #2 %variables.get-variable :.operand-ready | ( value -- ) @cpu.argc liadst_ &cpu.operands @cpu.argc liad_ #1 !cpu.argc ; ] :variables [ :.get-variable | ( variable -- value ) !.variable @.variable lieq_ #0 ?stack.pop @.variable lilt_ #16 { @.variable @calls.frame liadfegt #3 ?diagnostics.locals-error @calls.frame liad_ #3 @.variable adfe_ ; } @.variable lisulimu #16 #2 @memory.globals ad_ ~memory.word ; :.store | ( value -- ) lian_ #65535 !.result ~memory.next !.variable ^.put-variable :.put-indirect | ( -- ) @.variable lieq_ #0 { @stack.sp @stack.eval-base eq_ ?diagnostics.stack-error @.result @stack.sp lisuliad #1 &stack.cells st_ ; } :.put-variable | ( -- ) @.variable lieq_ #0 { @.result ~stack.push ; } @.variable lilt_ #16 { @.variable @calls.frame liadfegt #3 ?diagnostics.locals-error @.result lian_ #65535 @calls.frame liad_ #3 @.variable adst_ ; } @.variable lisulimu #16 #2 @memory.globals ad_ !cpu.destination @cpu.destination liad_ #1 @memory.static ltlieq_ #0 ?diagnostics.memory-error @cpu.destination !memory.byte-address @.result >#8 srlian_ #255 !memory.value ~memory.write-byte-raw @cpu.destination liad_ #1 !memory.byte-address @.result lian_ #255 !memory.value ~memory.write-byte-raw ; \.variable #0 \.result #0 ] :stack [ :.push | ( value -- ) @.sp lieq_ #4096 ?diagnostics.stack-error @.sp liadst_ &.cells @.sp liad_ #1 !.sp ; :.pop | ( -- value ) @.sp @.eval-base eq_ ?diagnostics.stack-error @.sp lisu_ #1 !.sp @.sp liadfe_ &.cells ; \.sp #0 \.cells *4096 \.eval-base #0 ] :format [ :.signed | ( word -- signed ) dulian_ #32768 { lisu_ #65536 } ; :.number | ( number -- ) dulilt_ #0 { >$- ~output.emit >#0 swsu_ } duligt_ #9 { >#10 di_ ~.number liad_ $0 ~output.emit ; } liad_ $0 ~output.emit ; ] | Guest calls use explicit RAM frames, independent of ilo return addresses. :calls [ :.call | ( -- ) ~memory.next !.call-variable @cpu.a lieq_ #0 { >#0 !variables.result @.call-variable !variables.variable ~variables.put-variable ^cpu.step } @.depth lieq_ #127 ?diagnostics.stack-error @.depth liad_ #1 !.depth @.frame liad_ #20 !.frame @cpu.pc @.frame st_ @.call-variable @.frame liadst_ #1 @stack.sp @.frame liadst_ #2 @stack.sp !stack.eval-base @cpu.a limu_ #2 !cpu.pc ~memory.next !.local-count @.local-count ligt_ #15 ?diagnostics.locals-error @.local-count @.frame liadst_ #3 >#0 !cpu.index :.call-defaults | ( -- ) @cpu.index @.local-count lt_ { ~memory.next >#8 sl_ ~memory.next or_ @.frame liad_ #4 @cpu.index adst_ @cpu.index liad_ #1 !cpu.index ^.call-defaults } >#1 !cpu.index :.call-arguments | ( -- ) @cpu.index @cpu.argc lt_ @cpu.index @.local-count gtlieqan #0 { @cpu.index liadfe_ &cpu.operands @.frame liad_ #3 @cpu.index adst_ @cpu.index liad_ #1 !cpu.index ^.call-arguments } ^cpu.step :.return-value | ( value -- ) lian_ #65535 !variables.result @.depth lieq_ #0 ?diagnostics.halt @.frame fe_ !cpu.pc @.frame liadfe_ #1 !variables.variable @.frame liadfe_ #2 !stack.sp @.frame lisu_ #20 !.frame @.depth lisu_ #1 !.depth @.frame liadfe_ #2 !stack.eval-base ~variables.put-variable ^cpu.step :.get-indirect | ( variable -- value ) dulieq_ #0 { dr_ @stack.sp @stack.eval-base eq_ ?diagnostics.stack-error @stack.sp lisuliad #1 &stack.cells fe_ ; } ^variables.get-variable \.frame #0 \.depth #0 \.call-variable #0 \.local-count #0 \.frames *2560 ] :control [ :.branch | ( condition -- ) lieqlieq #0 #0 !cpu.condition ~memory.next !.branch-byte @.branch-byte lian_ #63 !.offset @.branch-byte lianlieq #64 #0 { @.offset >#8 sl_ ~memory.next or_ !.offset @.offset lian_ #8192 { @.offset lisu_ #16384 !.offset } } @.branch-byte lianlieq #128 #0 lieq_ #0 @cpu.condition ne_ ?cpu.step @.offset lieq_ #0 @.offset lieqor_ #1 { @.offset ^calls.return-value } @cpu.pc @.offset adlisu_ #2 !cpu.pc ^cpu.step \.branch-byte #0 \.offset #0 ] | Checked guest memory stores. :memory.write [ :.capabilities | ( -- ) | Serial text backend: no status line, split screen or variable font. >#1 ~memory.byte lianlior #143 #16 >#1 ~.write-byte ; :.write-byte | ( value address -- ) !memory.byte-address lian_ #255 !memory.value @memory.byte-address lilt_ #0 @memory.byte-address @memory.static ltlieqor #0 ?diagnostics.memory-error ^memory.write-byte-raw :.write-word | ( value address -- ) !memory.word-address !memory.word-value @memory.word-address lilt_ #0 @memory.word-address liad_ #1 @memory.static ltlieqor #0 ?diagnostics.memory-error @memory.word-value >#8 sr_ @memory.word-address ~.write-byte @memory.word-value @memory.word-address liad_ #1 ~.write-byte ; ] | Output streams: serial screen and up to sixteen nested memory streams. :output [ :.output-stream | ( -- ) @cpu.a ~format.signed !.stream @.stream lieq_ #1 { >#1 !.screen-output ^cpu.step } @.stream lieq_ #-1 { >#0 !.screen-output ^cpu.step } @.stream lieq_ #2 @.stream lieqor_ #-2 ?cpu.step @.stream lieq_ #3 { @cpu.argc lilt_ #2 ?diagnostics.unsupported @.stream-depth lieq_ #16 ?diagnostics.stack-error @cpu.b @.stream-depth liadst_ &.streams @.stream-depth liad_ #1 !.stream-depth >#0 @cpu.b ~memory.write.write-word ^cpu.step } @.stream lieq_ #-3 { @.stream-depth lieq_ #0 ?diagnostics.stack-error @.stream-depth lisu_ #1 !.stream-depth ^cpu.step } ^diagnostics.unsupported :.emit | ( zscii -- ) !.emit-char @.emit-char lieq_ #0 { ; } @.emit-char line_ #13 { @.emit-char lilt_ #32 ?diagnostics.unsupported @.emit-char ligt_ $~ { @.emit-char lilt_ #155 @.emit-char ligtor_ #223 ?diagnostics.unsupported } } @.stream-depth { @.stream-depth lisuliad #1 &.streams fe_ !.stream-address @.stream-address ~memory.word !.stream-length @.emit-char @.stream-address @.stream-length adliad_ #2 ~memory.write.write-byte @.stream-length liad_ #1 @.stream-address ~memory.write.write-word ; } @.screen-output { @.emit-char lieq_ #13 { >#10 !.emit-char } @.emit-char ligt_ #154 { @.emit-char lisuliad #155 &unicode.table fe_ !.emit-char @.emit-char >#6 srlior_ #192 liio_ #0 @.emit-char lianlior #63 #128 !.emit-char } @.emit-char liio_ #0 } ; \.stream #0 \.stream-depth #0 \.screen-output #0 \.emit-char #0 \.stream-address #0 \.stream-length #0 \.streams *16 ] :random [ | Core ilo has no clock/entropy discovery. Mix input and a changing nonce | when returning to random mode; explicit negative seeds ignore both. :.reseed | ( -- ) @.nonce liad_ #1 !.nonce @.seed @.noise xo_ @.nonce xo_ @loader.file-checksum xo_ lixo_ #1831565813 !.seed @.seed lieq_ #0 { >#1 !.seed } ~.next ; :.next | ( -- ) | xorshift32: mask the arithmetic right shift to make it logical. | Older save files can contain a zero seed; never enter the absorbing state. @.seed lieq_ #0 { >#1831565813 !.seed } @.seed @.seed >#13 slxo_ !.seed @.seed @.seed >#17 srlian_ #32767 xo_ !.seed @.seed @.seed >#5 slxo_ !.seed ; :.random | ( -- ) @cpu.a ~format.signed !.random-range @.random-range lilt_ #1 { @.random-range lieq_ #0 { ~.reseed >#0 ~variables.store ^cpu.step } >#0 @.random-range su_ !.seed >#0 ~variables.store ^cpu.step } | Reject the incomplete tail before taking a remainder (no modulo bias). >#2147483647 @.random-range di_ dr_ >#2147483647 swsu_ !.limit :.sample | ( -- ) ~.next @.seed >#1 srlian_ #2147483647 !.sample-value @.sample-value lieq_ #0 ?.sample @.sample-value lisu_ #1 !.sample-value @.sample-value @.limit ltlieq_ #0 ?.sample @.sample-value @.random-range didrliad #1 ~variables.store ^cpu.step \.seed #0 \.random-range #0 \.noise #0 \.nonce #0 \.limit #0 \.sample-value #0 ] | Z-text decoder. Each invocation saves its state on ilo's address stack; | abbreviations may not themselves contain abbreviations (V3 standard). :text [ :.ztext | ( address -- next-address ) @.zaddress pu_ @.zword pu_ @.zshift pu_ @.alphabet pu_ @.zstate pu_ @.zpartial pu_ !.zaddress >#0 !.alphabet >#0 !.zstate :.zword-loop | ( -- next-address ) @.zaddress ~memory.word !.zword @.zaddress liad_ #2 !.zaddress >#10 !.zshift :.zchar-loop | ( -- next-address ) @.zword @.zshift srlian_ #31 !.zchar @.zstate lieq_ #1 ?.zabbreviation @.zstate lieq_ #2 { @.zchar >#5 sl_ !.zpartial >#3 !.zstate ^.znext } @.zstate lieq_ #3 { @.zpartial @.zchar or_ ~output.emit >#0 !.zstate >#0 !.alphabet ^.znext } @.zchar lieq_ #0 { >#32 ~output.emit >#0 !.alphabet ^.znext } @.zchar lilt_ #4 { @.zchar lisulimu #1 #32 !.zpartial >#1 !.zstate ^.znext } @.zchar lieq_ #4 { >#1 !.alphabet ^.znext } @.zchar lieq_ #5 { >#2 !.alphabet ^.znext } @.alphabet lieq_ #2 { @.zchar lieq_ #6 { >#2 !.zstate ^.znext } @.zchar lisuliad #6 &.punctuation fe_ ~output.emit >#0 !.alphabet ^.znext } @.zchar liad_ #91 @.alphabet lieq_ #1 { lisu_ #32 } ~output.emit >#0 !.alphabet ^.znext :.zabbreviation | ( -- next-address ) @.zpartial @.zchar adlimu_ #2 >#24 ~memory.word ad_ ~memory.word limu_ #2 @.zdepth { dr_ >&.text-message ^diagnostics.error } >#1 !.zdepth ~.ztext dr_ >#0 !.zdepth >#0 !.zstate >#0 !.alphabet :.znext | ( -- next-address ) @.zshift lisu_ #5 !.zshift @.zshift liltlieq #0 #0 ?.zchar-loop @.zword lianlieq #32768 #0 ?.zword-loop @.zaddress po_ !.zpartial po_ !.zstate po_ !.alphabet po_ !.zshift po_ !.zword po_ !.zaddress ; \.zaddress #0 \.zword #0 \.zshift #0 \.alphabet #0 \.zstate #0 \.zpartial #0 \.zchar #0 \.zdepth #0 \.punctuation #32 #13 $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $. $, $! $? $_ $# $' $" $/ $\ $- $: $( $) \.text-message 'Invalid_abbreviation_nesting. ] | V3 object entries and properties. :objects [ :.object | ( object -- address ) dulilt_ #1 { dr_ >&.object-message ^diagnostics.error } duligt_ #255 { dr_ >&.object-message ^diagnostics.error } lisulimu #1 #9 >#10 ~memory.word adliad_ #62 ; :.attribute | ( -- ) @cpu.b lilt_ #0 @cpu.b ligtor_ #31 ?diagnostics.memory-error @cpu.a ~.object @cpu.b >#3 srad_ !.attribute-address >#128 @cpu.b liansr_ #7 !.attribute-mask @.attribute-address ~memory.byte !.attribute-value @cpu.opcode lieq_ #10 { @.attribute-value @.attribute-mask an_ ^control.branch } @cpu.opcode lieq_ #11 { @.attribute-value @.attribute-mask or_ @.attribute-address ~memory.write.write-byte ^cpu.step } @.attribute-value @.attribute-mask lixoan_ #-1 @.attribute-address ~memory.write.write-byte ^cpu.step :.remove-object | ( -- ) @.obj ~.object !.obj-address @.obj-address liad_ #4 ~memory.byte !.parent @.parent { @.parent ~.object liad_ #6 !.link-address :.remove-search | ( -- ) @.link-address ~memory.byte !.link-object @.link-object lieq_ #0 { >&.object-message ^diagnostics.error } @.link-object @.obj eqlieq_ #0 { @.link-object ~.object liad_ #5 !.link-address ^.remove-search } @.obj-address liad_ #5 ~memory.byte @.link-address ~memory.write.write-byte } >#0 @.obj-address liad_ #4 ~memory.write.write-byte >#0 @.obj-address liad_ #5 ~memory.write.write-byte ; :.insert-object | ( -- ) @cpu.a !.obj ~.remove-object @cpu.b ~.object !.parent-address @.parent-address liad_ #6 ~memory.byte @.obj-address liad_ #5 ~memory.write.write-byte @cpu.b @.obj-address liad_ #4 ~memory.write.write-byte @cpu.a @.parent-address liad_ #6 ~memory.write.write-byte ^cpu.step :.property-start | ( -- ) @cpu.a ~.object liad_ #7 ~memory.word du_ ~memory.byte limuad_ #2 liad_ #1 !.property-address ; :.find-property | ( -- ) ~.property-start :.property-search | ( -- ) @.property-address ~memory.byte !.property-header @.property-header lian_ #31 !.property-number @.property-number @cpu.b gt_ { @.property-header >#5 srliad_ #2 @.property-address ad_ !.property-address ^.property-search } ; :.property-op | ( -- ) @cpu.opcode lieq_ #19 @cpu.b lieqan_ #0 { ~.property-start @.property-address ~memory.byte lian_ #31 ~variables.store ^cpu.step } ~.find-property @cpu.opcode lieq_ #19 { @.property-number @cpu.b ne_ ?diagnostics.memory-error @.property-header >#5 srliad_ #2 @.property-address ad_ ~memory.byte lian_ #31 ~variables.store ^cpu.step } @.property-number @cpu.b ne_ { @cpu.opcode lieq_ #18 { >#0 ~variables.store ^cpu.step } @cpu.b lisulimu #1 #2 >#10 ~memory.word ad_ ~memory.word ~variables.store ^cpu.step } @cpu.opcode lieq_ #18 { @.property-address liad_ #1 ~variables.store ^cpu.step } @.property-address liad_ #1 @.property-header >#5 srlieq_ #0 { ~memory.byte ~variables.store ^cpu.step } ~memory.word ~variables.store ^cpu.step :.put-property | ( -- ) @cpu.argc line_ #3 ?diagnostics.unsupported ~.find-property @.property-number @cpu.b ne_ ?diagnostics.memory-error >&cpu.operands liadfe_ #2 @.property-address liad_ #1 @.property-header >#5 srlieq_ #0 { ~memory.write.write-byte ^cpu.step } ~memory.write.write-word ^cpu.step \.obj #0 \.obj-address #0 \.parent #0 \.link-address #0 \.link-object #0 \.parent-address #0 \.attribute-address #0 \.attribute-mask #0 \.attribute-value #0 \.property-address #0 \.property-header #0 \.property-number #0 \.object-message 'Invalid_object_tree. ] :unicode [ | Terminal I/O is UTF-8; story memory and dictionaries retain ZSCII. :.read-character | ( -- zscii-or-eof ) ~.read-byte !.code @.code lilt_ #128 { @.code ; } @.code lilt_ #194 @.code ligtor_ #223 { >#0 ; } @.code lian_ #31 >#6 sl_ !.code ~.read-byte !.continuation @.continuation lilt_ #128 @.continuation ligtor_ #191 { @.continuation !.pending >#0 ; } @.code @.continuation lian_ #63 or_ !.code | Latin-1 upper case and the OE ligature have simple lower-case forms. @.code ligt_ #191 @.code liltan_ #223 @.code linean_ #215 { @.code liad_ #32 !.code } @.code lieq_ #338 { >#339 !.code } >#0 !.index :.find-character | ( -- zscii ) @.index liadfe_ &.table @.code eq_ { @.index liad_ #155 ; } @.index liad_ #1 !.index @.index lilt_ #69 ?.find-character >#0 ; :.read-byte | ( -- byte-or-eof ) @.pending line_ #-2 { @.pending >#-2 !.pending ; } liio_ #1 du_ @random.noise limu_ #16777619 xo_ !random.noise ; \.code #0 \.continuation #0 \.index #0 \.pending #-2 \.table #228 #246 #252 #196 #214 #220 #223 #187 #171 #235 #239 #255 #203 #207 #225 #233 #237 #243 #250 #253 #193 #201 #205 #211 #218 #221 #224 #232 #236 #242 #249 #192 #200 #204 #210 #217 #226 #234 #238 #244 #251 #194 #202 #206 #212 #219 #229 #197 #248 #216 #227 #241 #245 #195 #209 #213 #230 #198 #231 #199 #254 #240 #222 #208 #163 #339 #338 #161 #191 ] :input [ :.read-line | ( -- ) @cpu.argc line_ #2 ?diagnostics.unsupported @cpu.a !.text-buffer @cpu.b !.parse-buffer @.text-buffer ~memory.byte lisu_ #1 !.input-limit @.input-limit lilt_ #0 ?diagnostics.memory-error >#0 !.input-length :.input-character | ( -- ) ~unicode.read-character !.ch @.ch lieq_ #-1 ?diagnostics.halt @.skip-lf { >#0 !.skip-lf @.ch lieq_ #10 ?.input-character } @.ch lieq_ #13 @.ch lieqor_ #10 ?.input-complete @.ch lieq_ #8 @.ch lieqor_ #127 { @.input-length { @.input-length lisu_ #1 !.input-length } ^.input-character } @.ch lilt_ #32 ?.input-character @.input-length @.input-limit ltlieq_ #0 ?.input-character @.ch ligt_ #64 @.ch liltan_ #91 { @.ch liad_ #32 !.ch } @.ch @.text-buffer @.input-length adliad_ #1 ~memory.write.write-byte @.input-length liad_ #1 !.input-length ^.input-character :.input-complete | ( -- ) @.ch lieq_ #13 { >#1 !.skip-lf } >#0 @.text-buffer @.input-length adliad_ #1 ~memory.write.write-byte >#13 ~output.emit >#8 ~memory.word !.dictionary @.dictionary ~memory.byte !.separator-count @.dictionary @.separator-count adliad_ #1 ~memory.byte !.entry-length @.entry-length lilt_ #4 ?diagnostics.memory-error @.dictionary @.separator-count adliad_ #2 ~memory.word ~format.signed !.entry-count >#0 !.dictionary-unsorted @.entry-count lilt_ #0 { >#1 !.dictionary-unsorted >#0 @.entry-count su_ !.entry-count } @.dictionary @.separator-count adliad_ #4 !.entries @.parse-buffer ~memory.byte !.token-limit >#0 !.token-count >#1 !.input-position :.token-next | ( -- ) @.input-position @.input-length gt_ ?.tokens-done @.token-count @.token-limit ltlieq_ #0 ?.tokens-done @.text-buffer @.input-position ad_ ~memory.byte !.input-char @.input-char lieq_ #32 { @.input-position liad_ #1 !.input-position ^.token-next } @.input-position !.token-position >#1 !.token-length ~.is-separator @.separator ?.token-found :.token-extend | ( -- ) @.token-position @.token-length ad_ !.input-position @.input-position @.input-length gt_ ?.token-found @.text-buffer @.input-position ad_ ~memory.byte !.input-char @.input-char lieq_ #32 ?.token-found ~.is-separator @.separator ?.token-found @.token-length liad_ #1 !.token-length ^.token-extend :.token-found | ( -- ) ~.encode-token >#0 !.dictionary-result >#0 !.entry-index @.dictionary-unsorted ?.dictionary-search >#0 !.dictionary-low @.entry-count lisu_ #1 !.dictionary-high :.dictionary-binary | ( -- ) @.dictionary-low @.dictionary-high gt_ ?.dictionary-done @.dictionary-low @.dictionary-high ad_ >#1 sr_ !.entry-index @.entry-index @.entry-length mu_ @.entries ad_ !.entry-address @.entry-address ~memory.word !.dictionary-first @.dictionary-first @.encoded-first lt_ ?.dictionary-right @.dictionary-first @.encoded-first gt_ ?.dictionary-left @.entry-address liad_ #2 ~memory.word !.dictionary-second @.dictionary-second @.encoded-second lt_ ?.dictionary-right @.dictionary-second @.encoded-second gt_ ?.dictionary-left @.entry-address !.dictionary-result ^.dictionary-done :.dictionary-right | ( -- ) @.entry-index liad_ #1 !.dictionary-low ^.dictionary-binary :.dictionary-left | ( -- ) @.entry-index lisu_ #1 !.dictionary-high ^.dictionary-binary :.dictionary-search | ( -- ) @.entry-index @.entry-count ltlieq_ #0 ?.dictionary-done @.entry-index @.entry-length mu_ @.entries ad_ !.entry-address @.entry-address ~memory.word @.encoded-first eq_ { @.entry-address liad_ #2 ~memory.word @.encoded-second eq_ { @.entry-address !.dictionary-result ^.dictionary-done } } @.entry-index liad_ #1 !.entry-index ^.dictionary-search :.dictionary-done | ( -- ) @.token-count limu_ #4 @.parse-buffer adliad_ #2 !.parse-address @.dictionary-result @.parse-address ~memory.write.write-word @.token-length @.parse-address liad_ #2 ~memory.write.write-byte @.token-position @.parse-address liad_ #3 ~memory.write.write-byte @.token-count liad_ #1 !.token-count @.token-position @.token-length ad_ !.input-position ^.token-next :.tokens-done | ( -- ) @.token-count @.parse-buffer liad_ #1 ~memory.write.write-byte ^cpu.step :.is-separator | ( -- ) >#0 !.separator >#0 !.separator-index :.separator-loop | ( -- ) @.separator-index @.separator-count lt_ { @.dictionary @.separator-index adliad_ #1 ~memory.byte @.input-char eq_ { >#1 !.separator ; } @.separator-index liad_ #1 !.separator-index ^.separator-loop } ; :.encode-token | ( -- ) >#0 !.encoded-count >#0 !.encode-index >#0 !.encoded-first >#0 !.encoded-second >#0 !cpu.index :.encode-clear | ( -- ) >#5 @cpu.index liadst_ &.encoded @cpu.index liad_ #1 !cpu.index @cpu.index lilt_ #6 ?.encode-clear :.encode-character | ( -- ) @.encoded-count ligt_ #5 @.encode-index @.token-length ltlieqor #0 ?.encode-pack @.text-buffer @.token-position ad_ @.encode-index ad_ ~memory.byte !.encode-char @.encode-index liad_ #1 !.encode-index @.encode-char ligt_ #96 @.encode-char liltan_ #123 { @.encode-char lisu_ #91 ~.encode-zchar ^.encode-character } >#5 ~.encode-zchar >#1 !.punct-index :.encode-punctuation | ( -- ) @.punct-index lilt_ #26 { @.punct-index liadfe_ &text.punctuation @.encode-char eq_ { @.punct-index liad_ #6 ~.encode-zchar ^.encode-character } @.punct-index liad_ #1 !.punct-index ^.encode-punctuation } >#6 ~.encode-zchar @.encode-char >#5 sr_ ~.encode-zchar @.encode-char lian_ #31 ~.encode-zchar ^.encode-character :.encode-zchar | ( zchar -- ) @.encoded-count lilt_ #6 { @.encoded-count liadst_ &.encoded @.encoded-count liad_ #1 !.encoded-count ; } dr_ ; :.encode-pack | ( -- ) @.encoded >#10 sl_ >&.encoded liadfe_ #1 >#5 slor_ >&.encoded liadfeor #2 !.encoded-first >&.encoded liadfe_ #3 >#10 sl_ >&.encoded liadfe_ #4 >#5 slor_ >&.encoded liadfeor #5 lior_ #32768 !.encoded-second ; \.ch #0 \.skip-lf #0 \.text-buffer #0 \.parse-buffer #0 \.input-limit #0 \.input-length #0 \.dictionary #0 \.separator-count #0 \.entry-length #0 \.entry-count #0 \.entries #0 \.token-limit #0 \.token-count #0 \.input-position #0 \.input-char #0 \.token-position #0 \.token-length #0 \.dictionary-result #0 \.entry-index #0 \.entry-address #0 \.parse-address #0 \.separator #0 \.separator-index #0 \.encoded-count #0 \.encode-index #0 \.encoded-first #0 \.encoded-second #0 \.encode-char #0 \.punct-index #0 \.encoded *6 \.dictionary-unsorted #0 \.dictionary-low #0 \.dictionary-high #0 \.dictionary-first #0 \.dictionary-second #0 ] | Save format v1. Header + state + stack + frames + packed dynamic memory. | Only an empty header or an existing save for this exact story is writable. :save [ :.read-save-header | ( -- ) >&.zero-page >&.save-header >#1024 cy_ @.data-base >&.save-header liio_ #2 ; :.compatible-save | ( -- ) >#0 !.save-compatible @.save-header lieq_ #1515012401 >&.save-header liadfe_ #1 lieqan_ #1 >&.save-header liadfe_ #2 @memory.size eqan_ >&.save-header liadfe_ #3 @memory.static eqan_ >&.save-header liad_ #16 >&loader.identity >#16 cpan_ { >#1 !.save-compatible } ; :.save-layout | ( -- ) @memory.static liad_ #3 >#2 sr_ !.dynamic-cells @.dynamic-cells liad_ #1023 >#10 srliad_ #8 !.payload-blocks ; :.save-game | ( -- ) ~.read-save-header ~.compatible-save @.save-compatible lieq_ #0 { >&.save-header >&.zero-page >#1024 cplieq_ #0 ?.save-failed } ~.save-layout >&.zero-page >&.save-state >#1024 cy_ @cpu.pc !.save-state @stack.sp >&.save-state liadst_ #1 @calls.depth >&.save-state liadst_ #2 @random.seed >&.save-state liadst_ #3 @output.screen-output >&.save-state liadst_ #4 @output.stream-depth >&.save-state liadst_ #5 >&output.streams >&.save-state liad_ #16 >#16 cy_ >&.zero-page >&.save-header >#1024 cy_ >#1515012401 !.save-header >#1 >&.save-header liadst_ #1 @memory.size >&.save-header liadst_ #2 @memory.static >&.save-header liadst_ #3 @.payload-blocks >&.save-header liadst_ #4 >&loader.identity >&.save-header liad_ #16 >#16 cy_ | Invalidate the previous commit before modifying its payload. @.data-base >&.save-header liio_ #3 >#0 !.save-index >#-2128831035 !.save-hash :.save-page-loop | ( -- ) ~.payload-location >&.zero-page >&.save-page >#1024 cy_ @.payload-address >&.save-page @.payload-cells cy_ ~.hash-save-page @.save-index @.data-base adliad_ #1 >&.save-page liio_ #3 @.save-index liad_ #1 !.save-index @.save-index @.payload-blocks lt_ ?.save-page-loop @.save-hash !.expected-hash | Read back every payload page: block I/O has no success return value. ~.check-save-payload @.save-hash @.expected-hash ne_ ?.save-failed @.expected-hash >&.save-header liadst_ #5 >#1 >&.save-header liadst_ #6 @.data-base >&.save-header liio_ #3 >&.save-header >&.save-page >#1024 cy_ ~.read-save-header >&.save-header >&.save-page >#1024 cplieq_ #0 ?.save-failed >#1 ^control.branch :.restore-game | ( -- ) ~.read-save-header ~.compatible-save @.save-compatible lieq_ #0 ?.save-failed >&.save-header liadfe_ #6 line_ #1 ?.save-failed ~.save-layout >&.save-header liadfe_ #4 @.payload-blocks ne_ ?.save-failed >&.save-header liadfe_ #5 !.expected-hash ~.check-save-payload @.save-hash @.expected-hash ne_ ?.save-failed | State is staged privately; no guest memory is touched before validation. @.save-state lilt_ #64 @.save-state @memory.size ltlieqor #0 ?.save-failed >&.save-state liadfedu #1 liltsw_ #0 ligtor_ #4096 ?.save-failed >&.save-state liadfedu #2 liltsw_ #0 ligtor_ #127 ?.save-failed >&.save-state liadfedu #5 liltsw_ #0 ligtor_ #16 ?.save-failed >#17 ~memory.byte lian_ #3 !loader.preserve-flags >#1 !.save-index :.restore-page-loop | ( -- ) @.save-index @.data-base adliad_ #1 >&.save-page liio_ #2 ~.payload-location >&.save-page @.payload-address @.payload-cells cy_ @.save-index liad_ #1 !.save-index @.save-index @.payload-blocks lt_ ?.restore-page-loop @.save-state !cpu.pc >&.save-state liadfe_ #1 !stack.sp >&.save-state liadfe_ #2 !calls.depth >&.save-state liadfe_ #3 !random.seed >&.save-state liadfe_ #4 !output.screen-output >&.save-state liadfe_ #5 !output.stream-depth >&.save-state liad_ #16 >&output.streams >#16 cy_ @calls.depth limuliad #20 &calls.frames !calls.frame @calls.frame liadfe_ #2 !stack.eval-base >#17 ~memory.byte lian_ #252 @loader.preserve-flags or_ >#17 ~memory.write.write-byte ~memory.write.capabilities >#1 ^control.branch :.save-failed | ( -- ) >#0 ^control.branch :.check-save-payload | ( -- ) >#0 !.save-index >#-2128831035 !.save-hash :.check-save-loop | ( -- ) >&.zero-page >&.save-page >#1024 cy_ @.save-index @.data-base adliad_ #1 >&.save-page liio_ #2 @.save-index lieq_ #0 { >&.save-page >&.save-state >#1024 cy_ } ~.hash-save-page @.save-index liad_ #1 !.save-index @.save-index @.payload-blocks lt_ ?.check-save-loop ; :.hash-save-page | ( -- ) >#0 !.hash-index :.hash-save-loop | ( -- ) @.hash-index liadfe_ &.save-page @.save-hash xolimu_ #16777619 !.save-hash @.hash-index liad_ #1 !.hash-index @.hash-index lilt_ #1024 ?.hash-save-loop ; :.payload-location | ( -- ) >#1024 !.payload-cells @.save-index lieq_ #0 { >&.save-state !.payload-address ; } @.save-index lilt_ #5 { @.save-index lisulimu #1 #1024 liad_ &stack.cells !.payload-address ; } @.save-index lilt_ #8 { @.save-index lisulimu #5 #1024 !.payload-offset @.payload-offset liad_ &calls.frames !.payload-address @.save-index lieq_ #7 { >#512 !.payload-cells } ; } @.save-index lisulimu #8 #1024 !.payload-offset @.payload-offset liad_ &memory.story !.payload-address @.dynamic-cells @.payload-offset su_ !.payload-cells @.payload-cells ligt_ #1024 { >#1024 !.payload-cells } ; \.save-compatible #0 \.dynamic-cells #0 \.payload-blocks #0 \.save-index #0 \.save-hash #0 \.payload-address #0 \.payload-cells #0 \.expected-hash #0 \.hash-index #0 \.payload-offset #0 \.data-base #0 \.save-header *1024 \.save-page *1024 \.save-state *1024 \.zero-page *1024 ] :console [ :.print | ( string -- ) dufe_ !.count liad_ #1 !.text :.print-loop | ( -- ) @.count lieq_ #0 { ; } @.text feliio_ #0 @.text liad_ #1 !.text @.count lisu_ #1 !.count ^.print-loop \.count #0 \.text #0 ] :diagnostics [ :.bad-story | ( -- ) >&.invalid ^.error :.version-error | ( -- ) >&.version ^.error :.memory-error | ( -- ) >&.memory ^.error :.stack-error | ( -- ) >&.stack-message ^.error :.locals-error | ( -- ) >&.locals-message ^.error :.division-error | ( -- ) >&.division-message ^.error :.unsupported | ( -- ) >&.unsupported-message ~console.print @cpu.class ~format.number >$: liio_ #0 @cpu.opcode ~format.number >&.at-message ~console.print @cpu.instruction-pc ~format.number >#10 liio_ #0 ^.halt :.error | ( message -- ) ~console.print >#10 liio_ #0 :.halt | ( ... -- ) Clears the native data and return stacks before exiting. liio_ #7 !.native-rdepth !.native-depth :.halt-data | ( ... -- ) Clears the native data and return stacks before exiting. @.native-depth { dr_ @.native-depth lisu_ #1 !.native-depth ^.halt-data } :.halt-returns | ( -- ) Clears the native data and return stacks before exiting. @.native-rdepth { podr_ @.native-rdepth lisu_ #1 !.native-rdepth ^.halt-returns } liio_ #6 \.invalid 'Invalid_or_truncated_V3_story. \.version 'Only_V3_stories_are_supported. \.memory 'Story_memory_out_of_bounds. \.stack-message 'Guest_stack_overflow_or_underflow. \.locals-message 'Invalid_routine_local_variable. \.division-message 'Division_by_zero. \.unsupported-message 'Unsupported_Z-machine_opcode_(class:number):_ \.at-message '_at_PC_ \.native-rdepth #0 \.native-depth #0 \.no-input-stream 'Command_file_input_is_unavailable. ] :memory [ :.next | ( -- byte ) @cpu.pc ~.byte @cpu.pc liad_ #1 !cpu.pc ; :.byte | ( address -- byte ) !.byte-address @.byte-address lilt_ #0 @.byte-address @.size ltlieqor #0 ?diagnostics.memory-error @.byte-address >#2 srliadfe &.story @.byte-address lianlimu #3 #8 srlian_ #255 ; :.word | ( address -- word ) du_ ~.byte >#8 slswliad #1 ~.byte or_ ; :.write-byte-raw | ( -- ) @.byte-address >#2 srliad_ &.story !.cell @.byte-address lianlimu #3 #8 !.shift @.cell fe_ >#255 @.shift sllixoan #-1 @.value @.shift slor_ @.cell st_ ; \.size #0 \.value #0 \.byte-address #0 \.static #0 \.globals #0 \.cell #0 \.shift #0 \.word-address #0 \.word-value #0 \.guest-address #0 \.guest-value #0 \.old-byte #0 `32768 \.story *32768 ]