Home Database Mysql Tutorial 自己动手写CPU之第九阶段(2)加载存储指令说明2(lwl、lwr

自己动手写CPU之第九阶段(2)加载存储指令说明2(lwl、lwr

Jun 07, 2016 pm 03:20 PM
cpu load storage handwriting instruction Own illustrate stage

将陆续上传新书《 自己动手写CPU 》,今天是第38篇,我尽量每周四篇,但是最近已经很久没有实现这个目标了,一直都有事,不好意思哈。 开展晒书评送书活动,在 亚马逊 、京东、当当三大图书网站上,发表《 自己动手写CPU 》书评的前十名读者,均可获赠《步步

将陆续上传新书《自己动手写CPU》,今天是第38篇,我尽量每周四篇,但是最近已经很久没有实现这个目标了,一直都有事,不好意思哈。

开展晒书评送书活动,在亚马逊、京东、当当三大图书网站上,发表《自己动手写CPU》书评的前十名读者,均可获赠《步步惊芯——软核处理器内部设计分析》一书,大家踊跃参与吧!活动时间:2014-9-11至2014-10-20


今天继续对MIPS32中加载存储指令进行说明(主要是lwl、lwr),上次已经介绍一些其他的加载存储指令,大家可以回顾。


9.1.4 加载指令lwllwr说明

      加载指令lwllwr的格式如图9-6所示。

自己动手写CPU之第九阶段(2)加载存储指令说明2(lwl、lwr
  •  当指令中的指令码为6'b100010时,是lwl指令,非对齐加载指令,向左加载

      指令用法为:lwl rt, offset(base)

      指令作用为:从内存中指定的加载地址处,加载一个字的最高有效部分。lwl指令对加载地址没有要求,从而允许地址非对齐加载,这是与前面介绍的lhlhulw指令的不同之处。在大端模式、小端模式下,lwl指令的效果不同,因为OpenMIPS是大端模式,所以此处只介绍在大端模式下lwl指令的效果。假设计算出来的加载地址是loadaddrloadaddr的最低两位的值为n,将loadaddr最低两位设为0后的值称为loadaddr_align,如下。

加载地址loadaddr = signed_extended(offset) + GPR[base]

n = loadaddr[1:0]

loadaddr_align = loadaddr – n

      例如:假设计算出来的加载地址是5lwl指令要从地址5加载数据,那么loadaddr就等于5n等于1loadaddr_align等于4

      lwl指令的作用是从地址为loadaddr_align处加载一个字,也就是4个字节,然后将这个字的最低4-n个字节保存到地址为rt的通用寄存器的高位,并且保持低位不变。

      继续上例,此时loadaddr_align4,所以从地址4处加载一个字,对应的是地址为4567的字节,因为n等于1,所以将加载到的字的最低3个字节保存到地址rt的通用寄存器的高3个字节。如图9-7所示。一个更加通用的描述如图9-8所示。

自己动手写CPU之第九阶段(2)加载存储指令说明2(lwl、lwr
  •  当指令中的指令码为6'b100110时,是lwr指令,非对齐加载指令,向右加载

      指令用法为:lwr rt, offset(base)

      指令作用为:从内存中指定的加载地址处,加载一个字的最低有效部分。还是假设计算出来的加载地址是loadaddrloadaddr的最低两位的值为n,将loadaddr最低两位设为0后的值称为loadaddr_align,如下。

加载地址loadaddr = signed_extended(offset) + GPR[base]

n = loadaddr[1:0]

loadaddr_align = loadaddr – n

      例如:假设计算出来的加载地址是9lwr指令要从地址9加载数据,那么loadaddr就等于9n等于1loadaddr_align等于8

      lwr指令的作用是从地址为loadaddr_align处加载一个字,也就是4个字节,然后将这个字的最高n+1个字节保存到地址为rt的通用寄存器的低位,并且保持高位不变。

      继续上例,此时loadaddr_align8,所以从地址8处加载一个字,对应的是地址为891011的字节,因为n等于1,所以将加载到的字的最高2个字节保存到地址rt的通用寄存器的低2个字节。如图9-9所示。一个更加通用的描述如图9-10所示。

自己动手写CPU之第九阶段(2)加载存储指令说明2(lwl、lwr

      lwllwr指令配合可以实现从一个非对齐地址加载一个字,而且只需要使用2条指令,提高了效率。例如:使用一般指令从地址7处加载一个字,那么可以使用以下代码实现,共5条指令。

lw  $1, 4($0)          # 取得地址0x4处的字,保存在$1中
lw  $2, 8($0)          # 取得地址0x8处的字,保存在$2中
sll $1, $1, 24         # $1左移24位
slr $2, $2, 8          # $2右移8位
or  $1, $1, $2         # $1与$2进行逻辑“或”运算,得到最终结果
Copy after login

      而有了lwllwr指令后,只需要2条指令即可。如下,图9-11是对这个过程的描述。

lwl $1, 7($0)
lwr $1,10($0)
Copy after login
自己动手写CPU之第九阶段(2)加载存储指令说明2(lwl、lwr


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to get items using commands in Terraria? -How to collect items in Terraria? How to get items using commands in Terraria? -How to collect items in Terraria? Mar 19, 2024 am 08:13 AM

How to get items using commands in Terraria? 1. What is the command to give items in Terraria? In the Terraria game, giving command to items is a very practical function. Through this command, players can directly obtain the items they need without having to fight monsters or teleport to a certain location. This can greatly save time, improve the efficiency of the game, and allow players to focus more on exploring and building the world. Overall, this feature makes the gaming experience smoother and more enjoyable. 2. How to use Terraria to give item commands 1. Open the game and enter the game interface. 2. Press the "Enter" key on the keyboard to open the chat window. 3. Enter the command format in the chat window: "/give[player name][item ID][item quantity]".

The operation process of WIN10 service host occupying too much CPU The operation process of WIN10 service host occupying too much CPU Mar 27, 2024 pm 02:41 PM

1. First, we right-click the blank space of the taskbar and select the [Task Manager] option, or right-click the start logo, and then select the [Task Manager] option. 2. In the opened Task Manager interface, we click the [Services] tab on the far right. 3. In the opened [Service] tab, click the [Open Service] option below. 4. In the [Services] window that opens, right-click the [InternetConnectionSharing(ICS)] service, and then select the [Properties] option. 5. In the properties window that opens, change [Open with] to [Disabled], click [Apply] and then click [OK]. 6. Click the start logo, then click the shutdown button, select [Restart], and complete the computer restart.

144-core, 3D-stacked SRAM: Fujitsu details next-generation data center processor MONAKA 144-core, 3D-stacked SRAM: Fujitsu details next-generation data center processor MONAKA Jul 29, 2024 am 11:40 AM

According to news from this website on July 28, foreign media TechRader reported that Fujitsu introduced in detail the FUJITSU-MONAKA (hereinafter referred to as MONAKA) processor planned to be shipped in 2027. MONAKACPU is based on the "cloud native 3D many-core" architecture and adopts the Arm instruction set. It is oriented to the data center, edge and telecommunications fields. It is suitable for AI computing and can realize mainframe-level RAS1. Fujitsu said that MONAKA will achieve a leap in energy efficiency and performance: thanks to technologies such as ultra-low voltage (ULV) technology, the CPU can achieve 2 times the energy efficiency of competing products in 2027, and cooling does not require water cooling; in addition, the application performance of the processor It can also reach twice as much as your opponent. In terms of instructions, MONAKA is equipped with vector

Leak reveals key specs of Intel Arrow Lake-U, -H, -HX and -S Leak reveals key specs of Intel Arrow Lake-U, -H, -HX and -S Jun 15, 2024 pm 09:49 PM

IntelArrowLakeisexpectedtobebasedonthesameprocessorarchitectureasLunarLake,meaningthatIntel'sbrandnewLionCoveperformancecoreswillbecombinedwiththeeconomicalSkymontefficiencycores.WhileLunarLakeisonlyavailableasava

AM4 refuses to die, news says AMD will launch Ryzen 9 5900XT/7 5800XT: clocked at up to 4.8GHz AM4 refuses to die, news says AMD will launch Ryzen 9 5900XT/7 5800XT: clocked at up to 4.8GHz Jun 05, 2024 pm 09:43 PM

According to news from this website on June 1st, the source @CodeCommando tweeted today, sharing some screenshots of AMD’s upcoming presentation documents at the Computex2024 event. The content of the tweet was “AM4 will never die”, and the accompanying picture showed two new Ryzen5000XT series processors. The screenshots show the following two products: Ryzen 95900 Ryzen75800XT It is a faster variant of AMD's existing Ryzen75800X processor. Both processors are clocked up to 4.8G

Huawei will launch innovative MED storage products next year: rack capacity exceeds 10 PB and power consumption is less than 2 kW Huawei will launch innovative MED storage products next year: rack capacity exceeds 10 PB and power consumption is less than 2 kW Mar 07, 2024 pm 10:43 PM

This website reported on March 7 that Dr. Zhou Yuefeng, President of Huawei's Data Storage Product Line, recently attended the MWC2024 conference and specifically demonstrated the new generation OceanStorArctic magnetoelectric storage solution designed for warm data (WarmData) and cold data (ColdData). Zhou Yuefeng, President of Huawei's data storage product line, released a series of innovative solutions. Image source: Huawei's official press release attached to this site is as follows: The cost of this solution is 20% lower than that of magnetic tape, and its power consumption is 90% lower than that of hard disks. According to foreign technology media blocksandfiles, a Huawei spokesperson also revealed information about the magnetoelectric storage solution: Huawei's magnetoelectronic disk (MED) is a major innovation in magnetic storage media. First generation ME

Stremio subtitles not working; error loading subtitles Stremio subtitles not working; error loading subtitles Feb 24, 2024 am 09:50 AM

Subtitles not working on Stremio on your Windows PC? Some Stremio users reported that subtitles were not displayed in the videos. Many users reported encountering an error message that said "Error loading subtitles." Here is the full error message that appears with this error: An error occurred while loading subtitles Failed to load subtitles: This could be a problem with the plugin you are using or your network. As the error message says, it could be your internet connection that is causing the error. So please check your network connection and make sure your internet is working properly. Apart from this, there could be other reasons behind this error, including conflicting subtitles add-on, unsupported subtitles for specific video content, and outdated Stremio app. like

The perfect solution to the problem of high CPU usage in Chrome browser The perfect solution to the problem of high CPU usage in Chrome browser Mar 14, 2024 pm 12:25 PM

When the computer is running, some users find that Google Chrome in the task manager occupies a very high CPU. If it is not processed in time, the computer will become more and more stuck, and even crash. So how to deal with the high CPU usage of Chrome browser? Let’s take a look at this issue together. High CPU usage issues in Google Chrome are usually due to "SoftwareReporterTool" running abnormally in Task Manager. This tool is actually a Chrome browser cleaning tool, used to clean up unnecessary or harmful extensions, applications or homepage hijackers. When Chrome is installed, Software_reporter_tool.exe is also downloaded to SwR

See all articles