From fac2f26447a0789a6142a690cefc7a3713f446bf Mon Sep 17 00:00:00 2001 From: Wojciech Kosior Date: Mon, 28 Dec 2020 10:44:00 +0100 Subject: add a tclasm version of example2 --- examples/example2c_measure_time_tclasm/Makefile | 3 ++ .../instructions.s.tcl | 52 ++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 examples/example2c_measure_time_tclasm/Makefile create mode 100644 examples/example2c_measure_time_tclasm/instructions.s.tcl diff --git a/examples/example2c_measure_time_tclasm/Makefile b/examples/example2c_measure_time_tclasm/Makefile new file mode 100644 index 0000000..b4058ef --- /dev/null +++ b/examples/example2c_measure_time_tclasm/Makefile @@ -0,0 +1,3 @@ +SIMFLAGS += -DFINISH_ON_LED1=1 -DFINISH_ON_LED2=1 + +include ../../Makefile.example diff --git a/examples/example2c_measure_time_tclasm/instructions.s.tcl b/examples/example2c_measure_time_tclasm/instructions.s.tcl new file mode 100644 index 0000000..39e1666 --- /dev/null +++ b/examples/example2c_measure_time_tclasm/instructions.s.tcl @@ -0,0 +1,52 @@ +## also look at soc_measure_time test + +### we do some of the same operations as in example2a and example2b + +# this will translate to 2 16-bit instructions +set_sp h100000 + +## reset the timer +# this will translate to 1 16-bit instruction +const 0 +# this will translate to 2 16-bit instructions +storew h1C0008 + +### we're going to add numbers from 0 to 100 +## initialize counter +# this will translate to 1 16-bit instruction +const 0 +# this will translate to 2 16-bit instructions +storew h080000 + +## initialize sum variable +# this will translate to 1 16-bit instruction +const 0 + +### this is the point we later jump to, address 18 +## load counter value, add it to the sum +loadwzx h080000 +add + +## increase counter +loadwzx h080000 +const 1 +add +storew h080000 + +## compare counter to 100 +loadwzx h080000 +const 100 +lt +cond_jump 18 + +## light LED2 +const 1 +storew h1C0006 + +### at this point we skip displaying to VGA - it'd be too cumbersome +### to do in tclasm +## store sum somewhere +store h080004 + +## finish operation (will also put led1 on) +halt -- cgit v1.2.3