Skip to content

Instantly share code, notes, and snippets.

@vsmelov
Last active March 28, 2021 17:00
Show Gist options
  • Save vsmelov/0d0937ce517e33ef87c9cf1d1c0ab7e3 to your computer and use it in GitHub Desktop.
Save vsmelov/0d0937ce517e33ef87c9cf1d1c0ab7e3 to your computer and use it in GitHub Desktop.
a[3] = a[7] * 2
set _comment "define constants"
set maxASize 10
op mul maxASizeX2 maxASize 2
set m 7
set n 3
set _comment "def aGetIndex"
op add aGetIndexLine @counter 1
op add @counter @counter maxASizeX2
set aGetResult a0
set @counter aGetIndexCaller
set aGetResult a1
set @counter aGetIndexCaller
set aGetResult a2
set @counter aGetIndexCaller
set aGetResult a3
set @counter aGetIndexCaller
set aGetResult a4
set @counter aGetIndexCaller
set aGetResult a5
set @counter aGetIndexCaller
set aGetResult a6
set @counter aGetIndexCaller
set aGetResult a7
set @counter aGetIndexCaller
set aGetResult a8
set @counter aGetIndexCaller
set aGetResult a9
set @counter aGetIndexCaller
set _comment "def aSetIndex"
op add aSetIndexLine @counter 1
op add @counter @counter maxASizeX2
set a0 aSetValue
set @counter aSetIndexCaller
set a1 aSetValue
set @counter aSetIndexCaller
set a2 aSetValue
set @counter aSetIndexCaller
set a3 aSetValue
set @counter aSetIndexCaller
set a4 aSetValue
set @counter aSetIndexCaller
set a5 aSetValue
set @counter aSetIndexCaller
set a6 aSetValue
set @counter aSetIndexCaller
set a7 aSetValue
set @counter aSetIndexCaller
set a8 aSetValue
set @counter aSetIndexCaller
set a9 aSetValue
set @counter aSetIndexCaller
set _comment "deleteme: initalize array with range()"
set a0 0
set a1 1
set a2 2
set a3 3
set a4 4
set a5 5
set a6 6
set a7 7
set a8 8
set a9 9
set _comment "def aGet(i)"
op add aGetLine @counter 1
op add @counter @counter 5
op mul iX2 i 2
op add callLine aGetIndexLine iX2
op add aGetIndexCaller @counter 1
set @counter callLine
set @counter aGetCaller
set _comment "def aSet(i)"
op add aSetLine @counter 1
op add @counter @counter 5
op mul iX2 i 2
op add callLine aSetIndexLine iX2
op add aSetIndexCaller @counter 1
set @counter callLine
set @counter aSetCaller
set _comment "==== MAIN ===="
set _comment "aSet(3, aGet(7) * 2)"
set _comment "== 1) aGetResult:= aGet(7) =="
set i m
op add aGetCaller @counter 1
set @counter aGetLine
set _comment "== 2) aSetValue := aGetResult * 2 =="
op mul aSetValue aGetResult 2
set _comment "== 3) aSet(3, aSetValue) =="
set i n
op add aSetCaller @counter 1
set @counter aSetLine
set _comment "==== TEST ===="
print "a["
print m
print "] = "
print aGetResult
printflush message1
print "a3 = "
print a3
printflush message2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment