[Gridflow-cvs] [svn] commit: r6612 - /trunk/src/mmx.rb

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Thu Feb 17 15:07:45 EST 2011


Author: matju
Date: Thu Feb 17 15:07:44 2011
New Revision: 6612

Log:
attempt to add code for shr and sar (not using it) and add $prefix option for OSX (not detected and not default)

Modified:
    trunk/src/mmx.rb

Modified: trunk/src/mmx.rb
==============================================================================
--- trunk/src/mmx.rb (original)
+++ trunk/src/mmx.rb Thu Feb 17 15:07:44 2011
@@ -26,6 +26,9 @@
 puts "; generated by/for GridFlow 9.14"
 $loader.puts "#include \"gridflow.hxx.fcs\"\nextern \"C\" {"
 
+$prefix = "" # on Linux
+# $prefix = "_" # on OSX
+
 # this class is not really used yet (only self.make)
 class AsmFunction
 	def initialize(name)
@@ -33,7 +36,7 @@
 		@label_count = 1
 	end
 	def self.make(name)
-		puts "", "GLOBAL #{name}", "#{name}:"
+		puts "", "GLOBAL #{$prefix}#{name}", "#{$prefix}#{name}:"
 		puts "push ebp", "mov ebp,esp", "push esi", "push edi"
 		yield AsmFunction.new(name)
 		puts "pop edi", "pop esi", "leave", "ret", ""
@@ -133,12 +136,25 @@
 		foo.call 4
 		foo.call 1
 		a.make_until("test ecx,ecx", "jz") {
-			#if opcode=="shl" or opcode=="sar" then
-			#	puts "mov cl,al"
-			#	puts "#{opcode} #{$asm_type[type]} [esi],cl"
-			#else
-			puts "#{opcode} #{$asm_type[type]} [esi],#{accum}"
-			#end
+			a = accum
+			b = accum.gsub(/a/,'b')
+			d = accum.gsub(/a/,'d')
+			if op==:max then
+				puts "mov #{b},[esi]"
+				puts "sub #{b},#{a}"
+				puts "sbb #{d},#{d}"
+				puts "and #{b},#{d}"
+				puts "mov [esi],#{b}"
+			elsif op==:min then
+				puts "mov #{b},[esi]"
+				puts "sub #{b},#{a}"
+				puts "sbb #{d},#{d}"
+				puts "and #{b},#{d}"
+				puts "mov [esi],#{b}"
+			else
+				puts ";#{op.inspect}"
+				puts "#{opcode} #{$asm_type[type]} [esi],#{accum}"
+			end
 			puts "lea esi,[esi+#{size}]"
 			puts "dec ecx"
 		}
@@ -192,7 +208,7 @@
 end
 
 for op in $opcodes.keys do
-	for type in [:uint8, :int16, :int32
+	for type in [:uint8, :int16 #, :int32
 	] do
 		make_fun_map(op,type)
 		make_fun_zip(op,type)



More information about the Gridflow-cvs mailing list