问题标签 [y86]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
75 浏览

c - 汇编优化函数调用,允许从函数中取出常量?

我有一个递归 C 函数

在主函数里面。

相应的程序集如下所示:

在 foo 内部,我使用 8 字节长的 quad 大小的常量值。(值 8 在 C 代码中不存在,但我正在使用此值将数组的长度转换为相应的地址等...)

如果每次递归调用 foo 时都加载这个值,我认为这是在浪费周期。我想知道编译器是否能够对其进行优化,以便在主调用 foo 之前加载常量?

示例:在调用 foo 之前将值 8 加载到 r13 一次,这样就不必每次都加载。(前提是 r13 恢复到加载值 8 之前的原始状态,点击停止后)

如果我在 main 之前将值 8 保存到 r13 中,这是否仍然保留了 foo(int numFruits) 的精神,还是我的更改等同于 foo(int numFruits, int quadSize)?

谢谢

0 投票
2 回答
910 浏览

linux - 无法从源代码构建 y86-64 模拟器

我正在尝试在 Linux 上为 Y86-64 代码编译一个模拟器。我已经重写了 makefile,但结果如下所示。它说“'matherr' 的未定义引用”。(看起来它在链接时与 gcc 连接)

0 投票
2 回答
350 浏览

assembly - 有没有办法只使用 xorq、andq、addq、iaddq 和 subq 来执行算术右移?

我在一个假设的架构中,只有这些操作(Y86)。不存在算术右移。我实际上是在尝试捕获最高位以确定该数字是否为负,如果是,则将其添加到结果寄存器 rax。

编辑:

对不起,我忘了指定,我试图避免条件分支,看看它是否能提高效率。我所在的版本中不存在 cmov。

我得到的最远的是:

但是,对于 0 的结果,这不起作用。

0 投票
0 回答
285 浏览

for-loop - 在 Y86 中嵌套 for 循环

所以我想弄清楚在 Y86 中编写一个嵌套的 for 循环。(我现在 Y86 只是为了教学)。我已经研究了如何执行常规 for 循环,但不确定如何为嵌套循环执行此操作,尤其是当您调用 2 个函数时,一个接一个地调用。有人可以指出我正确的方向。这只是我想写的一个例子。

0 投票
0 回答
518 浏览

c - 将递归 C 函数转换为 Y86 程序集

我是汇编编程的新手,我正在尝试将用 c 编写的函数转换为汇编代码 Y86。这就是我所拥有的,但我知道这是错误的。我开始为一个参数编写汇编代码,但是当我尝试使用 2 个参数时,我对该怎么做感到困惑。我可以使用一些帮助。假设 x = 5 和 y = 1。

0 投票
1 回答
302 浏览

c++ - C++ Y86 Disassembler - How to interpret .quad

So, for a class assignment we are writing a Y86 (toy processor) disassembler in C++. Easy enough, I have almost everything done, except for disassembling instructions into a .quad directive.

The quad directive takes a numeric or hexadecimal value, and then converts it into an 8-byte "instruction" (it's not really an instruction, .quad is the only thing in the processor that takes 8 bytes so if you come across an 8 byte line you automatically know you're looking at a quad) that is representative of the value. Here's an example below since my explanation may not be great:

https://image.prntscr.com/image/h5xAoE4YRryl7HSJ13o5Yg.png

It's easy enough to see that the first two quads there are bit shifted 2 to the right on disassembly, but then the next two are bit-shifted 2 to the left. What's the pattern I'm missing here? Here's some more examples of disassembled quads:

Essentially, I'm trying to write an algorithm that will take what's on the left in those screenshots (assembled processor code) and return ".quad 0xblahblah," but I can't figure out what it's doing to the hex values in order to get them like that.

My current C++ code is as follows:

But when it should be returning the .quads you see in the first screenshot I posted, it's returning this:

Which is the exact value of the assembled machine code, when I need to figure out what it's doing to end up with

As in the example screenshot.

0 投票
1 回答
45 浏览

memory - Y86-64 ISA 中存储的条件标志在哪里?

条件标志 SF、ZF 和 OF,在虚构的 Y86-64 架构中,如 Randall 和 Bryant 的 Computer Systems, a Programmer's Perspective 中所述。

0 投票
1 回答
187 浏览

assembly - 实现条件跳转时如何在管道中查找指令

我在准备考试时遇到了一个问题。问题是

在回答以下有关在课堂上介绍的 5 阶段管道中实现条件跳转的问题时,请考虑以下 y86 代码片段,阶段为 F、D、E、M、WB。

一个。当 jne 指令完成 F 阶段时,下一条指令的地址在处理器中可用吗?圈一个

湾。如果处理器假设条件跳转为 TAKEN,那么当 jne 指令完成 F 阶段时,下一条指令的地址在哪个流水线内部寄存器(变量)中?圈出一个 icode ifun rA rB valC valP valM valE

C。如果处理器假设条件跳转是 NOT TAKEN,那么当 jne 指令完成 F 阶段时,下一条指令的地址在哪个流水线内部寄存器(变量)中?圈一个

d。在哪个阶段之后管道会知道是否应该进行条件跳转?圈出正确的阶段

我有没有解释的答案这里是答案:

1) 是的

2) valC

3) valP

4) E

有人可以请,请解释这个过程。我有考试,我真的需要帮助

0 投票
0 回答
134 浏览

assembly - 在 Y86 中,当你有超过 6 个函数参数时会发生什么?

考虑 c 中的这个函数: long arithEx(long, long, long, long, long, long, long, long);

在 X-86 中,汇编代码如下所示:

这对我来说很有意义,因为 X-86 和 Y-86 只有 6 个寄存器来接收函数参数。而对于 X-86,由于它支持立即到内存寻址模式,我们可以将其余参数存储到内存中。

但是,对于 Y-86,我们没有可以将立即数移动到内存的指令,那么其余的参数应该去哪里呢?

0 投票
2 回答
958 浏览

assembly - 如何在 Y86-64 中执行右移(或其他带有 ADD + AND 但没有原生右移的玩具 ISA)

我正在尝试对 Y86-64 进行右移

要进行左移,我知道我需要乘以 2^n,其中 n 是我们想要的移位数,例如,如果我们想要移动 4,它是 2^4 = 16 并执行加法循环以执行乘法就可以了,但我不确定该怎么做正确的转变我认为我需要执行除法,但不确定如何处理