0

変数に値を代入しています

ar db 107,106,105,104,103,102,101,100,99,98

また、文字列を実行しません

msg db "this is not printed by tasm ","$"

これは emu8086 エミュレータで実行されます 実際のコード

バブルソート

data segment
ar db 107,106,105,104,103,102,101,100,99,98
ends


code segment
 start:
assume cs:code,ds:data
mov ax, data
mov ds, ax
mov es, ax



mov cl,00h
   lb1:
mov ch,09h
sub ch,cl
mov si,0
lb2:
    mov dl,ar[si]
    mov dh,ar[si+1]
    cmp dl,dh
    jle finish
    mov ar[si],dh
    mov ar[si+1],dl
finish:
    inc si
    dec ch
    cmp ch,00
    jg lb2
inc cl
cmp cl,09h
jl lb1


mov cx,10
mov si,0
  lb3:
mov dl,ar[si]
mov ah,02h
int 21h

inc si
loop lb3

mov ax, 4c00h 
int 21h    
ends

end start 

それでは、何が問題なのですか。これを特定できません。サポートに感謝します。結果が必要です。怠惰にならないでください。

4

1 に答える 1

0

.model small .stack .data .code org 5000h

buff db 256 dup(?)

開始:mov ah、3fh; 標準入力から文字列を読み取るxorbx、bx
mov dx、offset buff mov cx、size buff int 21h jnc okay ret

大丈夫:mov bx、offset buff
sub al、2; CRLF push ax cmp al、2を無視します。2つ以上の文字?jbソート

add   ax, bx
dec   ax
mov   cx, ax            ; cx - ptr. to the last element
inc   bx                ; starting with the second element

for1:mov si、cx; 内側のループは常に最後の要素から始まりますmovdl、1; dlは「ソート済み」フラグとして使用されます

for2:mov ax、[si-1]; 2文字のcmpalを取得します、ああ; それらは順番にありますか?jbe cool xor dl、dl; いいえ、「ソートされた」フラグをリセットしますmov [si --1]、ah; ...そして値を交換しますmov[si]、al

かっこいい:dec si; わかりました、内側のループはsi <bx cmp si、bxjaefor2まで続きます

test  dl, dl            ; some exchanges occured ?
jne   sorted            ; nope - then the array is sorted

inc   bx                ; the outer loop continues till
cmp   bx, cx            ; bx goes past the last element in array ...
jbe   for1

ソート済み:pop cx; 結果を標準出力xorbx、bx mov ah、40h inc bx mov dx、offset buffint21hに書き込みます

ret

終了開始

于 2010-07-06T04:56:14.083 に答える