Skip to content

Instantly share code, notes, and snippets.

@tranduydat
Last active March 8, 2020 16:29
Show Gist options
  • Save tranduydat/01337835e4f16c40cde8258f13f1ecb2 to your computer and use it in GitHub Desktop.
Save tranduydat/01337835e4f16c40cde8258f13f1ecb2 to your computer and use it in GitHub Desktop.
12.6
// X = (A + B * C)/(D - E * F)
// three-address code
MPY Y, B, C
ADD Y, Y, A
MPY Z, E, F
SUB Z, D, Z
DIV X, Y, Z
// two-address code
MOVE X, B
MPY X, C
ADD X, A
MOVE T, E
MPY T, F
MOVE Y, D
SUB Y, T
DIV X, Y
// one-address code
LOAD B
MPY C
ADD A
STOR X
LOAD E
MPY F
STOR Y
LOAD D
SUB Y
STOR Y
LOAD X
DIV Y
STOR X
// zero-address code
PUSH F
PUSH E
MPY
PUSH D
SUB
PUSH C
PUSH B
MPY
PUSH A
ADD
DIV
POP X
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment