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 getchar
inc esi
cmp esi,count
jb