assembly - Why does my code display rubbish? -
my code display rubbish when want print each of numbers in list well, wrong? output should this:
the given array is:2g;4?pt why rubbish
total number is:7
code
assume cs:code , ds : data, ss: stk org 0000h data segment list db 2,23,11,4,15,32,"$" ; given array last element $ indicate end message1 db "the given array is:$" ;message 1 message2 db "the total number is:$" ;message 2 data ends ;stack segment stk segment stack db 512 dup (?) tos label word stk ends ; code segment code segment org 2000h start : mov dx, data mov ds, dx mov dx, stk mov ss, dx mov sp, offset tos xor ax, ax ; clear register xor bx, bx ; initialise index register lea dx, message1 mov ah, 9h int 21h lea si , list mov cl,0 mov al,"$" again: cmp al,[si] ; end of list je on mov dl, list[bx] ; move array numbers add dx, 30h ; convert number character. mov ah, 2 ;display number @ screen int 21h inc si inc bx inc cl jmp again over: lea dx, message2 mov ah, 9h int 21h push cx ; transfer cl dl int21/ah=2. pop dx add dx, 30h ; convert number character. mov ah, 02h ; prints character in dl. int 21h mov ah, 4ch ; exit. int 21h code ends end start
i think knew why whatever number greater 10 display character, how let display in number "13" dont display "="?
list db 2,23,11,4,15,32,"$"
you not realizing values on 9 consists of more 1 numeral. that's why values 2 , 4 come out correct; display "2nd" , "4th" number characters, there no character number 23. need display number 2 and 3.
what need proper int string function output values ascii.
Comments
Post a Comment