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

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 匯編入門學(xué)習(xí)筆記 (十四)—— 直接定址表

          匯編入門學(xué)習(xí)筆記 (十四)—— 直接定址表

          作者: 時(shí)間:2016-11-09 來(lái)源:網(wǎng)絡(luò) 收藏
          瘋狂的暑假學(xué)習(xí)之 匯編入門學(xué)習(xí)筆記 (十四)—— 直接定址表

          本文引用地址:http://www.ex-cimer.com/article/201611/317787.htm

          參考: 《匯編語(yǔ)言》 王爽 第16章

          1. 描述單元長(zhǎng)度的標(biāo)號(hào)

          普通的標(biāo)號(hào):a,b

          1. assumecs:code
          2. codesegment
          3. a:db1,2,3,4,5,6,7,8
          4. b:dw0
          5. start:
          6. movsi,offseta
          7. movdi,offsetb
          8. movah,0
          9. movcx,8
          10. s:
          11. moval,cs:[si]
          12. addcs:[di],ax
          13. incsi
          14. loops
          15. movax,4c00h
          16. int21h
          17. movax,4c00h
          18. int21h
          19. codeends
          20. endstart

          仔細(xì)看一下,下面代碼的標(biāo)號(hào)的不同。下面的標(biāo)號(hào)a、b后面沒(méi)有冒號(hào)。它們是可以描述單元長(zhǎng)度的標(biāo)號(hào)。又叫數(shù)據(jù)標(biāo)號(hào)

          1. assumecs:code
          2. codesegment
          3. adb1,2,3,4,5,6,7,8
          4. bdw0
          5. start:
          6. movsi,offseta
          7. movah,0
          8. movcx,8
          9. s:
          10. moval,a[si]
          11. addb,ax
          12. incsi
          13. loops
          14. movax,4c00h
          15. int21h
          16. movax,4c00h
          17. int21h
          18. codeends
          19. endstart

          我們可以:

          mov ax,bx 相當(dāng)于 mov ax,cs:[8]

          mov b,2 相當(dāng)于 mov word ptr cs:[8],2

          inc b 相當(dāng)于inc word ptr cs:[8]

          mov al,a[si]相當(dāng)于 mov al,cs:0[si]

          mov al,a[3] 相當(dāng)于mov al,cs:0[3]

          但是下面的是錯(cuò)的

          mov al,b 因?yàn)閎是dw,字型的

          add b,al

          2. 在其他段中使用數(shù)據(jù)標(biāo)號(hào)

          普通的后面帶有“:”的標(biāo)號(hào),是只能定義在代碼段的。數(shù)據(jù)標(biāo)號(hào)可以用在其他段中。

          例子:注意如果想把ds:b 直接寫成 b,就必須在assume 后加上 cs:data

          1. assumecs:code,ds:data
          2. datasegment
          3. adb1,2,3,4,5,6,7,8
          4. bdw0
          5. dataends
          6. codesegment
          7. start:
          8. movax,data
          9. movds,ax
          10. movsi,offseta
          11. movah,0
          12. movcx,8
          13. s:
          14. moval,a[si]
          15. addb,ax
          16. incsi
          17. loops
          18. movax,4c00h
          19. int21h
          20. movax,4c00h
          21. int21h
          22. codeends
          23. endstart

          3. 直接定址表

          我們可以建一個(gè)表,用查表的方式來(lái)大大加快處理速度。

          例子:在屏幕顯示對(duì)應(yīng)16進(jìn)制數(shù)字的字符。這里字符就用來(lái)一個(gè)表。

          1. assumecs:code
          2. codesegment
          3. start:
          4. moval,0eh
          5. callshowbyte
          6. movax,4c00h
          7. int21h
          8. showbyte:
          9. jmpshortshow
          10. tabledb0123456789ABCDE;字符表
          11. show:
          12. pushbx
          13. pushes
          14. movah,al
          15. shrah,1;右移4位,ah中保存高4位,al中保存第4位
          16. shrah,1
          17. shrah,1
          18. shrah,1
          19. andal,00001111b
          20. movbl,ah
          21. movbh,0
          22. movah,table[bx]
          23. movbx,0b800h
          24. moves,bx
          25. moves:[160*12+40*2],ah
          26. movbl,al
          27. movbh,0
          28. moval,table[bx]
          29. moves:[160*12+40*2+2],al
          30. popes
          31. popbx
          32. ret
          33. codeends
          34. endstart

          我們還可以在直接定址表中存儲(chǔ)子程序的地址,從而方便的實(shí)現(xiàn)不同子程序的調(diào)用。



          關(guān)鍵詞: 匯編入門直接定址

          評(píng)論


          技術(shù)專區(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); })();