MIC IJVM 2位简单和 [英] MIC IJVM simple sum of 2 digits

查看:98
本文介绍了MIC IJVM 2位简单和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个关于IJVM中计算的简单问题,因为我在他们的文档中找不到解决方案。

just a simple question regarding calculations in IJVM as I couldn't find the solution in their documentation.

假设我们需要执行以下计算:

Suppose we need to perform the following calculation:

BIPUSH 0x32 // PUSH 2
BIPUSH 0x33 // PUSH 3
IADD // PUSH sum(2,3)
OUT // output: "e"




IADD ---->从堆栈中弹出两个单词;推动他们的总和

IADD ----> Pop two words from stack; push their sum

我知道解决方案可能很简单,但是对于我来说,我不记得如何转换加/输出到实际数字。
如何使其输出 5而不是这个愚蠢的 e? :)

I know the solution is likely straight forward, but for the life of me I can't recall on how to convert the addition/output to the actual digits. How to make it output "5" instead of this stupid "e"? :)

干杯。

推荐答案

按预期,此问题的答案非常简单。这与实际找到答案非常矛盾,因为似乎没人愿意在文档中的任何地方提及此问题。太棒了

As expected, the answer to this problem was very simple. That's very much contradictory to actually finding the answer as no one seem to bother to mention this anywhere in the docs. Awesome.

解决方案:

BIPUSH 0x32 // PUSH 2
BIPUSH 0x33 // PUSH 3
IADD // PUSH sum(2,3)
DUP
BIPUSH 0x30 // PUSH 0
ISUB // subtract 0
OUT 

或实际代码:

plus:
    ILOAD X
    ILOAD Y
    IADD
    DUP
    BIPUSH 0x30
    ISUB
    GOTO return // Dominykas Tautkus. Linkėjimai prodekanui. :)

在执行加法运算后减去0会将其视为具有整数的实际数学任务,因此说话。

Subtracting 0 after performing addition forces it to treat this as an actual mathematical task with integers so to speak.

这篇关于MIC IJVM 2位简单和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆