comparison clojure/com/aurellem/assembly.clj @ 121:744de3427c05

finished Mode 2 of bootstrapping program
author Robert McIntyre <rlm@mit.edu>
date Fri, 16 Mar 2012 20:48:12 -0500
parents d6f2a06cb128
children e85b53994fac
comparison
equal deleted inserted replaced
120:d6f2a06cb128 121:744de3427c05
601 ;; beginning of main state machine 601 ;; beginning of main state machine
602 0x18 ;D380 ; Declaration of variables 602 0x18 ;D380 ; Declaration of variables
603 0x05 ;D381 ; 5 variables: 603 0x05 ;D381 ; 5 variables:
604 0x00 ;D382 ; current-mode 604 0x00 ;D382 ; current-mode
605 0x00 ;D383 ; bytes-left-to-write 605 0x00 ;D383 ; bytes-left-to-write
606 0x00 ;D384 ; unused 606 0x00 ;D384 ; start-point
607 0x00 ;D385 ; unused 607 0x00 ;D385 ; unused
608 0x00 ;D386 ; unused 608 0x00 ;D386 ; unused
609 609
610 610
611 ;; banch on current mode 611 ;; banch on current mode
621 621
622 0xCA ;D38D ; goto Mode 0 if A == 0 622 0xCA ;D38D ; goto Mode 0 if A == 0
623 0xA8 ;D38E 623 0xA8 ;D38E
624 0xD3 ;D38F 624 0xD3 ;D38F
625 625
626 626 ;; GOTO Mode 1 (set-length) if current-mode is 1
627 ;; GOTO Mode 1 (set-bytes) if current-mode is 1
628 0xFE ;D390 627 0xFE ;D390
629 0x01 ;D391 ; compare A with 0x01 628 0x01 ;D391 ; compare A with 0x01
630 629
631 0xCA ;D392 630 0xCA ;D392
632 0xB1 ;D393 631 0xB1 ;D393
633 0xD3 ;D394 ; goto Mode 1 if A == 1 632 0xD3 ;D394 ; goto Mode 1 if A == 1
634 633
635 0x00 ;D395 634 ;; GOTO Mode 2 (set-start-point) if current mode is 2
636 0x00 ;D396 635 0xFE ;D395
637 0x00 ;D397 636 0x02 ;D396 ; compare A with 0x02
638 0x00 ;D398 637
639 0x00 ;D399 638 0xCA ;D397
639 0xBF ;D398
640 0xD3 ;D399 ; goto Mode 2 if A == 2
641
640 0x00 ;D39A 642 0x00 ;D39A
641 0x00 ;D39B 643 0x00 ;D39B
642 0x00 ;D39C 644 0x00 ;D39C
643 0x00 ;D39D 645 0x00 ;D39D
644 0x00 ;D39E 646 0x00 ;D39E
672 0x1D ;D3AF 674 0x1D ;D3AF
673 0xD3 ;D3B0 675 0xD3 ;D3B0
674 ;; End Mode 0 676 ;; End Mode 0
675 677
676 678
677 ;; Mode 1 -- input bytes mode 679 ;; Mode 1 -- set-length mode
678 ;; This is the header for writing things to memory 680 ;; This is the header for writing things to memory.
679 ;; specifies the number of bytes to write. 681 ;; User specifies the number of bytes to write.
680 ;; Mode is auto advanced to Mode 2 after this mode 682 ;; Mode is auto advanced to Mode 2 after this mode
681 ;; completes. 683 ;; completes.
682 684
683 ;; set bytes left to write to input-number, 685 ;; Set bytes left to write to input-number;
684 ;; set current-mode to 0x02. 686 ;; set current-mode to 0x02.
685 0xFA ;D3B1 ; load input-number (0xD352) 687 0xFA ;D3B1 ; load input-number (0xD352)
686 0x52 ;D3B2 ; into A 688 0x52 ;D3B2 ; into A
687 0xD3 ;D3B3 689 0xD3 ;D3B3
688 690
689 0xEA ;D3B4 ; load A into bytes-left-to-write 691 0xEA ;D3B4 ; load A into bytes-left-to-write
690 0x83 ;D3B5 ; (0xD383) 692 0x83 ;D3B5 ; (0xD383)
691 0xD3 ;D3B6 693 0xD3 ;D3B6
692 694
693 0x3E ;D3B7 ; load 0x02 to A 695 0x3E ;D3B7 ; load 0x02 into A.
694 0x02 ;D3B8 696 0x02 ;D3B8
695 697
696 0xEA ;D3B9 ; load A to current-mode 698 0xEA ;D3B9 ; load A to current-mode
697 0x82 ;D3BA ; advancing from Mode 1 to 699 0x82 ;D3BA ; advancing from Mode 1 to
698 0xD3 ;D3BB ; Mode 2 700 0xD3 ;D3BB ; Mode 2
699 701
700 0xC3 ;D3BC ; go back to beginning 702 0xC3 ;D3BC ; go back to beginning
701 0x1D ;D3BD 703 0x1D ;D3BD
702 0xD3 ;D3BE 704 0xD3 ;D3BE
703 ;; End Mode 1 705 ;; End Mode 1
704 706
705 0x00 ;D3BF 707
706 0x00 ;D3C0 708 ;; Mode 2 -- set start-point mode
707 0x00 ;D3C1 709 ;; Final part of the header for writing things to memory.
708 0x00 ;D3C2 710 ;; User specifies the start location in RAM to which
709 0x00 ;D3C3 711 ;; data will be written.
710 0x00 ;D3C4 712 ;; Mode is auto advanced to Mode 3 after this mode completes.
711 0x00 ;D3C5 713
712 0x00 ;D3C6 714 ;; Set start-point to input-number;
713 0x00 ;D3C7 715 ;; set current mode to 0x03.
714 0x00 ;D3C8 716 0xFA ;D3BF ; load input-number (0xD352)
715 0x00 ;D3C9 717 0x52 ;D3C0 ; into A
716 0x00 ;D3CA 718 0xD3 ;D3C1
717 0x00 ;D3CB 719
718 0x00 ;D3CC 720 0xEA ;D3C2 ; load A into start-point
721 0x84 ;D3C3 ; (0xD384)
722 0xD3 ;D3C4
723
724 0x3E ;D3C5 ; load 0x03 into A.
725 0x03 ;D3C6
726
727 0xEA ;D3C7 ; load A to current-mode,
728 0x82 ;D3C8 ; advancing from Mode 2 to
729 0xD3 ;D3C9 ; Mode 3.
730
731 0xC3 ;D3CA ; go back to beginning
732 0x1D ;D3CB
733 0xD3 ;D3CC
734 ;;End Mode 2
735
719 0x00 ;D3CD 736 0x00 ;D3CD
720 0x00 ;D3CE 737 0x00 ;D3CE
721 0x00 ;D3CF 738 0x00 ;D3CF
722 0x00 ;D3D0 739 0x00 ;D3D0
723 0x00 ;D3D1 740 0x00 ;D3D1
725 0x00 ;D3D3 742 0x00 ;D3D3
726 0x00 ;D3D4 743 0x00 ;D3D4
727 0x00 ;D3D5 744 0x00 ;D3D5
728 0x00 ;D3D6 745 0x00 ;D3D6
729 746
747 ;; Mode 3 -- write bytes mode
748 ;; This is where RAM manipulation happens.
749 ;; User supplies bytes every frame, which are written
750 ;; sequentially to
751
730 752
731 753
732 754
733 0xC3 ; ; Complete Loop 755 0xC3 ; ; Complete Loop
734 0x1D ; 756 0x1D ;