From bf1fe33c369d815676c4b7b3a334a6d971988f64 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 16 Feb 2019 22:36:21 -0800 Subject: 4975 - new plan for Phase 2 So far I've been assuming that I'd just statelessly convert each line in a .subx file. But over the past week or so of constant interruptions I gradually realized that code and data need different parsers. --- subx/apps/pack.subx | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'subx') diff --git a/subx/apps/pack.subx b/subx/apps/pack.subx index cf0a27d7..755f3d79 100644 --- a/subx/apps/pack.subx +++ b/subx/apps/pack.subx @@ -75,9 +75,9 @@ $main:end: # We'll operate on each line/instruction in isolation. That way we only need to # allocate memory for converting a single instruction. # -# To pack an entire file: -# read every line -# convert it +# To pack an entire file, convert every segment in it +# To convert a code segment, convert every instruction (line) until the next segment header +# To convert a non-data segment, convert every word until the next segment header # # primary state: line # stream of 512 bytes; abort if it ever overflows @@ -89,7 +89,15 @@ convert: # in : (address buffered-file), out : (address buffered-file) -> + # pseudocode: + # var line = new-stream(512, 1) + # repeatedly + # clear-stream(line) + # EAX = read-line(in, line) + # if (EAX == EOF) break + # word-slice = next-word(line) + # if (slice-equal?(word-slice, "==")) + # return + # convert-instruction(line, out) + +convert-data-segment: # in : (address buffered-file), out : (address buffered-file) -> + # pseudocode: + # var line = new-stream(512, 1) + # repeatedly + # clear-stream(line) + # EAX = read-line(in, line) + # if (EAX == EOF) break + # word-slice = next-word(line) + # if (slice-equal?(word-slice, "==")) + # return + # convert-data-word(line, out) + # - To pack an instruction, following the C++ version: # read first word as opcode and write-slice # if 0f or f2 or f3 read second opcode and write-slice -- cgit 1.4.1-2-gfad0