RISCV instructions












0














I am new to riscv and I am confused between la and lw.



I know that la stands for load address and lw stands for load word. If address of VAL is 0x100 and data value of VAL is 0x11 should x3 stores 0x100 and x4 stores 0x11?



la x7, VAL
sw x3, 0(x7)
lw x4, VAL
bne x4, x3









share|improve this question





























    0














    I am new to riscv and I am confused between la and lw.



    I know that la stands for load address and lw stands for load word. If address of VAL is 0x100 and data value of VAL is 0x11 should x3 stores 0x100 and x4 stores 0x11?



    la x7, VAL
    sw x3, 0(x7)
    lw x4, VAL
    bne x4, x3









    share|improve this question



























      0












      0








      0







      I am new to riscv and I am confused between la and lw.



      I know that la stands for load address and lw stands for load word. If address of VAL is 0x100 and data value of VAL is 0x11 should x3 stores 0x100 and x4 stores 0x11?



      la x7, VAL
      sw x3, 0(x7)
      lw x4, VAL
      bne x4, x3









      share|improve this question















      I am new to riscv and I am confused between la and lw.



      I know that la stands for load address and lw stands for load word. If address of VAL is 0x100 and data value of VAL is 0x11 should x3 stores 0x100 and x4 stores 0x11?



      la x7, VAL
      sw x3, 0(x7)
      lw x4, VAL
      bne x4, x3






      riscv






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 at 10:37









      FabienM

      1,076725




      1,076725










      asked Nov 21 at 5:17









      YoungBin Jo

      92




      92
























          1 Answer
          1






          active

          oldest

          votes


















          1














          la computes an pointer-sized effective address, but does not perform any memory access.  The effective address itself is what is loaded into x7.



          (Also note that la is a pseudo instruction that may expand into two instructions, depending on VAL — none the less, the sequence computes an effective address and that is its result (no memory access is performed).)



          lw also computes an effective address; however, it uses the effective address in a word-sized memory access, and the result of that memory access is the value loaded into x4.



          lb would do the same as lw except that the memory access is byte-sized.





          As far as your code sequence goes, the value that was in x3 (which cannot be determined from your code snippet) will be stored into memory at locations 0x100-0x103 (this is a word-sized store).



          The lw will reload the value that was written by the sw.  (Note that the lw in this case may also expand to multiple instructions depending on VAL, whereas the sw is a single instruction regardless of VAL.)



          The bne (though missing a target label) will not branch.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405655%2friscv-instructions%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            la computes an pointer-sized effective address, but does not perform any memory access.  The effective address itself is what is loaded into x7.



            (Also note that la is a pseudo instruction that may expand into two instructions, depending on VAL — none the less, the sequence computes an effective address and that is its result (no memory access is performed).)



            lw also computes an effective address; however, it uses the effective address in a word-sized memory access, and the result of that memory access is the value loaded into x4.



            lb would do the same as lw except that the memory access is byte-sized.





            As far as your code sequence goes, the value that was in x3 (which cannot be determined from your code snippet) will be stored into memory at locations 0x100-0x103 (this is a word-sized store).



            The lw will reload the value that was written by the sw.  (Note that the lw in this case may also expand to multiple instructions depending on VAL, whereas the sw is a single instruction regardless of VAL.)



            The bne (though missing a target label) will not branch.






            share|improve this answer


























              1














              la computes an pointer-sized effective address, but does not perform any memory access.  The effective address itself is what is loaded into x7.



              (Also note that la is a pseudo instruction that may expand into two instructions, depending on VAL — none the less, the sequence computes an effective address and that is its result (no memory access is performed).)



              lw also computes an effective address; however, it uses the effective address in a word-sized memory access, and the result of that memory access is the value loaded into x4.



              lb would do the same as lw except that the memory access is byte-sized.





              As far as your code sequence goes, the value that was in x3 (which cannot be determined from your code snippet) will be stored into memory at locations 0x100-0x103 (this is a word-sized store).



              The lw will reload the value that was written by the sw.  (Note that the lw in this case may also expand to multiple instructions depending on VAL, whereas the sw is a single instruction regardless of VAL.)



              The bne (though missing a target label) will not branch.






              share|improve this answer
























                1












                1








                1






                la computes an pointer-sized effective address, but does not perform any memory access.  The effective address itself is what is loaded into x7.



                (Also note that la is a pseudo instruction that may expand into two instructions, depending on VAL — none the less, the sequence computes an effective address and that is its result (no memory access is performed).)



                lw also computes an effective address; however, it uses the effective address in a word-sized memory access, and the result of that memory access is the value loaded into x4.



                lb would do the same as lw except that the memory access is byte-sized.





                As far as your code sequence goes, the value that was in x3 (which cannot be determined from your code snippet) will be stored into memory at locations 0x100-0x103 (this is a word-sized store).



                The lw will reload the value that was written by the sw.  (Note that the lw in this case may also expand to multiple instructions depending on VAL, whereas the sw is a single instruction regardless of VAL.)



                The bne (though missing a target label) will not branch.






                share|improve this answer












                la computes an pointer-sized effective address, but does not perform any memory access.  The effective address itself is what is loaded into x7.



                (Also note that la is a pseudo instruction that may expand into two instructions, depending on VAL — none the less, the sequence computes an effective address and that is its result (no memory access is performed).)



                lw also computes an effective address; however, it uses the effective address in a word-sized memory access, and the result of that memory access is the value loaded into x4.



                lb would do the same as lw except that the memory access is byte-sized.





                As far as your code sequence goes, the value that was in x3 (which cannot be determined from your code snippet) will be stored into memory at locations 0x100-0x103 (this is a word-sized store).



                The lw will reload the value that was written by the sw.  (Note that the lw in this case may also expand to multiple instructions depending on VAL, whereas the sw is a single instruction regardless of VAL.)



                The bne (though missing a target label) will not branch.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 22 at 16:26









                Erik Eidt

                2,41011723




                2,41011723






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405655%2friscv-instructions%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    404 Error Contact Form 7 ajax form submitting

                    How to know if a Active Directory user can login interactively

                    TypeError: fit_transform() missing 1 required positional argument: 'X'