diff modules/x86.tp @ 348:a840e9a068a2

Get sample builtin to il module working again
author Michael Pavone <pavone@retrodev.com>
date Fri, 10 Apr 2015 00:48:42 -0700
parents f987bb2a1911
children a3b06d53bcb9
line wrap: on
line diff
--- a/modules/x86.tp	Fri Apr 10 00:48:12 2015 -0700
+++ b/modules/x86.tp	Fri Apr 10 00:48:42 2015 -0700
@@ -226,6 +226,7 @@
 					idx + 1
 				}
 			}
+			string <- { (ilist map: :el { hex: el}) join: " "}
 		}
 	}
 	multiInst <- :instarr {
@@ -240,6 +241,11 @@
 					inst flattenTo: dest at: idx
 				}
 			}
+			string <- {
+				(instarr map: :inst {
+					(inst map: :el { hex: el}) join: " "
+				}) join: "\n" 
+			}
 		}
 	}
 
@@ -449,6 +455,7 @@
 					}
 					idx
 				}
+				string <- { "label: " . _offset }
 				withOffset:else <- :fun :elsefun {
 					if: hasOffset? {
 						fun: _offset
@@ -503,6 +510,9 @@
 						}
 						idx + _size
 					}
+					string <- {
+						"jmp " . jmpDest
+					}
 				}
 			} else: {
 				inst: 0xFFu8 | (mod_rm: (opex: 5u8) jmpDest)
@@ -540,6 +550,9 @@
 					}
 					idx + _size
 				}
+				string <- {
+					"jcc " . jmpDest
+				}
 			}
 		}
 
@@ -559,6 +572,9 @@
 						}
 						idx + 5
 					}
+					string <- {
+						"call " . callDest
+					}
 				}
 			} else: {
 				inst: 0xFFu8 | (mod_rm: (opex: 2u8) callDest)
@@ -732,8 +748,10 @@
 				{ outarr append: (and: (inst in) (inst out) (mapSize: (inst size))) }
 				{ outarr append: (or: (inst in) (inst out) (mapSize: (inst size))) }
 				{ outarr append: (xor: (inst in) (inst out) (mapSize: (inst size))) }
-				//mul
-				//div
+				{ } //muls
+				{ } //mulu
+				{ } //divs
+				{ } //divu
 				{ outarr append: (sub: (inst in) (inst out) (mapSize: (inst size))) }
 				{ outarr append: (cmp: (inst in) (inst out) (mapSize: (inst size))) }
 				{ outarr append: (bnot: (inst arg) (mapSize: (inst size))) }
@@ -789,6 +807,7 @@
 					outarr append: endlab
 				}
 				//skipIf:else
+				{ }
 				{
 					//save
 					newsave <- []
@@ -799,14 +818,16 @@
 					foreach: (inst scope) :_ inst {
 						convertIL: inst to: outarr withLabels: labels withSaved: newsave
 					}
-					if: ((inst scope) length) = 0 || (((inst scope) get: ((inst scope) length) - 1) opcode) != 14 {
+					if: ((inst scope) length) = 0 || (((inst scope) get: ((inst scope) length) - 1) opcode) != 18 {
 						foreach: newsave :_ reg {
 							outarr append: (pop: reg)
 						}
 					}
 				}
 				//bool
+				{ }
 			]
+			print: "Opcode: " . (inst opcode) . "\n"
 			fun <- opmap get: (inst opcode)
 			fun:
 			outarr