How do i print a unsigned array of numbers in assembly?

Question!

this is my code:

    .model  small
.stack   100h
.data
    A db 2,-5,3,4,-8
    N equ 5 

.code
    mov ax, @data
    mov ds, ax

    mov si,offset A
    mov cl,1

start:  
    cmp cl,N
    je sof

    mov al,[si]
    cmp al,[si+1]
    jg change
    jmp next

change:
    mov ah,al
    mov al,[si+1]
    mov [si],ah
    mov [si+1],al
    jmp next

next:
    inc si
    inc cl
    jmp start

sof:
    mov ah,9
    mov cx, offset A
    int 21h


.exit
end

i get a weird out put a lot of weird characters :/

By : Ilan Arba


Answers

You need to add 30h to a number in range 0 through 9 in order to display an ascii character. To display a character, use

                                ;al = digit to display
        mov     dl,al
        add     dl,030h
        mov     ah,02           ;display character (in dl)
        int     21h
By : rcgldr


This video can help you solving your question :)
By: admin