secret
Created

  • Download Gist
gistfile1.md
Markdown

Organic JSON Support

Organic can now produce a machine-friendly JSON output from your assembly. You can grab the latest version here.

Here's an example:

; Color test
; Cause I got the default palette wrong in Tomato
; Things you might get out of this file:
; The palette values ;)
; screen_init maps all connected screens to 0x8000

    JSR screen_init    
    ; Draw out palette
    SET A, 0x8000
    SET C, 0x0F00 ; color mask
    SET X, text
loop:
    SET B, [X]
    ADD X, 1
    BOR B, C
    SET [A], B
    ADD A, 1
    SUB C, 0x0100
    ife A, 0x8008
    BOR C, 0xF000
    ifn A, 0x8010
    SET PC, loop

    SET A, 0x8020
    SET C, 0xF000 ; color mask
    SET X, text
loop_foreground:
    SET B, [X]
    ADD X, 1
    BOR B, C
    SET [A], B
    ADD A, 1
    SUB C, 0x1000
    ife A, 0x8028
    BOR C, 0x0F00
    ifn A, 0x8030
    SET PC, loop_foreground

    SUB PC, 1

text:
    dat "0123456789ABCDEF"

; Sets up the screen(s)
screen_init:
    HWN A
    SUB A, 1
screen_init_loop:
    IFE A, 0xFFFF
        SET PC, POP
    SET PUSH, A
        HWQ A
        IFE A, 0xf615
            IFE B, 0x7349
                SET PC, init_screen
    SET A, POP
    SUB A, 1
    SET PC, screen_init_loop
init_screen:
    SET A, POP
    SET J, A
    SET C, A
    SET A, 0
    SET B, 0x8000
    HWI C
    SET A, C
    SUB A, 1
    SET PC, screen_init_loop

This produces the following JSON:

[
    {
        "type":"NonBasicInstruction",
        "code":"JSR screen_init",
        "file":"palette.dasm",
        "line":"7",
        "address":"0x0000",
        "a":"screen_init",
        "output":"7C20 003B"
    },
    {
        "type":"BasicInstruction",
        "code":"SET A, 0x8000",
        "file":"palette.dasm",
        "line":"9",
        "address":"0x0002",
        "a":"0x8000",
        "b":"A",
        "output":"7C01 8000"
    },
    {
        "type":"BasicInstruction",
        "code":"SET C, 0x0F00",
        "file":"palette.dasm",
        "line":"10",
        "address":"0x0004",
        "a":"0x0F00",
        "b":"C",
        "output":"7C41 0F00"
    },
    {
        "type":"BasicInstruction",
        "code":"SET X, text",
        "file":"palette.dasm",
        "line":"11",
        "address":"0x0006",
        "a":"text",
        "b":"X",
        "output":"7C61 002B"
    },
    {
        "type":"Label",
        "code":"loop:",
        "file":"palette.dasm",
        "line":"12",
        "address":"0x0008"
    },
    {
        "type":"BasicInstruction",
        "code":"SET B, [X]",
        "file":"palette.dasm",
        "line":"13",
        "address":"0x0008",
        "a":"[X]",
        "b":"B",
        "output":"2C21"
    },
    {
        "type":"BasicInstruction",
        "code":"ADD X, 1",
        "file":"palette.dasm",
        "line":"14",
        "address":"0x0009",
        "a":"1",
        "b":"X",
        "output":"8862"
    },
    {
        "type":"BasicInstruction",
        "code":"BOR B, C",
        "file":"palette.dasm",
        "line":"15",
        "address":"0x000A",
        "a":"C",
        "b":"B",
        "output":"082B"
    },
    {
        "type":"BasicInstruction",
        "code":"SET [A], B",
        "file":"palette.dasm",
        "line":"16",
        "address":"0x000B",
        "a":"B",
        "b":"[A]",
        "output":"0501"
    },
    {
        "type":"BasicInstruction",
        "code":"ADD A, 1",
        "file":"palette.dasm",
        "line":"17",
        "address":"0x000C",
        "a":"1",
        "b":"A",
        "output":"8802"
    },
    {
        "type":"BasicInstruction",
        "code":"SUB C, 0x0100",
        "file":"palette.dasm",
        "line":"18",
        "address":"0x000D",
        "a":"0x0100",
        "b":"C",
        "output":"7C43 0100"
    },
    {
        "type":"BasicInstruction",
        "code":"ife A, 0x8008",
        "file":"palette.dasm",
        "line":"19",
        "address":"0x000F",
        "a":"0x8008",
        "b":"A",
        "output":"7C12 8008"
    },
    {
        "type":"BasicInstruction",
        "code":"BOR C, 0xF000",
        "file":"palette.dasm",
        "line":"20",
        "address":"0x0011",
        "a":"0xF000",
        "b":"C",
        "output":"7C4B F000"
    },
    {
        "type":"BasicInstruction",
        "code":"ifn A, 0x8010",
        "file":"palette.dasm",
        "line":"21",
        "address":"0x0013",
        "a":"0x8010",
        "b":"A",
        "output":"7C13 8010"
    },
    {
        "type":"BasicInstruction",
        "code":"SET PC, loop",
        "file":"palette.dasm",
        "line":"22",
        "address":"0x0015",
        "a":"loop",
        "b":"PC",
        "output":"A781"
    },
    {
        "type":"BasicInstruction",
        "code":"SET A, 0x8020",
        "file":"palette.dasm",
        "line":"24",
        "address":"0x0016",
        "a":"0x8020",
        "b":"A",
        "output":"7C01 8020"
    },
    {
        "type":"BasicInstruction",
        "code":"SET C, 0xF000",
        "file":"palette.dasm",
        "line":"25",
        "address":"0x0018",
        "a":"0xF000",
        "b":"C",
        "output":"7C41 F000"
    },
    {
        "type":"BasicInstruction",
        "code":"SET X, text",
        "file":"palette.dasm",
        "line":"26",
        "address":"0x001A",
        "a":"text",
        "b":"X",
        "output":"7C61 002B"
    },
    {
        "type":"Label",
        "code":"loop_foreground:",
        "file":"palette.dasm",
        "line":"27",
        "address":"0x001C"
    },
    {
        "type":"BasicInstruction",
        "code":"SET B, [X]",
        "file":"palette.dasm",
        "line":"28",
        "address":"0x001C",
        "a":"[X]",
        "b":"B",
        "output":"2C21"
    },
    {
        "type":"BasicInstruction",
        "code":"ADD X, 1",
        "file":"palette.dasm",
        "line":"29",
        "address":"0x001D",
        "a":"1",
        "b":"X",
        "output":"8862"
    },
    {
        "type":"BasicInstruction",
        "code":"BOR B, C",
        "file":"palette.dasm",
        "line":"30",
        "address":"0x001E",
        "a":"C",
        "b":"B",
        "output":"082B"
    },
    {
        "type":"BasicInstruction",
        "code":"SET [A], B",
        "file":"palette.dasm",
        "line":"31",
        "address":"0x001F",
        "a":"B",
        "b":"[A]",
        "output":"0501"
    },
    {
        "type":"BasicInstruction",
        "code":"ADD A, 1",
        "file":"palette.dasm",
        "line":"32",
        "address":"0x0020",
        "a":"1",
        "b":"A",
        "output":"8802"
    },
    {
        "type":"BasicInstruction",
        "code":"SUB C, 0x1000",
        "file":"palette.dasm",
        "line":"33",
        "address":"0x0021",
        "a":"0x1000",
        "b":"C",
        "output":"7C43 1000"
    },
    {
        "type":"BasicInstruction",
        "code":"ife A, 0x8028",
        "file":"palette.dasm",
        "line":"34",
        "address":"0x0023",
        "a":"0x8028",
        "b":"A",
        "output":"7C12 8028"
    },
    {
        "type":"BasicInstruction",
        "code":"BOR C, 0x0F00",
        "file":"palette.dasm",
        "line":"35",
        "address":"0x0025",
        "a":"0x0F00",
        "b":"C",
        "output":"7C4B 0F00"
    },
    {
        "type":"BasicInstruction",
        "code":"ifn A, 0x8030",
        "file":"palette.dasm",
        "line":"36",
        "address":"0x0027",
        "a":"0x8030",
        "b":"A",
        "output":"7C13 8030"
    },
    {
        "type":"BasicInstruction",
        "code":"SET PC, loop_foreground",
        "file":"palette.dasm",
        "line":"37",
        "address":"0x0029",
        "a":"loop_foreground",
        "b":"PC",
        "output":"F781"
    },
    {
        "type":"BasicInstruction",
        "code":"SUB PC, 1",
        "file":"palette.dasm",
        "line":"39",
        "address":"0x002A",
        "a":"1",
        "b":"PC",
        "output":"8B83"
    },
    {
        "type":"Label",
        "code":"text:",
        "file":"palette.dasm",
        "line":"41",
        "address":"0x002B"
    },
    {
        "type":"Directive",
        "code":".dat \"0123456789ABCDEF\"",
        "file":"palette.dasm",
        "line":"42",
        "address":"0x0032",
        "output":"0030 0031 0032 0033 0034 0035 0036 0037 0038 0039 0041 0042 0043 0044 0045 0046"
    },
    {
        "type":"Label",
        "code":"screen_init:",
        "file":"palette.dasm",
        "line":"45",
        "address":"0x003B"
    },
    {
        "type":"NonBasicInstruction",
        "code":"HWN A",
        "file":"palette.dasm",
        "line":"46",
        "address":"0x003B",
        "a":"A",
        "output":"0200"
    },
    {
        "type":"BasicInstruction",
        "code":"SUB A, 1",
        "file":"palette.dasm",
        "line":"47",
        "address":"0x003C",
        "a":"1",
        "b":"A",
        "output":"8803"
    },
    {
        "type":"Label",
        "code":"screen_init_loop:",
        "file":"palette.dasm",
        "line":"48",
        "address":"0x003D"
    },
    {
        "type":"BasicInstruction",
        "code":"IFE A, 0xFFFF",
        "file":"palette.dasm",
        "line":"49",
        "address":"0x003D",
        "a":"0xFFFF",
        "b":"A",
        "output":"8012"
    },
    {
        "type":"BasicInstruction",
        "code":"SET PC, POP",
        "file":"palette.dasm",
        "line":"50",
        "address":"0x003E",
        "a":"POP",
        "b":"PC",
        "output":"6381"
    },
    {
        "type":"BasicInstruction",
        "code":"SET PUSH, A",
        "file":"palette.dasm",
        "line":"51",
        "address":"0x003F",
        "a":"A",
        "b":"PUSH",
        "output":"0301"
    },
    {
        "type":"NonBasicInstruction",
        "code":"HWQ A",
        "file":"palette.dasm",
        "line":"52",
        "address":"0x0040",
        "a":"A",
        "output":"0220"
    },
    {
        "type":"BasicInstruction",
        "code":"IFE A, 0xf615",
        "file":"palette.dasm",
        "line":"53",
        "address":"0x0041",
        "a":"0xf615",
        "b":"A",
        "output":"7C12 F615"
    },
    {
        "type":"BasicInstruction",
        "code":"IFE B, 0x7349",
        "file":"palette.dasm",
        "line":"54",
        "address":"0x0043",
        "a":"0x7349",
        "b":"B",
        "output":"7C32 7349"
    },
    {
        "type":"BasicInstruction",
        "code":"SET PC, init_screen",
        "file":"palette.dasm",
        "line":"55",
        "address":"0x0045",
        "a":"init_screen",
        "b":"PC",
        "output":"7F81 004B"
    },
    {
        "type":"BasicInstruction",
        "code":"SET A, POP",
        "file":"palette.dasm",
        "line":"56",
        "address":"0x0047",
        "a":"POP",
        "b":"A",
        "output":"6001"
    },
    {
        "type":"BasicInstruction",
        "code":"SUB A, 1",
        "file":"palette.dasm",
        "line":"57",
        "address":"0x0048",
        "a":"1",
        "b":"A",
        "output":"8803"
    },
    {
        "type":"BasicInstruction",
        "code":"SET PC, screen_init_loop",
        "file":"palette.dasm",
        "line":"58",
        "address":"0x0049",
        "a":"screen_init_loop",
        "b":"PC",
        "output":"7F81 003D"
    },
    {
        "type":"Label",
        "code":"init_screen:",
        "file":"palette.dasm",
        "line":"59",
        "address":"0x004B"
    },
    {
        "type":"BasicInstruction",
        "code":"SET A, POP",
        "file":"palette.dasm",
        "line":"60",
        "address":"0x004B",
        "a":"POP",
        "b":"A",
        "output":"6001"
    },
    {
        "type":"BasicInstruction",
        "code":"SET J, A",
        "file":"palette.dasm",
        "line":"61",
        "address":"0x004C",
        "a":"A",
        "b":"J",
        "output":"00E1"
    },
    {
        "type":"BasicInstruction",
        "code":"SET C, A",
        "file":"palette.dasm",
        "line":"62",
        "address":"0x004D",
        "a":"A",
        "b":"C",
        "output":"0041"
    },
    {
        "type":"BasicInstruction",
        "code":"SET A, 0",
        "file":"palette.dasm",
        "line":"63",
        "address":"0x004E",
        "a":"0",
        "b":"A",
        "output":"8401"
    },
    {
        "type":"BasicInstruction",
        "code":"SET B, 0x8000",
        "file":"palette.dasm",
        "line":"64",
        "address":"0x004F",
        "a":"0x8000",
        "b":"B",
        "output":"7C21 8000"
    },
    {
        "type":"NonBasicInstruction",
        "code":"HWI C",
        "file":"palette.dasm",
        "line":"65",
        "address":"0x0051",
        "a":"C",
        "output":"0A40"
    },
    {
        "type":"BasicInstruction",
        "code":"SET A, C",
        "file":"palette.dasm",
        "line":"66",
        "address":"0x0052",
        "a":"C",
        "b":"A",
        "output":"0801"
    },
    {
        "type":"BasicInstruction",
        "code":"SUB A, 1",
        "file":"palette.dasm",
        "line":"67",
        "address":"0x0053",
        "a":"1",
        "b":"A",
        "output":"8803"
    },
    {
        "type":"BasicInstruction",
        "code":"SET PC, screen_init_loop",
        "file":"palette.dasm",
        "line":"68",
        "address":"0x0054",
        "a":"screen_init_loop",
        "b":"PC",
        "output":"7F81 003D"
    }
]

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.