<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > ARM 匯編與 C 語(yǔ)言相互調(diào)用實(shí)驗(yàn)

          ARM 匯編與 C 語(yǔ)言相互調(diào)用實(shí)驗(yàn)

          作者: 時(shí)間:2016-11-11 來(lái)源:網(wǎng)絡(luò) 收藏
          4. 7 匯編C 語(yǔ)言相互調(diào)用實(shí)驗(yàn)

          4. 7. 1 實(shí)驗(yàn)?zāi)康?/p>本文引用地址:http://www.ex-cimer.com/article/201611/316816.htm

          閱讀S3C2410 啟動(dòng)代碼,觀(guān)察處理器啟動(dòng)過(guò)程;

          學(xué)會(huì)使用 MDK 集成開(kāi)發(fā)環(huán)境輔助窗口來(lái)分析判斷調(diào)試過(guò)程和結(jié)果;

          學(xué)會(huì)在 MDK 集成開(kāi)發(fā)環(huán)境中編寫(xiě)、編譯與調(diào)試匯編和C 語(yǔ)言相互調(diào)用的程序。

          4. 7. 6 實(shí)驗(yàn)參考程序

          1.randtest.c 參考源代碼:

          /*********************************************************************************************
          * File: randtest.c

          * Author: Wuhan R&D Center, embest
          * Desc: Random number generator demo program

          * Calls assembler function randomnumber defined in random.s

          * History:

          *********************************************************************************************/

          /*------------------------------------------------------------------------------------------*/

          /* extern function */

          /*------------------------------------------------------------------------------------------*/

          extern unsigned int randomnumber( void );

          unsigned int unRandom[10];

          /*********************************************************************************************

          * name: main

          * func: c code entry

          * para: none

          * ret: none

          * modify:

          * comment:

          *********************************************************************************************/

          int __main()

          {

          unsigned int i,nTemp;

          for( i = 0; i < 10; i++ )

          {

          nTemp = randomnumber();

          unRandom[i] = nTemp;

          }

          while(1);

          }

          2.random.s 參考源代碼:

          ;#************************************************************************************************************
          ;# File: random.s *

          ;# Author: Wuhan R&D Center, embest *
          ;# Desc: Random number generator *

          ;# This uses a 33-bit feedback shift register to generate a pseudo-randomly *

          ;# ordered sequence of numbers which repeats in a cycle of length 2^33 - 1 *

          ;# NOTE: randomseed should not be set to 0, otherwise a zero will be generated *

          ;# continuously (not particularly random!). *

          ;# This is a good application of direct ARM assembler, because the 33-bit *

          ;# shift register can be implemented using RRX (which uses reg + carry). *

          ;# An ANSI C version would be less efficient as the compiler would not use RRX. *

          ;# AREA |Random$$code|, CODE, READONLY *

          ;# History: *

          ;#*************************************************************************************************************

          ;/*------------------------------------------------------------------------------------------*/

          ;/* global symbol define */

          ;/*------------------------------------------------------------------------------------------*/

          global randomnumber

          global seed

          ;/*------------------------------------------------------------------------------------------*/

          ;/* code */

          ;/*------------------------------------------------------------------------------------------*/

          AREA BLOCK, code , readonly

          EXPORT randomnumber

          randomnumber

          ;# on exit:

          ;# a1 = low 32-bits of pseudo-random number

          ;# a2 = high bit (if you want to know it)

          ldr ip, seedpointer

          基于S3C2410 嵌入式 MDK 開(kāi)發(fā)實(shí)驗(yàn)與實(shí)踐――EduKit 系列叢書(shū)
          Email:support@edukit.com.cn Tel:0755-25631365

          ldmia ip, {a1, a2}

          tst a2, a2, lsr #1 ;/* to bit into carry */

          movs a3, a1, rrx ;/* 33-bit rotate right */

          adc a2, a2, a2 ;/* carry into LSB of a2 */

          eor a3, a3, a1, lsl #12 ;/* (involved!) */

          eor a1, a3, a3, lsr #20 ;/* (similarly involved!) */

          stmia ip, {a1, a2}

          BX lr

          seedpointer

          DCD seed

          seed

          DCD 0x55555555

          DCD 0x55555555

          END



          評(píng)論


          技術(shù)專(zhuān)區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();