TITLE MASM sort (main.asm)
.686P ; Pentium Pro or later
.MODEL flat, stdcall
.STACK 4096
option casemap:none; 大小不敏感
printf PROTO C :dword,:vararg
scanf PROTO C :dword,:vararg
gets PROTO C :dword
getchar PROTO C
strlen PROTO C :dword
ExitProcess PROTO,dwExitCode:DWORD ; exit program
exit EQU <INVOKE ExitProcess,0>
INCLUDELIB C:\ASM\USER32.LIB
INCLUDELIB C:\ASM\KERNEL32.LIB
INCLUDELIB C:\ASM\MSVCRT.LIB
chr$ MACRO any_text:VARARG
LOCAL txtname
.data
txtname db any_text,0
align 4
.code
EXITM <OFFSET txtname>
ENDM
.data
arrayai sdword 100 dup(0)
count dword 0
.code
main PROC
getshu: invoke printf,chr$("请输入数组长度:",0Ah,0Dh)
invoke scanf, chr$("%d"),addr count
invoke getchar ;把scanf的回车换行清掉
cmp count,1
jb getshu
mov esi,0
jixu: invoke printf,chr$("请输入第 %d 个元素: "),esi
invoke scanf,chr$("%d"),addr arrayai[esi*4]
invoke getc
汇编语言实现冒泡排序
最新推荐文章于 2022-04-22 23:07:28 发布
这篇博客展示了如何用汇编语言(MASM)实现冒泡排序算法。首先,程序提示用户输入数组长度和各个元素,然后进行冒泡排序。排序完成后,将结果显示出来,显示从小到大排列的数组元素。
摘要由CSDN通过智能技术生成