comparison clojure/com/aurellem/run/bootstrap_0.clj @ 341:bf9b9777c3ce

brought item-writer down to 20 items.
author Robert McIntyre <rlm@mit.edu>
date Sun, 08 Apr 2012 05:48:13 -0500
parents dea7e476eba7
children 4e0b64ea7b66
comparison
equal deleted inserted replaced
340:dea7e476eba7 341:bf9b9777c3ce
917 [ 917 [
918 ;;0xC5 ;; push junk onto stack 918 ;;0xC5 ;; push junk onto stack
919 ;;0xD5 919 ;;0xD5
920 ;;0xE5 920 ;;0xE5
921 ;;0xF5 921 ;;0xF5
922 0x37 ;; (item-hack) set cary flag no-op 922 0x33 ;; (item-hack) set increment stack pointer no-op
923 0x1E ;; load limit into E 923 0x1E ;; load limit into E
924 limit 924 limit
925 0x3F ;; (item-hack) set carry flag no-op 925 0x3F ;; (item-hack) set carry flag no-op
926 926
927 ;; load 1 into C. 927 ;; load 2 into C.
928 0x0E ;; C == 0 means input-first nybble 928 0x0E ;; C == 1 means input-first nybble
929 0x01 ;; C == 0xFF means input-second nybble 929 0x04 ;; C == 0 means input-second nybble
930 930
931 0x0D ;; (item-hack) (dec C)
932 0x2B ;; (item-hack) (dec HL) no-op
933
934 0x21 ;; load target into HL 931 0x21 ;; load target into HL
935 target-low 932 target-low
936 target-high 933 target-high
937 0x37 ;; (item-hack) set carry flag no-op 934 0x37 ;; (item-hack) set carry flag no-op
938 935
958 0x37 ;; (item-hack) set carry flag no-op 955 0x37 ;; (item-hack) set carry flag no-op
959 956
960 0x00 ;; (item-hack) no-op 957 0x00 ;; (item-hack) no-op
961 0xB8 ;; see if input is different (CP A B) 958 0xB8 ;; see if input is different (CP A B)
962 959
963 0x33 ;; (item-hack) (INC SP) 960 0x00 ;; (item-hack) (INC SP)
964 0x28 ;; repeat above steps if input is not different 961 0x28 ;; repeat above steps if input is not different
965 ;; (jump relative backwards if B != A) 962 ;; (jump relative backwards if B != A)
966 0xED ;; (literal -19) (item-hack) -19 == egg bomb (TM37) 963 0xED ;; (literal -19) (item-hack) -19 == egg bomb (TM37)
967 964
968 0x47 ;; load A into B 965 0x47 ;; load A into B
969 966
970 0x0D ;; dec C 967 0x0D ;; dec C
971 0x37 ;; (item-hack) set-carry flag 968 0x37 ;; (item-hack) set-carry flag
972 ;; branch based on C: 969 ;; branch based on C:
973 0x20 ;; JR NZ 970 0x20 ;; JR NZ
974 0x08 ;; skip "input first nybble" below 971 23 ;; skip "input second nybble" and "jump to target" below
975 972
976 ;; input second nybble 973 ;; input second nybble
977 974
978 0x0C ;; inc C 975 0x0C ;; inc C
979 0x37 ;; (item-hack) set-carry flag no-op 976 0x37 ;; (item-hack) set-carry flag no-op
991 0x1D ;; (DEC E) 988 0x1D ;; (DEC E)
992 989
993 0x00 ;; (item-hack) 990 0x00 ;; (item-hack)
994 0x20 ;; jump back to input section if not done 991 0x20 ;; jump back to input section if not done
995 0xDA ;; literal -36 == TM 18 (counter) 992 0xDA ;; literal -36 == TM 18 (counter)
996 0x01 ;; (item-hack) will never reach this instruction 993 0x01 ;; (item-hack) set BC to literal (no-op)
997 994
995 ;; jump to target
996 0x00 ;; (item-hack) these two bytes can be anything.
997 0x01
998
999 0x00 ;; (item-hack) no-op
1000 0xBF ;; (CP A A) ensures Z
1001
1002 0xCA ;; (item-hack) jump if Z
1003 return-low
1004 return-high
1005 0x01 ;; (item-hack) will never be reached.
1006
1007
1008
998 ;; input first nybble 1009 ;; input first nybble
999 0x00 1010 0x00
1000 0xCB 1011 0xCB
1001 0x37 ;; swap nybbles on A 1012 0x37 ;; swap nybbles on A
1002 1013
1003 0x57 ;; A -> D 1014 0x57 ;; A -> D
1004 1015
1005 0x37 1016 0x37 ;; (item-hack) set carry flag no-op
1006 0x18 1017 0x18 ;; relative jump backwards
1007 0xD5 ;; literal -20 == TM13; go back to input section 1018 0xCD ;; literal -51 == TM05; go back to input section
1008 0x01 1019 0x01 ;; (item-hack) will never reach this instruction
1009 1020
1010 0x3A ;; (item-hack) these two bytes can be anything. 1021 ])))
1011 0x01 1022
1012 ;; cleanup 1023
1013 ;;0xF1 1024
1014 ;;0xE1 1025 (defn test-item-writer []
1015 ;;0xD1 1026 (-> (read-state "bootstrap-init")
1016 ;;0xC1 1027 (set-memory pc-item-list-start 50)
1017 0x00 ;; (item-hack) no-op 1028 (set-memory-range
1018 0xBF ;; (CP A A) ensures Z 1029 map-function-address-start
1019 ;;0xFB ;; re-enable interrupts;; unnecessary 1030 (reverse (disect-bytes-2 (inc pc-item-list-start))))
1020 0xCA ;; (item-hack) jump if Z 1031 (set-memory-range
1021 return-low 1032 (inc pc-item-list-start)
1022 return-high 1033 (item-writer 0xD162 201 0xD162))))
1023
1024 0x01 ;; (item-hack) will never be reached.
1025 ])))