Appearance
GreatestCommonDivisor
ユークリッドの互除法で1071と462の最大公約数21を求めます。剰余を使ったwhileループのサンプルです。
json
{
"version": 1,
"comment": "ユークリッドの互除法で1071と462の最大公約数21を求めます。剰余を使ったwhileループのサンプルです。",
"data": [
{
"name": "__a",
"type": "SystemInt32",
"value": 0
},
{
"name": "__b",
"type": "SystemInt32",
"value": 0
},
{
"name": "__remainder",
"type": "SystemInt32",
"value": 0
},
{
"name": "__value_1071",
"type": "SystemInt32",
"value": 1071
},
{
"name": "__value_462",
"type": "SystemInt32",
"value": 462
},
{
"name": "__zero",
"type": "SystemInt32",
"value": 0
},
{
"name": "__condition",
"type": "SystemBoolean",
"value": false
},
{
"name": "__prefix",
"type": "SystemString",
"value": "gcd = "
},
{
"name": "__message",
"type": "SystemString",
"value": ""
}
],
"code": [
{
"name": "_start",
"export": true,
"instructions": [
{
"op": "PUSH",
"operand": "__value_1071"
},
{
"op": "PUSH",
"operand": "__a"
},
{
"op": "COPY"
},
{
"op": "PUSH",
"operand": "__value_462"
},
{
"op": "PUSH",
"operand": "__b"
},
{
"op": "COPY"
},
{
"op": "JUMP",
"operand": "_loop"
}
]
},
{
"name": "_loop",
"export": false,
"instructions": [
{
"op": "PUSH",
"operand": "__b"
},
{
"op": "PUSH",
"operand": "__zero"
},
{
"op": "EXTERN",
"signature": "SystemInt32.__op_Inequality__SystemInt32_SystemInt32__SystemBoolean",
"argumentCount": 2,
"return": "__condition"
},
{
"op": "JUMP_IF_FALSE",
"operand": "_end"
},
{
"op": "PUSH",
"operand": "__a"
},
{
"op": "PUSH",
"operand": "__b"
},
{
"op": "EXTERN",
"signature": "SystemInt32.__op_Remainder__SystemInt32_SystemInt32__SystemInt32",
"argumentCount": 2,
"return": "__remainder"
},
{
"op": "POP"
},
{
"op": "PUSH",
"operand": "__b"
},
{
"op": "PUSH",
"operand": "__a"
},
{
"op": "COPY"
},
{
"op": "PUSH",
"operand": "__remainder"
},
{
"op": "PUSH",
"operand": "__b"
},
{
"op": "COPY"
},
{
"op": "JUMP",
"operand": "_loop"
}
]
},
{
"name": "_end",
"export": false,
"instructions": [
{
"op": "PUSH",
"operand": "__prefix"
},
{
"op": "PUSH",
"operand": "__a"
},
{
"op": "EXTERN",
"signature": "SystemString.__Concat__SystemObject_SystemObject__SystemString",
"argumentCount": 2,
"return": "__message"
},
{
"op": "EXTERN",
"signature": "UnityEngineDebug.__Log__SystemObject__SystemVoid",
"argumentCount": 1
}
]
}
]
}