Permalink
Browse files

tweak so it will build for carrot16.

  • Loading branch information...
1 parent 94a756b commit dcf45cc587d2012db9f83a5dc3eb766affa7af04 @robey committed Feb 10, 2013
Showing with 27 additions and 26 deletions.
  1. +1 −0 Cakefile
  2. +23 −23 src/d16bunny/assembler.coffee
  3. +1 −1 src/d16bunny/line.coffee
  4. +2 −2 src/d16bunny/output.coffee
View
@@ -36,6 +36,7 @@ synctask = (name, description, f) ->
assemblerFiles = [
"assembler",
+ "builtins",
"dcpu",
"errors",
"expression",
@@ -59,29 +59,29 @@ class DataLine
address += @data.length
address
-# pack a sequence of DataLine objects (one per line) into a smaller array.
-# in theory, each new DataLine object should have all the data between two
-# ORG changes. the new DataLine array is sorted in address order. ParsedLine
-# information is removed.
-DataLine.pack = (dlines) ->
- i = 0
- end = dlines.length
- blocks = []
- while i < end
- runStart = i
- addressStart = address = dlines[i].address
- while i < end and dlines[i].address == address
- address += dlines[i].data.length
- i++
- data = new Array(address - addressStart)
- n = 0
- for j in [runStart...i]
- k = dlines[j].data.length
- data[n ... n + k] = dlines[j].data
- n += k
- if data.length > 0 then blocks.push(new DataLine(null, addressStart, data))
- blocks.sort((a, b) -> a.address > b.address)
- blocks
+ # pack a sequence of DataLine objects (one per line) into a smaller array.
+ # in theory, each new DataLine object should have all the data between two
+ # ORG changes. the new DataLine array is sorted in address order. ParsedLine
+ # information is removed.
+ pack: (dlines) ->
+ i = 0
+ end = dlines.length
+ blocks = []
+ while i < end
+ runStart = i
+ addressStart = address = dlines[i].address
+ while i < end and dlines[i].address == address
+ address += dlines[i].data.length
+ i++
+ data = new Array(address - addressStart)
+ n = 0
+ for j in [runStart...i]
+ k = dlines[j].data.length
+ data[n ... n + k] = dlines[j].data
+ n += k
+ if data.length > 0 then blocks.push(new DataLine(null, addressStart, data))
+ blocks.sort((a, b) -> a.address > b.address)
+ blocks
# compile lines of DCPU assembly.
View
@@ -19,7 +19,6 @@ Span.Label = "label"
# for parsing a line of text, and syntax highlighting
class Line
-
constructor: (@text) ->
@pos = 0 # current index within text
@end = @text.length # parsing should not continue past end
@@ -120,6 +119,7 @@ class Line
start = @pos
@pos += 2
rv = switch @text[@pos - 1]
+ when 'e' then "\x1b"
when 'n' then "\n"
when 'r' then "\r"
when 't' then "\t"
@@ -1,4 +1,4 @@
-assembler = require("./assembler")
+DataLine = require("./assembler").DataLine
class AssemblerOutput
# errors: array of errors discovered (and previously reported through
@@ -22,7 +22,7 @@ class AssemblerOutput
pack: ->
if @cachedPack? then return @cachedPack
if @errors.length > 0 or @lines.length == 0 then return []
- @cachedPack = assembler.DataLine.pack(@lines)
+ @cachedPack = @lines[0].pack(@lines)
@cachedPack
# return the line # of an address in the compiled code. if it's not an

0 comments on commit dcf45cc

Please sign in to comment.