Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Further examples #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

WIP: Further examples #1

wants to merge 7 commits into from

Conversation

hornc
Copy link
Owner

@hornc hornc commented Sep 24, 2022

TODO

  • Improve notation / macro expansion to make the examples functional for any prime encoded virtual register
    (currently %VREG% is to be replaced using sed)
  • The decrease doesn't currently test or leave the data unmodified if it is already zero (currently other registers get messed up if an already zeroed register is decreased below zero)

Example usage:

The output below show R0 with the initial state (register value, and its prime decoding), R1 is the final state after applying the code example.

./counterfish.py <(./cfmacro.py <(sed 's/%VREG%/5/g' examples/decv.cfm)) -i91125

result:

R0: 91125
   [0, 6, 3]
R1: 18225
   [0, 6, 2]

Which shows v.reg 5 (i.e. the third prime number register) decrease from 3 to 2, leaving v.reg.3 unchanged at 6.

Running the increase example on the same state:

./counterfish.py <(./cfmacro.py <(sed 's/%VREG%/5/g' examples/incv.cfm)) -i91125

result:

R0: 91125
   [0, 6, 3]
R1: 455625
   [0, 6, 4]

Running increase on v.reg.3:

./counterfish.py <(./cfmacro.py <(sed 's/%VREG%/3/g' examples/incv.cfm)) -i91125

result:

R0: 91125
   [0, 6, 3]
R1: 273375
   [0, 7, 3]

Running increase on v.reg.37:

 ./counterfish.py <(./cfmacro.py <(sed 's/%VREG%/37/g' examples/incv.cfm)) -i91125

result:

R0: 91125
   [0, 6, 3]
R1: 3371625
   [0, 6, 3, 0, 0, 0, 0, 0, 0, 0, 0, 1]

@hornc hornc changed the title Further examples WIP: Further examples Sep 24, 2022
@hornc hornc self-assigned this Feb 7, 2023
@hornc
Copy link
Owner Author

hornc commented Feb 8, 2023

./counterfish.py <(./cfmacro.py <(sed 's/%VREG%/5/g' examples/incv.cfm)) -i91125

./counterfish.py <(./cfmacro.py examples/incv.cfm -v VREG=5 ) -i91125




./counterfish.py <(./cfmacro.py <(sed 's/%VREG%/7/g;s/%C%/5/g' examples/setvc.cfm)) -i1

./counterfish.py <(./cfmacro.py -v VREG=7,C=5 examples/setvc.cfm) -i1

Add a warning to list all unassigned variables when compiling macros

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant