git @ Cat's Eye Technologies SixtyPical / c246424
Fix bug raising InconsistentExitError, and type-bug in ribos2.60p. Chris Pressey 2 years ago
3 changed file(s) with 83 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
4949 // be practical. So we just jump to this location instead.
5050
5151 define pla_tay_pla_tax_pla_rti routine
52 inputs a
53 trashes a
52 inputs border_color, vic_intr
53 outputs border_color, vic_intr
54 trashes a, z, n, c
5455 @ $EA81
5556
5657 // ----- Interrupt Handler -----
480480 exit_writeable = set(exit_context.each_writeable())
481481 for ex in self.exit_contexts[1:]:
482482 if set(ex.each_meaningful()) != exit_meaningful:
483 raise InconsistentExitError("Exit contexts are not consistent")
483 raise InconsistentExitError(routine, "Exit contexts are not consistent")
484484 if set(ex.each_touched()) != exit_touched:
485 raise InconsistentExitError("Exit contexts are not consistent")
485 raise InconsistentExitError(routine, "Exit contexts are not consistent")
486486 if set(ex.each_writeable()) != exit_writeable:
487 raise InconsistentExitError("Exit contexts are not consistent")
487 raise InconsistentExitError(routine, "Exit contexts are not consistent")
488488
489489 # We now set the main context to the (consistent) exit context
490490 # so that this routine is perceived as having the same effect
39203920 | }
39213921 = ok
39223922
3923 TODO: we should have a lot more test cases for the above, here.
3923 Another inconsistent exit test, this one based on "real" code
3924 (the `ribos2` demo).
3925
3926 | typedef routine
3927 | inputs border_color, vic_intr
3928 | outputs border_color, vic_intr
3929 | trashes a, z, n, c
3930 | irq_handler
3931 |
3932 | vector irq_handler cinv @ $314
3933 | vector irq_handler saved_irq_vec
3934 | byte vic_intr @ $d019
3935 | byte border_color @ $d020
3936 |
3937 | define pla_tay_pla_tax_pla_rti routine
3938 | inputs a
3939 | trashes a
3940 | @ $EA81
3941 |
3942 | define our_service_routine irq_handler
3943 | {
3944 | ld a, vic_intr
3945 | st a, vic_intr
3946 | and a, 1
3947 | cmp a, 1
3948 | if not z {
3949 | goto saved_irq_vec
3950 | } else {
3951 | ld a, border_color
3952 | xor a, $ff
3953 | st a, border_color
3954 | goto pla_tay_pla_tax_pla_rti
3955 | }
3956 | }
3957 |
3958 | define main routine
3959 | {
3960 | }
3961 ? InconsistentExitError
3962
3963 | typedef routine
3964 | inputs border_color, vic_intr
3965 | outputs border_color, vic_intr
3966 | trashes a, z, n, c
3967 | irq_handler
3968 |
3969 | vector irq_handler cinv @ $314
3970 | vector irq_handler saved_irq_vec
3971 | byte vic_intr @ $d019
3972 | byte border_color @ $d020
3973 |
3974 | define pla_tay_pla_tax_pla_rti routine
3975 | inputs border_color, vic_intr
3976 | outputs border_color, vic_intr
3977 | trashes a, z, n, c
3978 | @ $EA81
3979 |
3980 | define our_service_routine irq_handler
3981 | {
3982 | ld a, vic_intr
3983 | st a, vic_intr
3984 | and a, 1
3985 | cmp a, 1
3986 | if not z {
3987 | goto saved_irq_vec
3988 | } else {
3989 | ld a, border_color
3990 | xor a, $ff
3991 | st a, border_color
3992 | goto pla_tay_pla_tax_pla_rti
3993 | }
3994 | }
3995 |
3996 | define main routine
3997 | {
3998 | }
3999 = ok
39244000
39254001 Can't `goto` a routine that outputs or trashes more than the current routine.
39264002