Friday, April 13, 2012

Sorting numbers in ascending oreder (signed) using 8086 in assembly language

assume cs:code,ds:data
data segment
org 2000h
series db 81h,82h,93h,95h,10h,56h,33h,99h,13h,44h
count dw 10d
data ends
code segment
start:mov ax,data
mov ds,ax
mov dx,count
dec dx
go:mov cx,dx
lea si,series
nxt_byte:mov al,[si]
cmp al,[si+1]
jl next
xchg al,[si+1]
xchg al,[si]
next:inc si
loop nxt_byte
dec dx
jnz go
mov ah,4ch
int 21h
code ends
end start

1 comment:

  1. Sort array of ten numbers without procedures..
    Rgrds

    START:
    MOV CX,9
    LEA SI,ARRAY

    LABEL2:
    MOV AL,[SI]
    CMP AL,[SI+1]
    JLE LABEL1
    MOV AH,[SI+1]
    MOV B.[SI],AH
    MOV B.[SI+1],AL
    JMP START

    LABEL1:
    INC SI
    LOOP LABEL2

    RET
    ARRAY DB 10,9,1,2,5,4,7,6,3,8

    ReplyDelete

DC motor control with Pulse Width Modulation Part 1

DC Motor intro DC motor is a device which converts electrical energy into kinetic energy. It converts the DC power into movement. The typica...