开发者

tasm not run predefined data in variable

I am assigning some value in a variable

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

and also not run string

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

but this is run on emu8086 emulator The actual code

The Bubble Sort

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


code segment
 sta开发者_开发问答rt:
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 

then what's the problem I can't identify this thanks for your support please I need the result don't be lazy


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

buff db 256 dup(?)

start: mov ah, 3fh ; reading a string from standard input xor bx, bx
mov dx, offset buff mov cx, size buff int 21h jnc okay ret

okay: mov bx, offset buff
sub al, 2 ; ignore the CRLF push ax cmp al, 2 ; two or more chars ? jb sorted

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 ; the inner loop always starts from the last element mov dl, 1 ; dl is used as the "sorted" flag

for2: mov ax, [si - 1] ; get two chars cmp al, ah ; are they in order ? jbe cool xor dl, dl ; no, then reset the "sorted" flag mov [si - 1], ah ; ... and exchange the values mov [si], al

cool: dec si ; ok, the inner loop continues until si < bx cmp si, bx jae for2

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

sorted: pop cx ; write the result at the standard output xor bx, bx mov ah, 40h inc bx mov dx, offset buff int 21h

ret

end start

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜