Advertisement
sci4me

Untitled

Mar 9th, 2019
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                         .setcpu "65C02"
  2.  
  3.                         ACIA_DATA       = $7F00
  4.                         ACIA_STATUS     = $7F01
  5.                         ACIA_COMMAND    = $7F02
  6.                         ACIA_CONTROL    = $7F03
  7.  
  8.                         BF_JUMP_TABLE   = $1000
  9.                         BF_CODE         = $1100
  10.                         BF_MEMORY       = $4100
  11.  
  12.                         BF_DONE         = 0
  13.                         BF_PLUS         = 1
  14.                         BF_MINUS        = 2
  15.                         BF_RIGHT        = 3
  16.                         BF_LEFT         = 4
  17.                         BF_WRITE        = 5
  18.                         BF_READ         = 6
  19.                         BF_OPEN         = 7
  20.                         BF_CLOSE        = 8
  21.  
  22.                         .segment "VECTORS"
  23.  
  24.                         .word nmi
  25.                         .word reset
  26.                         .word irq
  27.  
  28.                         .zeropage
  29.  
  30. temp_1:                 .res 2
  31. temp_2:                 .res 2
  32. temp_3:                 .res 2
  33. temp_4:                 .res 2
  34. temp_5:                 .res 2
  35. bf_ip:                  .res 2
  36. bf_next_ip:             .res 2
  37. bf_dp:                  .res 2
  38.  
  39.                         .code
  40.  
  41. .macro acia_puts addr
  42. .local @loop
  43. .local @done
  44.                         pha
  45.                         phx
  46.                         ldx #0
  47. @loop:                  lda addr,x
  48.                         beq @done
  49.                         jsr acia_putc
  50.                         inx
  51.                         bra @loop
  52. @done:                  plx
  53.                         pla
  54. .endmacro
  55.  
  56. .macro inc16 addr
  57. .local @done
  58.                         inc addr
  59.                         bne @done
  60.                         inc addr+1
  61. @done:
  62. .endmacro
  63.  
  64. .macro dec16 addr
  65. .local @done
  66.                         lda addr
  67.                         bne @done
  68.                         dec addr+1
  69. @done:                  dec addr
  70. .endmacro
  71.  
  72. .macro add16 _a, _b, _r
  73.                         clc
  74.                         lda _b
  75.                         adc #<_a
  76.                         sta _r
  77.                         lda _b+1
  78.                         adc #>_a
  79.                         sta _r+1
  80. .endmacro
  81.  
  82. .macro push16 addr
  83.                         lda addr
  84.                         pha
  85.                         lda addr+1
  86.                         pha
  87. .endmacro
  88.  
  89. .macro pop16 addr
  90.                         pla
  91.                         sta addr+1
  92.                         pla
  93.                         sta addr
  94. .endmacro
  95.  
  96. .macro store16 base, off, val
  97.                         add16 base, off, temp_4
  98.                         lda val
  99.                         sta (temp_4)
  100.                         inc16 temp_4
  101.                         lda val+1
  102.                         sta (temp_4)
  103. .endmacro
  104.  
  105. .macro sta16 base, off
  106.                         pha
  107.                         add16 base, off, temp_4
  108.                         pla
  109.                         sta (temp_4)
  110. .endmacro
  111.  
  112. .macro stz16 addr
  113.                         stz addr
  114.                         stz addr+1
  115. .endmacro
  116.  
  117. .macro mov16 src, dst
  118.                         lda src
  119.                         sta dst
  120.                         lda src+1
  121.                         sta dst+1
  122. .endmacro
  123.  
  124. .macro asl16 addr
  125.                         asl addr
  126.                         rol addr+1
  127. .endmacro
  128.  
  129. .macro ldptr16 addr, dst
  130.                         lda (addr)
  131.                         sta dst
  132.                         ldy #1
  133.                         lda (addr),y
  134.                         sta dst+1
  135. .endmacro
  136.  
  137. reset:                  jmp main
  138. nmi:                    rti
  139. irq:                    rti
  140.  
  141. main:                   sei
  142.                         cld
  143.                         ldx #$FF
  144.                         txs
  145.  
  146.                         lda #%00001011
  147.                         sta ACIA_COMMAND
  148.                         lda #%00011111
  149.                         sta ACIA_CONTROL
  150.  
  151.                         acia_puts s_clearing_memory
  152.                         jsr clear_memory
  153.  
  154.                         acia_puts s_computing_jump_table
  155.                         jsr compute_jump_table
  156.  
  157.                         acia_puts s_compiling
  158.                         jsr compile
  159.  
  160.                         acia_puts s_executing_code
  161.                         jsr execute
  162.  
  163.                         acia_puts s_done
  164.  
  165. :                       stp
  166.                         bra :-
  167.  
  168. ; TODO: initialize temp_1 to brainfuck_code instead of adding every time
  169.  
  170. compute_jump_table:     stz16 temp_1
  171. @loop:                  add16 brainfuck_code, temp_1, temp_2
  172.                         lda (temp_2)
  173.                         bne :+
  174.                                 rts
  175. :                       cmp #'['
  176.                         bne :+
  177.                                 push16 temp_1
  178.                         bra :++
  179. :                       cmp #']'
  180.                         bne :+
  181.                                 pop16 temp_2
  182.  
  183.                                 mov16 temp_2, temp_5
  184.                                 asl16 temp_5
  185.                                 store16 BF_JUMP_TABLE, temp_5, temp_1
  186.  
  187.                                 mov16 temp_1, temp_5
  188.                                 asl16 temp_5
  189.                                 store16 BF_JUMP_TABLE, temp_5, temp_2
  190. :                       inc16 temp_1
  191.                         jmp @loop
  192.  
  193. ; TODO: initialize temp_1 to brainfuck_code instead of adding every time
  194.  
  195. compile:                stz16 temp_1
  196. @op_start:              add16 brainfuck_code, temp_1, temp_2
  197.                         lda (temp_2)
  198.                         bne :+
  199.                                 rts
  200. :                       cmp #'+'
  201.                         bne :+
  202.                                 lda #BF_PLUS
  203.                                 sta16 BF_CODE, temp_1
  204.                         jmp @op_end
  205. :                       cmp #'-'
  206.                         bne :+
  207.                                 lda #BF_MINUS
  208.                                 sta16 BF_CODE, temp_1
  209.                         jmp @op_end
  210. :                       cmp #'>'
  211.                         bne :+
  212.                                 lda #BF_RIGHT
  213.                                 sta16 BF_CODE, temp_1
  214.                         bra @op_end
  215. :                       cmp #'<'
  216.                         bne :+
  217.                                 lda #BF_LEFT
  218.                                 sta16 BF_CODE, temp_1
  219.                         bra @op_end
  220. :                       cmp #'.'
  221.                         bne :+
  222.                                 lda #BF_WRITE
  223.                                 sta16 BF_CODE, temp_1
  224.                         bra @op_end
  225. :                       cmp #','
  226.                         bne :+
  227.                                 lda #BF_READ
  228.                                 sta16 BF_CODE, temp_1
  229.                         bra @op_end
  230. :                       cmp #'['
  231.                         bne :+
  232.                                 lda #BF_OPEN
  233.                                 sta16 BF_CODE, temp_1
  234.                         bra @op_end
  235. :                       cmp #']'
  236.                         bne @op_end
  237.                                 lda #BF_CLOSE
  238.                                 sta16 BF_CODE, temp_1
  239. @op_end:                inc16 temp_1
  240.                         jmp @op_start
  241.  
  242. ; TODO: instead of adding BF_MEMORY to bf_dp all the time, why not just add it at the beginning?
  243. ; TODO: same for BF_CODE and bf_ip?
  244.  
  245. execute:                stz16 bf_ip
  246.                         stz16 bf_dp
  247. @dispatch:              mov16 bf_ip, bf_next_ip
  248.                         inc16 bf_next_ip
  249.                         add16 BF_CODE, bf_ip, temp_1
  250.                         lda (temp_1)
  251.                         asl a
  252.                         tax
  253.                         jmp (@dispatch_table,x)        
  254. @dispatch_table:        .addr @bf_done
  255.                         .addr @bf_plus
  256.                         .addr @bf_minus
  257.                         .addr @bf_right
  258.                         .addr @bf_left
  259.                         .addr @bf_write
  260.                         .addr @bf_read
  261.                         .addr @bf_open
  262.                         .addr @bf_close
  263. @bf_done:                       rts
  264. @bf_plus:                       add16 BF_MEMORY, bf_dp, temp_1
  265.                                 lda (temp_1)
  266.                                 inc a
  267.                                 sta (temp_1)
  268.                         jmp @op_end
  269. @bf_minus:                      add16 BF_MEMORY, bf_dp, temp_1
  270.                                 lda (temp_1)
  271.                                 dec a
  272.                                 sta (temp_1)
  273.                         jmp @op_end
  274. @bf_right:                      inc16 bf_dp
  275.                         jmp @op_end
  276. @bf_left:                       dec16 bf_dp
  277.                         jmp @op_end
  278. @bf_write:                      add16 BF_MEMORY, bf_dp, temp_1
  279.                                 lda (temp_1)
  280.                                 jsr acia_putc
  281.                         jmp @op_end
  282. @bf_read:                       jsr acia_getc
  283.                                 add16 BF_MEMORY, bf_dp, temp_1
  284.                                 sta (temp_1)
  285.                         bra @op_end
  286. @bf_open:                       add16 BF_MEMORY, bf_dp, temp_1
  287.                                 lda (temp_1)
  288.                                 bne @op_end
  289.  
  290.                                 mov16 bf_ip, temp_5
  291.                                 asl16 temp_5
  292.                                 add16 BF_JUMP_TABLE, temp_5, temp_1
  293.  
  294.                                 ldptr16 temp_1, bf_next_ip
  295.                                 inc16 bf_next_ip
  296.                         bra @op_end
  297. @bf_close:                      add16 BF_MEMORY, bf_dp, temp_1
  298.                                 lda (temp_1)
  299.                                 beq @op_end
  300.  
  301.                                 mov16 bf_ip, temp_5
  302.                                 asl16 temp_5
  303.                                 add16 BF_JUMP_TABLE, temp_5, temp_1
  304.  
  305.                                 ldptr16 temp_1, bf_next_ip
  306.                                 inc16 bf_next_ip
  307. @op_end:                mov16 bf_next_ip, bf_ip
  308.                         jmp @dispatch
  309.  
  310. clear_memory:           lda #$10
  311. :                       jsr clear_page
  312.                         inc a
  313.                         cmp #$7E
  314.                         bne :-
  315.                         rts
  316.  
  317. clear_page:             pha
  318.                         sta temp_1+1
  319.                         stz temp_1
  320.                         lda #0
  321.                         ldy #0
  322. :                       sta (temp_1),y
  323.                         iny
  324.                         bne :-
  325.                         pla
  326.                         rts
  327.  
  328. acia_putc:              phx
  329.                         ldx #$68
  330. :                       dex
  331.                         bne :-
  332.                         plx
  333.                         sta ACIA_DATA
  334.                         rts
  335.  
  336. acia_getc:              
  337. :                       lda ACIA_STATUS
  338.                         and #$08
  339.                         beq :-
  340.                         lda ACIA_DATA
  341.                         rts
  342.  
  343.                         .rodata
  344.  
  345. ; fibonacci
  346. ;brainfuck_code:         .byte ">++++++++++>+>+[[+++++[>++++++++<-]>.<++++++[>--------<-]+<<<]>.>>[[-]<[>+<-]>>[<<+>+>-]<[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>[-]>+>+<<<-[>+<-]]]]]]]]]]]+>>>]<<<]", 0
  347.  
  348. ; squares
  349. brainfuck_code:         .byte "++++[>+++++<-]>[<+++++>-]+<+[>[>+>+<<-]++>>[<<+>>-]>>>[-]++>[-]+>>>+[[-]++++++>>>]<<<[[<++++++++<++>>-]+<.<[>----<-]<]<<[>>>>>[>>>[-]+++++++++<[>-<-]+++++++++>[-[<->-]+[<<<]]<[>+<-]>]<<-]<<-]", 0
  350.  
  351. ; sierpinski
  352. ;brainfuck_code:         .byte "++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[-<<<[->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<<]>.>+[>>]>+]", 0
  353.  
  354. ; hello world
  355. ;brainfuck_code:         .byte "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.", 0
  356.  
  357. ; mandelbrot
  358. ;brainfuck_code:         .byte "+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+[>>>>>>[>>>>>>>[-]>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>[-]+<<<<<<++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<+++++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[[-]>>>>>>[>>>>>>>[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<+<<<+<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<+<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<<<]>>>>>>>>>+++++++++++++++[[>>>>>>>>>]+>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>-]+[>+>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>->>>>[-<<<<+>>>>]<<<<[->>>>+<<<<<[->>[-<<+>>]<<[->>+>>+<<<<]+>>>>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.byte ">>>>++>+>++>+>>++<+[[>[>>[>>>>]<<<<[[>>>>+<<<<-]<<<<]>>>>>>]+<]>->>--[+[+++<<<<--]++>>>>--]+[>>>>]<<<<[<<+<+<]<<[>>>>>>[[<<<<+>>>>-]>>>>]<<<<<<<<[<<<<]>>-[<<+>>-]+<<[->>>>[-[+>>>>-]-<<-[>>>>-]++>>+[-<<<<+]+>>>>]<<<<[<<<<]]>[-[<+>-]]+<[->>>>[-[+>>>>-]-<<<-[>>>>-]++>>>+[-<<<<+]+>>>>]<<<<[<<<<]]<<]>>>+[>>>>]-[+<<<<--]++[<<<<]>>>+[>-[>>[--[++>>+>>--]-<[-[-[+++<<<<-]+>>>>-]]++>+[-<<<<+]++>>+>>]<<[>[<-<<<]+<]>->>>]+>[>>>>]-[+<<<<--]++<[[>>>>]<<<<[-[->--[<->+]++<[[>-<+]++[<<<<]+>>+>>-]++<<<<-]>-[+[<+[<<<<]>]<+>]+<[->->>>[-]]+<<<<]]>[<<<<]>[-[-[+++++[>++++++++<-]>-.>>>-[<<<----.<]<[<<]>>[-]>->>+[[>>>>]+[-[->>>>+>>>>>>>>-[-[+++<<<<[-]]+>>>>-]++[<<<<]]+<<<<]>>>]+<+<<]>[-[->[--[++>>>>--]->[-[-[+++<<<<-]+>>>>-]]++<+[-<<<<+]++>>>>]<<<<[>[<<<<]+<]>->>]<]>>>>[--[++>>>>--]-<--[+++>>>>--]+>+[-<<<<+]++>>>>]<<<<<[<<<<]<]>[>+<<++<]<]>[+>[--[++>>>>--]->--[+++>>>>--]+<+[-<<<<+]++>>>>]<<<[<<<<]]>>]>]", 0
  362.  
  363. ; factorial    
  364. ;brainfuck_code:         .byte ">++++++++++>>>+>+[>>>+[-[<<<<<[+<<<<<]>>[[-]>[<<+>+>-]<[>+<-]<[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>[-]>>>>+>+<<<<<<-[>+<-]]]]]]]]]]]>[<+>-]+>>>>>]<<<<<[<<<<<]>>>>>>>[>>>>>]++[-<<<<<]>>>>>>-]+>>>>>]<[>++<-]<<<<[<[>+<-]<<<<]>>[->[-]++++++[<++++++++>-]>>>>]<<<<<[<[>+>+<<-]>.<<<<<]>.>>>>]", 0
  365.  
  366. ; ackermann
  367. ;brainfuck_code:         .byte ">>>->+[[[<<+>+>-]++++++[<<++++++++>>-]<<-.[-]<]++++++++++.[-]>>>++<[[-[[>>>]<<<-[+>>>]<<<[<<<]+>]<-[+>++++++++++>>]>]>>>[[>+<-]>>>]<<[-[<++>-[<++>-[<++>-[<++>-[<[-]>-[<++>-]>>[<+<]>[->]<++<<]]]]]<+<<] >]>[>>>]<<<]", 0
  368.  
  369. s_clearing_memory:      .byte "Clearing memory...", 10, 0
  370. s_computing_jump_table: .byte "Computing jump table...", 10, 0
  371. s_compiling:            .byte "Compiling...", 10, 0
  372. s_executing_code:       .byte "Executing code...", 10, 10, 0
  373. s_done:                 .byte 10, "Done!", 10, 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement