You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, in the Python-based Boneless assembler, when specifying the name of a label in an instruction, e.g. MOVR(R3, "label"), the instruction operand is substituted by the PC-relative address of the label. This is the only way to use a label.
I propose a way to apply arbitrary calculations to labels before their values get substituted. Instead of specifying "label", the user could specify LabelCalc(lambda pc, lbl: label, "label") to the same effect.
By allowing an arbitrary lambda expression for the label, many other possibilities could be expressed. For example, LabelCalc(lambda pc, lbl: label-pc, "label") specifies the absolute location of "label". If there was an array with labels at the start and end, one could specify CMPI(R3, LabelCalc(lambda pc, s, e: e-s, "data_start", "data_end")) to test if R3 has reached the number of items in the array.
Based on my understanding of the assembler, this lambda expression would allow arbitrary calculations without changing its framework. However, there may be problems converging if the user specified a nonlinear calculation. In that case, there may need to be a check to fail assembly if there is no convergence after a reasonable number of iterations.
The text was updated successfully, but these errors were encountered:
Currently, in the Python-based Boneless assembler, when specifying the name of a label in an instruction, e.g.
MOVR(R3, "label")
, the instruction operand is substituted by the PC-relative address of the label. This is the only way to use a label.I propose a way to apply arbitrary calculations to labels before their values get substituted. Instead of specifying
"label"
, the user could specifyLabelCalc(lambda pc, lbl: label, "label")
to the same effect.By allowing an arbitrary lambda expression for the label, many other possibilities could be expressed. For example,
LabelCalc(lambda pc, lbl: label-pc, "label")
specifies the absolute location of"label"
. If there was an array with labels at the start and end, one could specifyCMPI(R3, LabelCalc(lambda pc, s, e: e-s, "data_start", "data_end"))
to test if R3 has reached the number of items in the array.Based on my understanding of the assembler, this lambda expression would allow arbitrary calculations without changing its framework. However, there may be problems converging if the user specified a nonlinear calculation. In that case, there may need to be a check to fail assembly if there is no convergence after a reasonable number of iterations.
The text was updated successfully, but these errors were encountered: