檢測點16.1

來源:互聯網
上載者:User

下面的程式中將codesg段的8個資料累加,結果儲存到b處的雙位元組中,補全程式。
assume cs:codesg<br />codesg segment<br /> a dw 1,2,3,4,5,6,7,8<br /> b dd 0 </p><p> start:<br /> mov si,0<br /> mov cx,8<br /> s:<br /> mov ax,__(1)___<br /> add ___(2)___,ax<br /> adc ___(3)___,0<br /> add si,___(4)___<br /> loop s </p><p> mov ax,4c00h<br /> int 21h </p><p>codesg ends<br />end start

解析:在開始之前,一定要看清楚了在定義a、b時,它們的後面並沒有冒號。這一點很關鍵,我就是沒有注意到這一點,導致偵錯工具的時候,用a[si]取得的值並不正確,本來應該是在地址cs:a[si]取得的,但是如果有冒號的話,它則是從地址ds:a[si]取得。所以看書還是要小心仔細啊。接下來的事情就是順利成章了:
(1)處是要填寫a[si]用以取得在a處定義的資料
(2)處時要填寫b[0],因為相加的另一個資料時ax。所以在b[0]前要有word ptr 的限制
(3)與(2)同樣的道理,填寫word ptr b[2]
(4)處要填寫2,應為a處定義的是字。所以加2
原始碼:
assume cs:codesg<br />codesg segment<br /> a db 1,2,3,4,5,6,7,8<br /> b dw 0 </p><p> start: </p><p> mov si,0<br /> mov cx,8 </p><p> s:<br /> mov al,a[si]<br /> mov ah,0<br /> add b,ax<br /> inc si<br /> loop s </p><p> mov ax,4c00h<br /> int 21h </p><p>codesg ends<br />end start

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.