Author: bernhard
Date: Sun Oct 23 03:33:23 2005
New Revision: 9536
Added:
trunk/examples/subs/jsr_ret.pasm
- copied, changed from r9534, trunk/examples/assembly/jump.pasm
Removed:
trunk/examples/assembly/Makefile
trunk/examples/assembly/jump.pasm
Modified:
trunk/MANIFEST
trunk/include/parrot/interpreter.h
trunk/t/examples/subs.t
Log:
Remove 'examples/assembly/Makefile', as 'make mandel.pbc' is not much
easier than '../../parrot -o mandel.pbc mandel.pasm'.
Move the example 'assembly/jump.pasm' to 'subs/jsr_ret.pasm',
add example for 'jsr' and 'ret' in jsr_ret.pasm,
and add a test.
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST (original)
+++ trunk/MANIFEST Sun Oct 23 03:33:23 2005
@@ -443,10 +443,8 @@ encodings/fixed_8.h
encodings/utf8.c []
encodings/utf8.h []
examples/README [main]doc
-examples/assembly/Makefile [main]doc
examples/assembly/acorn.l [main]doc
examples/assembly/hello-dwim.imc [main]doc
-examples/assembly/jump.pasm [main]doc
examples/assembly/lexical.pasm [main]doc
examples/assembly/lexical2.pasm [main]doc
examples/assembly/lexical3.pasm [main]doc
@@ -634,6 +632,7 @@ examples/sdl/tetris/eventhandler.imc
examples/sdl/tetris/tetris.imc [main]doc
examples/subs/bsr_ret.pasm [main]doc
examples/subs/coroutine.pasm [main]doc
+examples/subs/jsr_ret.pasm [main]doc
examples/subs/pasm_sub1.pasm [main]doc
examples/subs/sub1.imc [main]doc
examples/subs/sub2.imc [main]doc
Copied: trunk/examples/subs/jsr_ret.pasm (from r9534,
trunk/examples/assembly/jump.pasm)
==============================================================================
--- trunk/examples/assembly/jump.pasm (original)
+++ trunk/examples/subs/jsr_ret.pasm Sun Oct 23 03:33:23 2005
@@ -6,27 +6,37 @@
=head1 NAME
-examples/assembly/jump.pasm - Jumping to subroutine
+examples/subs/jsr_ret.pasm - Jumping to subroutine
=head1 SYNOPSIS
- % ./parrot examples/assembly/jump.pasm
+ % ./parrot examples/subs/jsr_ret.pasm
=head1 DESCRIPTION
-A program to demonstrate the use of the C<jump> opcode.
+A program to demonstrate the use of the C<jump> and of the C<jsr> opcode.
=cut
-MAIN: print "Jump test.\n"
- print "Jumping to subroutine...\n"
- set_addr I1, SUB
+MAIN: print "Example of the jump op.\n"
+ print "\n"
+ print "Jumping to subroutine SUB_1.\n"
+ set_addr I1, SUB_1
jump I1
-RET: print "Returned from subroutine!\n"
+RET: print "Returned from subroutine SUB_1.\n"
+ print "Jumping to subroutine SUB_2.\n"
+ set_addr I3, SUB_2
+ jsr I3
+ print "Returned from subroutine SUB_2.\n"
end
-SUB: print "Entered subroutine...\n"
+SUB_1: print "Entered subroutine SUB_1.\n"
set_addr I2, RET
+ print "Returning from subroutine SUB_1.\n"
jump I2
+SUB_2: print "Entered subroutine SUB_2.\n"
+ print "Returning from subroutine SUB_2.\n"
+ ret
+
Modified: trunk/include/parrot/interpreter.h
==============================================================================
--- trunk/include/parrot/interpreter.h (original)
+++ trunk/include/parrot/interpreter.h Sun Oct 23 03:33:23 2005
@@ -64,14 +64,14 @@ typedef enum {
/* &gen_from_enum(interpcores.pasm) */
typedef enum {
- PARROT_SLOW_CORE, /* slow bounds/trace/profile core */
+ PARROT_SLOW_CORE, /* slow bounds/trace/profile
core */
PARROT_FUNCTION_CORE = PARROT_SLOW_CORE,
- PARROT_FAST_CORE = 0x01, /* fast DO_OP core */
- PARROT_SWITCH_CORE = 0x02, /* P */
- PARROT_CGP_CORE = 0x06, /* CP */
- PARROT_CGOTO_CORE = 0x04, /* C = cgoto */
- PARROT_JIT_CORE = 0x10, /* TODO arange bits for P testing */
- PARROT_EXEC_CORE = 0x20 /* TODO Parrot_exec_run variants */
+ PARROT_FAST_CORE = 0x01, /* fast DO_OP core */
+ PARROT_SWITCH_CORE = 0x02, /* P */
+ PARROT_CGP_CORE = 0x06, /* CP */
+ PARROT_CGOTO_CORE = 0x04, /* C = cgoto */
+ PARROT_JIT_CORE = 0x10, /* TODO arange bits for P
testing */
+ PARROT_EXEC_CORE = 0x20 /* TODO Parrot_exec_run variants
*/
} Parrot_Run_core_t;
/* &end_gen */
Modified: trunk/t/examples/subs.t
==============================================================================
--- trunk/t/examples/subs.t (original)
+++ trunk/t/examples/subs.t Sun Oct 23 03:33:23 2005
@@ -20,11 +20,12 @@ Test the examples in F<examples/subs>.
F<t/examples/japh.t>
F<t/examples/pasm.t>
+F<t/examples/pir.t>
=cut
use strict;
-use Parrot::Test tests => 6;
+use Parrot::Test tests => 7;
use Test::More;
# Set up expected output for examples
@@ -48,6 +49,19 @@ Resumed
Done
END_EXPECTED
+ 'jsr_ret.pasm' => << 'END_EXPECTED',
+Example of the jump op.
+
+Jumping to subroutine SUB_1.
+Entered subroutine SUB_1.
+Returning from subroutine SUB_1.
+Returned from subroutine SUB_1.
+Jumping to subroutine SUB_2.
+Entered subroutine SUB_2.
+Returning from subroutine SUB_2.
+Returned from subroutine SUB_2.
+END_EXPECTED
+
'pasm_sub1.pasm' => << 'END_EXPECTED',
Hello from subroutine
Hello from main