loops - Why is my ASM (using Turbo Assembler) program looping infinitely? -


i tried make small program accepts 4 digit number. reason doesn't stop after entering 4th digit.

this concept using.

a 4 digit number example 1234 "1000+200+30+4"
when enter 1234 in program happens:

1 bx = 0000 0000 0000 0000      2.1 bx = bx + 1000      3.1 bx = bx + 100 3.2 bx = bx + 100  4.1 bx = bx + 10 4.2 bx = bx + 10 4.3 bx = bx + 10      5.1 bx = bx + 1 5.2 bx = bx + 1 5.3 bx = bx + 1 5.4 bx = bx + 1     

so bx = 0000 0000 0000 1234
following program goes infinite loop. can me out problem.

;===========macros========== ;-----input macros input_bcd_sub macro digit         call common_inp_proc                 mov digit_place, digit         call num_convertor endm  input_bcd macro var         xor bx,bx         show t_msg2         input_bcd_sub 1000         input_bcd_sub 0100         input_bcd_sub 0010         input_bcd_sub 0001         mov var, bx         xor bx,bx endm  ;-----show macro show macro msg         mov ah, 09h         lea dx, msg         int 21h endm ;-----end: show macro  ;-----killme macro killme macro         mov ah, 4ch         int 21h endm ;-----end: killme macro  .model small .data         t_msg1 db 10,13,'enter number: $'         t_msg2 db 10,13,'you have entered: $'         err_msg db 10,13, 'an error has occured: invalid digit entered. please use     digits 0 9 $'         var_num1 dw 1 dup(0)         digit_place dw 1 dup(0) .code              common_inp_proc proc         mov ah, 01h         int 21h         cmp al, 30h             jb  err1         cmp al, 39h         jbe subt_30         err1: show err_msg               killme         subt_30: sub al, 30                 ret common_inp_proc endp  num_convertor proc         mov cl,al         count: add bx, digit_place                            loop count     num_convertor endp  main proc         mov ax, @data         mov ds, ax          show t_msg1         input_bcd var_num1         killme main endp end main 

i generated list file , looks fine. don't know problem is...

list file generated tasm

indeed, num_converter not having ret produce loop, , ch never initialised either, both correct. advice single-step sound. i'm posting answer can close issue no longer show on site.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -