简体   繁体   English

X86汇编指令转换为MIPS指令(端口,IN,I / O)

[英]X86 assembly instruction to MIPS instruction (Port, IN, I/O)

In X86, there is an instruction called IN: 在X86中,有一条称为IN的指令:
https://c9x.me/x86/html/file_module_x86_id_139.html https://en.wikipedia.org/wiki/X86_instruction_listings https://c9x.me/x86/html/file_module_x86_id_139.html https://en.wikipedia.org/wiki/X86_instruction_listings

MIPS does not have this instruction: MIPS没有此指令:
http://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html http://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html

I want to write my own IN instruction in MIPS. 我想在MIPS中编写自己的IN指令。
How can this be done? 如何才能做到这一点?
We are writing an operating system using C and MIPS: 我们正在使用C和MIPS编写操作系统:
https://github.com/uu-os-2018/project-iota https://github.com/uu-os-2018/project-iota

This function results in: 此函数导致:
Error: unrecognized opcode inb $2,lo 错误:无法识别的操作码inb $2,lo

static inline uint8_t inb(uint16_t port)  {  
     uint8_t ret;  
    asm volatile ( "inb %1, %0"  
                   : "=a"(ret)  
                   : "Nd"(port) );  
    return ret;  
}

The significant difference between in/out and memory access instructions is in how the hardware behaves. 进/出和内存访问指令之间的重要区别在于硬件的行为方式。 There is no way for software to make a system that uses I/O-mapped I/O work with memory instructions or vice-versa. 软件无法使使用I / O映射的I / O的系统与内存指令一起工作,反之亦然。 Since MIPS systems use only memory-mapped I/O, there is no possible use for in/out instructions. 由于MIPS系统仅使用内存映射的I / O,因此无法使用in / out指令。

The predecessors of the x86 family (the 8080 and 8085 processors) only had a 16-bit address bus and thus could only use a total of 64 kB of memory. x86系列的前辈(8080和8085处理器)仅具有16位地址总线,因此只能使用总共64 kB的内存。

Reserving some of this space for devices was seen as problematic as it limited the small amount of memory even more. 为设备保留一些此类空间被认为是有问题的,因为它进一步限制了少量的内存。 So the processors got a second address space (I/O space), with an additional 64 kB, by using IN and OUT instructions instead of load and store. 因此,处理器通过使用IN和OUT指令(而不是加载和存储)获得了第二个地址空间(I / O空间)和额外的64 kB。 The difference appeared externally as a special pin, in essence giving the CPU a 17th address bit. 区别是从外部作为特殊引脚出现的,本质上为CPU提供了第17个地址位。

When Intel designed the 8086, they followed this design from the 8085 as some kind of limited backward compatibility. 英特尔设计8086时,他们遵循了8085的这种设计,因为它具有某种有限的向后兼容性。 Despite this the original PC reserved the space between 640 kB and 1 MB for devices using memory mapped I/O. 尽管如此,原始PC仍为使用内存映射I / O的设备保留了640 kB和1 MB之间的空间。 The video board, for example, appeared in this space. 例如,视频板出现在该空间中。

The designers of the MIPS series didn't have those concerns about predecessors, and having gigabytes of address space from the start they didn't see a problem in using some 64 kB of this space for devices. MIPS系列的设计人员无需担心前代产品,从一开始就拥有千兆字节的地址空间,因此他们对使用大约64 kB的空间用于设备没有任何问题。 That way they also only had to provide load and store instructions and could skip the IN and OUT. 这样,他们也只需要提供加载和存储指令,就可以跳过输入和输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM