+################################################################################
+# add_scale_test #
+################################################################################
+def add_scale_test_dummy(a, b, scale)
+ should = a + (b<<(8*scale))
+ printf("[dummy] %s + %s <<8*%04x = %s\n",a.to_s(16), b.to_s(16), scale, should.to_s(16))
+end
+
+def add_scale_test(a, b, scale)
+ m = wait_for_prompt("enter a:")
+ return false if !m
+ puts("DBG put (#{__LINE__}): "+a.to_s(16)+" ") if $debug
+ $sp.print(a.to_s(16)+" ")
+ m = wait_for_prompt("enter b:")
+ return false if !m
+ puts("DBG put (#{__LINE__}): "+b.to_s(16)+" ") if $debug
+ $sp.print(b.to_s(16)+" ")
+ m = wait_for_prompt("enter scale:")
+ return false if !m
+ puts("DBG put (#{__LINE__}): "+scale.to_s(10)+" ") if $debug
+ $sp.print(scale.to_s(10)+"\r")
+ should = a + (b<<(8*scale))
+ m = wait_for_prompt(/[\s]*([-]?[0-9a-fA-F]+)[\s]+\+[\s]+([+-]?[0-9a-fA-F]+)[\s]*<<8\*[\s]*([+-]?[0-9a-fA-F]+)[\s]*=[\s]*([+-]?[0-9a-fA-F]+)/)
+ if !m
+ $logfile.printf("[fail (CRASH)]:")
+ $logfile.printf(" ; should %s + %s << 8*%s = %s\n", a.to_s(16), b.to_s(16), scale.to_s(16), should.to_s(16))
+ return false
+ end
+ line = m[0]
+ a_ = m[1].to_i(16)
+ b_ = m[2].to_i(16)
+ s_ = m[3].to_i(16)
+ c_ = m[4].to_i(16)
+ line.chomp!
+ if(a_== a && b_ == b && s_ == scale && c_ == should )
+ $logfile.printf("[pass]: %s\n", line)
+ return true
+ else
+ $logfile.printf("[fail (%s%s%s%s)]: %s", (a==a_)?"":"a", (b==b_)?"":"b", (scale==s_)?"":"s",(c_==should)?"":"c",line)
+ $logfile.printf(" ; should %s + %s << 8*%s = %s\n", a.to_s(16), b.to_s(16), scale.to_s(16), should.to_s(16))
+ return false
+ end
+ return false
+end
+