【问题标题】:MARIE assembly language program.that allow the user to input 8 numbers and find the smallest and the largest as output [closed]MARIE汇编语言程序。允许用户输入8个数字并找到最小和最大的输出[关闭]
【发布时间】:2020-04-25 14:04:19
【问题描述】:

编写、运行和测试一个 MARIE 汇编语言程序。该程序应允许用户输入 8 个数字并找出最小和最大的数字。然后程序应该打印最小的数字和最大的数字。数字仅限于整数,可以是正数、负数或零。您不必提示输入或标记输出。

  ORG 100   / Calculation of the maximum

  Load First /loading 1st array member

  Store Next /address of next pointer,stores

  Load Array /Loading 1st element

  Store Max /maximum value with 1st element

  Loop, Clear

  AddI Next /Load next element!

  Subt Max /Comparing with the maximum once

  Skipcond 000 /If negative ->skip

  Jump NewMax /If not negative ->max value

  NextIdx, Load Next

  Add One /pointer++

  Store Next

  Load Count /counter--

  Subt One

  Skipcond 800 /counter is positive ->same proceeding

  Jump Print /else - printing the result

  Store Count /counter decresed and stored

  Jump Loop

  NewMax, Clear / new maximum value

  AddI Next

  Store Max

  Jump NextIdx

  Print, Load Max

  Output

  Halt /Terminate program

  First, Hex 11E /starting is location 11E(change as per...,as code changes don't forget to change it too)

  Next, Hex 0 /next element index (memory location)

  Max, Dec 0 /maximum value

  Count, Hex 8 / loop counter decreases

  One, Dec 1 /Loop stops

  Array, Dec -5
  Dec 15
  Dec -17
  Dec 20
  Dec -23
  Dec 12
  Dec 130
  Dec -12

我正在尝试打印最小值和最大值。这将只打印最大值。谁能帮我让它打印给定数组中的最小值。

【问题讨论】:

  • 你明白这段代码是如何计算最大值的吗?
  • 是的。我愿意。但我被skipcond困住了。
  • 我的朋友,您已经发布了一些您在互联网上找到的代码,最早可以追溯到 2010 年 3 月 10 日,要求我们根据您的目的进行更改。你没有费心去理解代码是如何工作的,你只是想让我们解决你的作业问题。嗯.. (justanswer.com/computer-programming/…)。这是一种不诚实的寻求帮助的方式。
  • 如果我错了,我现在提前道歉,但是当时的代码和你发布的一样,你想出相同算法的可能性很低,cmets , 和标签名称。我意识到这段代码可能在流传,所以你不一定从这里得到它。但我坚持我的观点。
  • @Krixnaas 所以你是科罗拉多州立大学的学生。

标签: assembly marie


【解决方案1】:

仅供参考,这是您向我们展示的代码,在过去十年中略有修改,网址:https://www.justanswer.com/computer-programming/38kwi-m-a-r-i-e-assembly-language-code-find-maximum.html:

    ORG 100 / Calculate maximum
    Load First /Load address of first array member
    Store Next /Store this address is our Next pointer
    Load Array /Load first element
    Store Max /Initialize MAX value with 1st element
    Loop, Clear
    AddI Next /Load next element, Inderect addressing!
    Subt Max /Compare with Max
    Skipcond 000 /If Negative - skip to the next element
    Jump NewMax /If not negative - we have a new maximum - initialize it
    NextIdx, Load Next
    Add One /Increase array pointer by 1
    Store Next
    Load Count /Decrease counter
    Subt One
    Skipcond 800 /If the counter is Positive - proceed to the Loop cycle
    Jump Print /Else - output result
    Store Count /Store decreased counter
    Jump Loop
    NewMax, Clear /Store new maximum
    AddI Next
    Store Max
    Jump NextIdx
    Print, Load Max
    Output
    Halt /Terminate program
    First, Hex 11E /Array elements start at location 11E, if you change code, you should fix this value
    Next, Hex 0 /Previous Next element index (memory location)
    Max, Dec 0 /The maximum value
    Count, Hex 8 /The loop counter (will decrease)
    One, Dec 1 /Loop step
    Array, Dec -1
    Dec 10
    Dec -15
    Dec 25
    Dec -25
    Dec 120
    Dec 13
    Dec -10

从互联网上复制一些代码是不合适的,这些代码已经流传了 10 多年,代表你写了它,假装你理解它,你只需要解决一个小问题,这个代码很明显实际作者。

作弊和抄袭不符合本网站和大多数其他网站的精神。

在这个大流行时期,许多教师正在过渡到他们不熟悉的在线方法。学生也无法获得他们需要的指导。所以,我同情所有参与的人。

但我们绝不能屈服于作弊的诱惑。为什么不试试别的?就像学习你发现的这段代码实际上做了什么?研究 Skipcond 可以做什么。大多数突然过渡到在线的课程也提供了额外的时间来完成作业。利用这段时间学习一些东西。

【讨论】:

  • +1 用于查找原始来源,但我在原始问题中没有看到任何声称 OP 编写该代码的说法。当我第一次阅读这个问题时,这对我来说似乎很明显,这只是他们发现但不理解的一些代码。正如您所说,希望能够清楚地为能够首先编写此代码的人更新循环中的最小值和最大值。
  • 像你一样,我非常怀疑 OP 声称如果他们不理解 skipcond 就可以理解它如何计算最大值。但是这里的剽窃可能过于强烈,只是通常的乐观情绪,即其他人会为他们工作,这样他们就不必理解它。但是,是的,在最初的帖子之后,声称他们理解它的评论似乎是欺骗,这是不对的。
  • @PeterCordes,你是对的,当然。尽管我确实没有真正指责 OP 抄袭,但是,我怀疑他们正走在这条路上,而且我不希望我们参与那种可能性,如果那样的话。
  • 哦,是的,这很公平。毫无疑问,他们打算交出某人作为答案发布的内容的副本。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-03
  • 1970-01-01
  • 1970-01-01
  • 2016-03-08
  • 2021-07-28
  • 2021-10-13
相关资源
最近更新 更多