diff mbox

[1/3] mambo_utils: make p return a value

Message ID 1480657140-3955-1-git-send-email-oohall@gmail.com
State Accepted
Headers show

Commit Message

Oliver O'Halloran Dec. 2, 2016, 5:38 a.m. UTC
Currently the "p" command uses puts to output the result to the user.
This works for interactive usage, but it makes it impossible for use
inside scripts. This patch changes the function to return the value
rather than print it. The mambo interpreter prints the result of an
expression so this should not cause any user visible changes.

With this change you can use p in expressions:

	x [p r3] 4

Which will display the word at the address in r3.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 external/mambo/mambo_utils.tcl | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Stewart Smith Dec. 23, 2016, 5:17 a.m. UTC | #1
Oliver O'Halloran <oohall@gmail.com> writes:
> Currently the "p" command uses puts to output the result to the user.
> This works for interactive usage, but it makes it impossible for use
> inside scripts. This patch changes the function to return the value
> rather than print it. The mambo interpreter prints the result of an
> expression so this should not cause any user visible changes.
>
> With this change you can use p in expressions:
>
> 	x [p r3] 4
>
> Which will display the word at the address in r3.
>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>

Series looks good, merged to master as of f38ed26
diff mbox

Patch

diff --git a/external/mambo/mambo_utils.tcl b/external/mambo/mambo_utils.tcl
index a97bdc42af64..e1243432cdaf 100644
--- a/external/mambo/mambo_utils.tcl
+++ b/external/mambo/mambo_utils.tcl
@@ -6,28 +6,25 @@  proc p { reg { t 0 } { c 0 } } {
     switch -regexp $reg {
 	^r$ {
             set val [mysim cpu $c thread $t display gprs]
-            puts "$val"
 	}
         ^r[0-9]+$ {
             regexp "r(\[0-9\]*)" $reg dummy num
             set val [mysim cpu $c thread $t display gpr $num]
-            puts "$val"
         }
         ^f[0-9]+$ {
             regexp "f(\[0-9\]*)" $reg dummy num
             set val [mysim cpu $c thread $t display fpr $num]
-            puts "$val"
         }
         ^v[0-9]+$ {
             regexp "v(\[0-9\]*)" $reg dummy num
             set val [mysim cpu $c thread $t display vmxr $num]
-            puts "$val"
         }
         default {
             set val [mysim cpu $c thread $t display spr $reg]
-            puts "$val"
         }
     }
+
+    return "$val"
 }
 
 #