史萊姆論壇

史萊姆論壇 (http://forum.slime.com.tw/)
-   程式語言討論區 (http://forum.slime.com.tw/f76.html)
-   -   組何語言新手作業_ (http://forum.slime.com.tw/thread287278.html)

alanniok 2017-04-15 02:54 PM

組何語言新手作業_
 
小弟這學期剛開始學組合語言,結果第一次作業就讓我好頭大啦,所以來這邊求幫忙了QQ

這是其中一題的題目:
Write a program with a loop and addressing that exchanges every pair of values in an array with an even number of elements. Therefore, item i will exchange with i+1, and item i+2 will exchange with item i+3, and so on.

然後以下是我目前的程式碼:

TITLE 4_10_2 (4_10_2.asm)

; This program is homework1 4_10_2

INCLUDE Irvine32.inc

.data
array BYTE 00h, 11h, 22h, 33h, 44h, 55h, 66h, 77h, 88h, 99h

.code
main PROC
mov ecx, lengthof array

L1:
mov al, [array+ecx-1]
xchg al, [array+ecx-2]
mov [array+ecx-1], al
sub ecx, 1
loop L1

exit
main ENDP
END main

--------------------------------------------------------------------------------------

我的問題是我不知道該如何把array輸出到螢幕上.... 還有不知道我這樣寫有沒有符合題目的要求??

mini 2017-04-15 09:14 PM

一般是使用
MOV DX, 文字內容
MOV AH, 09H
INT 21H

來將 文字內容 內容輸出至螢幕
例如:
文字內容 DB 00h, 11h, 22h, 33h, 44h, 55h, 66h, 77h, 88h, 99h, '$'
最後加個字元 $ 來告知字串結束
以上是最後一次性的 列印方式
如果是要列印每次(一圈loop)的執行結果
那請自行理解 int 21h的用法

與組合語言脫節太久了 (要看懂已經很勉強了,所以要寫出能運行就...)


所有時間均為台北時間。現在的時間是 08:19 AM

Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2024, Jelsoft Enterprises Ltd.

『服務條款』

* 有問題不知道該怎麼解決嗎?請聯絡本站的系統管理員 *


SEO by vBSEO 3.6.1