comparison modules/x86.tp @ 350:a3b06d53bcb9

Make il and x86 modules cope with dict hash instead of dict linear for the program definition
author Michael Pavone <pavone@retrodev.com>
date Fri, 10 Apr 2015 01:19:46 -0700
parents a840e9a068a2
children 0b4d4f06bf91
comparison
equal deleted inserted replaced
349:60292f131de9 350:a3b06d53bcb9
762 { outarr append: (ror: (inst in) (inst out) (mapSize: (inst size))) } 762 { outarr append: (ror: (inst in) (inst out) (mapSize: (inst size))) }
763 { outarr append: (mov: (inst in) (inst out) (mapSize: (inst size))) } 763 { outarr append: (mov: (inst in) (inst out) (mapSize: (inst size))) }
764 { 764 {
765 //call 765 //call
766 arguments <- inst args 766 arguments <- inst args
767 cur <- (arguments length) - 1 767 arguments foldr: (arguments length) - 1 with: :cur src {
768 while: { cur >= 0 } do: {
769 src <- (arguments get: cur)
770 if: cur < (_argregs length) { 768 if: cur < (_argregs length) {
771 dst <- _argregs get: cur 769 dst <- _argregs get: cur
772 if: (not: dst = src) { 770 if: (not: dst = src) {
773 //TODO: Handle edge case in which src is a caller saved 771 //TODO: Handle edge case in which src is a caller saved
774 //reg that has been pusehd onto the stack to preserve 772 //reg that has been pusehd onto the stack to preserve
776 outarr append: (mov: src dst q) 774 outarr append: (mov: src dst q)
777 } 775 }
778 } else: { 776 } else: {
779 outarr append: (push: src) 777 outarr append: (push: src)
780 } 778 }
781 cur <- cur - 1 779 cur - 1
782 } 780 }
781
783 toCall <- inst target 782 toCall <- inst target
784 if: (toCall isString?) { 783 if: (toCall isString?) {
785 //TODO: Handle call to undefined label 784 //TODO: Handle call to undefined label
786 toCall <- labels get: toCall 785 toCall <- labels get: toCall else: {
786 print: "Could not find label " . toCall . "\nDefined labels:\n"
787 foreach: labels :key _ {
788 print: "\t" . key . "\n"
789 }
790 false
791 }
787 } 792 }
788 outarr append: (call: toCall) 793 outarr append: (call: toCall)
789 } 794 }
790 { 795 {
791 //return 796 //return