EXAPUNKS

EXAPUNKS

View Stats:
Can someone please explaion MODI
Hi

i do not have any programming knowledge and i am really enjoying this game. I am currently at the equity bank task.

i completed the highway sign task with a code that i know it is not pretty but it worked. i have since watched a scott manley video and he used the code below mine. I do not knoiw what MODI is actually doing in his code so if someone can explain in simple terms what MODI does or can do that would be great

MY CODE


XA

GRAB 300
MARK LOOP
COPY F M
JUMP LOOP

XB

LINK 800
COPY 1 #CLRS
COPY 0 X
MARK START
COPY 0 T
MARK LOOP
COPY T #DATA
COPY X #DATA
COPY M #DATA
ADDI X 1 X
TEST X = 9
TJMP STAGE2
JUMP START
MARK STAGE2
COPY 0 X
MARK START1
COPY 1 T
MARK LOOP1
COPY T #DATA
COPY X #DATA
COPY M #DATA
ADDI X 1 X
TEST X = 9
TJMP STAGE3
JUMP START1
MARK STAGE3
COPY 0 X
MARK START2
COPY 2 T
MARK LOOP2
COPY T #DATA
COPY X #DATA
COPY M #DATA
ADDI X 1 X
TEST X = 9
TJMP STAGE4
JUMP START2
MARK STAGE4
HALT




SCOTT MANLEY CODE


XA

LINK 800
MARK LOOP
DIVI X 9 T
COPY T #DATA
MODI X 9 T
COPY T #DATA
COPY M #DATA
ADDI X 1 X
TEST X = 27
FJMP LOOP

XB

GRAB 300
MARK LOOP
COPY F M
TEST EOF
FJMP LOOP


sorry for being dumb and thank you in advance

Originally posted by Slain087:
MOD takes the remainder of division by the selected numbers; so for example, 39 mod 9 results in 3. (39/9 = 4 with 3 remainder). Scott's solution uses the X register as a total counter for both the horizontal and vertical axes; dividing by 9 gives the row (so 19 would be row 2, or the bottom row in other words), while getting the mod 9 gives the column (19 would be column 1, aka the second column).
< >
Showing 1-7 of 7 comments
The author of this thread has indicated that this post answers the original topic.
MOD takes the remainder of division by the selected numbers; so for example, 39 mod 9 results in 3. (39/9 = 4 with 3 remainder). Scott's solution uses the X register as a total counter for both the horizontal and vertical axes; dividing by 9 gives the row (so 19 would be row 2, or the bottom row in other words), while getting the mod 9 gives the column (19 would be column 1, aka the second column).
Thank you
For negative numbers: -2 mod 7 = 5, 2 mod -7 = -5, -2 mod -7 = -2
btw modulo is a mathematical concept, its not just for programming.
There are whole mathematical systems build just with that concept.
Originally posted by la_nague:
btw modulo is a mathematical concept, its not just for programming.
There are whole mathematical systems build just with that concept.

thanks la_nague
Thanks Slain087
< >
Showing 1-7 of 7 comments
Per page: 1530 50