用彙編寫乙個氣泡排序

2021-05-23 17:44:42 字數 783 閱讀 4888

datas segment

;此處輸入資料段** 

data1 db 16 dup (3h, 8h, 6h, 0h, 2h, 7h, 5h, 4h, 9h, 1h, 23h, 35h, 88h, 80h, 20h, 49h)

count dw $ - data1

datas ends

stacks segment

;此處輸入堆疊段**

stacks ends

codes segment

assume cs:codes,ds:datas,ss:stacks

start:

mov ax,datas

mov ds,ax

;此處輸入**段**   

mov cx, count   

sub cx, 1   

outter:

push cx

mov bx, 0

inner : mov al, data1[bx] 

cmp al, data1[bx+1] 

ja cg

jmp nextinner

cg : xchg al, data1[bx+1]

mov data1[bx], al

nextinner: inc bx

loop inner  

nextoutter: pop cx

loop outter   

mov ah,4ch

int 21h

codes ends

end start

ARM C語言呼叫彙編函式 實現氣泡排序

三 ads除錯 本程式的關鍵是如何使用組合語言實現氣泡排序演算法。可以仿照c語言的 流程,分步驟寫出彙編的 首先要寫出最內層的 部分,也就是資料交換的彙編 資料交換可以使用str資料裝載指令實現。之後要考慮內層迴圈的 可以通過cmp指令控制迴圈次數。最後是編寫最外層的迴圈 也是使用cmp指令,來控制...

學習筆記 用組合語言編寫乙個函式 實現兩個數相加

c函式 int add int nnuma,int nnumb int tmain int argc,tchar argv 組合語言實現 執行過程 執行前棧狀態 首先執行push 0x4 push 0x3 執行後棧中內容 再執行call 00415fd7 呼叫函式,並將返回位址入棧 執行後棧中內容 ...

第乙個ARM匯程式設計序 氣泡排序

area sort,code,readonly declare for code area entry entry for the whole code start main code flag mov r4,0 clear r4 ldr r6,src r6 point to the beginin...