Skip to content

The ternary conditional operator inside jumps, supposedly enabled in v5.2.1, doesn't really work. #38

@FlatAssembler

Description

@FlatAssembler

Here is an example program demonstrating that:

;This is an example program demonstrating
;how the `?:` operator in jumps, supposedly
;enabled in v5.2.1, doesn't really work as
;intended.

address 0
jump PicoBlaze_Simulator_in_JS ? code_that_should_run_in_browser : code_that_should_run_on_mobile
load s0, 0
code_that_should_run_on_mobile:
load s0, 1
jump end_of_branching
code_that_should_run_in_browser:
load s0, 2
jump end_of_branching
end_of_branching:

;The 7th line doesn't assemble. The assembler
;asks the user `Instead of 
;"code_that_should_run_in_browser", in the
;line #7, did you perhaps mean 
;"PicoBlaze_Simulator_in_JS"?`. It has to do
;with the way the assembler is structured
;internally. Namely, when the core of the
;assembler sees the "jump" instruction, it
;invokes the "getLabelAddress" method of the
;"TreeNode" class. However, when that method
;sees that it's being invoked on an `?:`
;operator, it wrongly assumes that all of its
;operands are arithmetic expressions, so
;it invokes the 
;"interpretAsArithmeticExpression" method.
;That method takes as the only argument the
;"constants" argument, and it has no access
;to the labels. There doesn't seem to be
;a simple solution.

Perhaps separating the labels and constants into different structures returned by the preprocessor was a mistake after all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions