7

以下代码没有将 ``` 之间的内容格式化为汇编代码,我想知道为什么。谢谢!

- here is an example of an appropriate input file


```
.text
main:
        la   $s0, A              # load variables A and B into registers
        lw   $s0, 0($s0)
        la   $s1, B
        lw   $s1, 0($s1)

        add  $s2, $s0, $s1       # calculate sum
        la   $s3, Sum            # assign result to Sum
        sw   $s2, 0($s3)

        sub  $s2, $s0, $s1       # calculate difference
        la   $s3, Diff           # assign result to Diff
        sw   $s2, 0($s3)
exit:
        li   $v0, 10             # system call to terminate program
        syscall                  # make call

.data
A:      .word   32
B:      .word   16
Sum:    .word    0
Diff:   .word    0
```

<h3>Output:</h3> a ASCII text file with the corresponding MIPS machine code. Here is the corresponding output file to the above input file
4

3 回答 3

10

对于它的价值,现在(在提出问题 3 年后),组装似乎就像一种魅力

```assembly
.text
main:
        la   $s0, A              # load variables A and B into registers
        lw   $s0, 0($s0)
        la   $s1, B
        lw   $s1, 0($s1)
```
于 2016-04-15T14:56:22.980 回答
4

不同的 markdown 实现可能使用不同的语法高亮字符串。

Stackoverflow 使用这个 javascript 文件:https ://dev.sstatic.net/js/prettify-full.en.js

不幸的是,不支持组装。
根据这个元问题,stackexchange 上支持的语言列表是:

"bsh", "c", "cc", "cpp", "cs", "csh",
"cyc", "cv", "htm", "html", "java",
"js", "m", "mxml", "perl", "pl", "pm",
"py", "rb", "sh", "xhtml", "xml", "xsl"

Github 使用这个 yaml 文件:https ://github.com/github/linguist/blob/master/lib/linguist/languages.yml 正确的字符串是assembly

Discord:可以在此处找到语言列表:https ://highlightjs.org/static/demo/ 对于 Intel x86,相关代码是x86asm

于 2020-04-20T22:41:15.557 回答
0

他们用于语法高亮的“语言学家”引擎只知道这么多语言;似乎汇编代码不在其中,因为我似乎在他们的linguist/samples目录中看不到任何示例。

但是,如果它位于 ``` 标记之间,它仍应以等宽字体显示为代码块。

于 2013-11-09T07:46:32.117 回答