madmardigan53
Technical User
I have written a function that allows a user to input an integer in base CX that is stored in DX.
When I compile the following program, which is supposed to accept a number and display it using a successful function, with NGASM, the console's behavior is unpredictable after the entry of the number.
What is the problem?
Code:
;i:cx=base
;o:dx=number
;m:ax,bx,dx
inumber:
xor dx,dx
mov bx,1
mov ax,030
push ax
inum:
mov ah,1
int 021
cmp al,0d
je crfound
push ax
call inum
crfound:
pop ax
xor ah,ah
sub al,030
push dx
mul bx
pop dx
add dx,ax
mov ax,bx
mul cx
mov bx,ax
ret
Code:
mov cx,0a
call inumber
push dx
mov dl,0a
mov ah,2
int 021
pop ax
call disp_num
int 020
include func.asm
include routines.asm
Code:
;i:ax=number,cx=base
;o:none
;m:ax,dx
DISP_NUM:
XOR DX,DX
DIV CX
;---------
PUSH DX
;---------
OR AX,AX
JZ dn_done
CALL disp_num
DN_DONE:
;---------
POP DX
;---------
ADD DL,30h
MOV AH,2
INT 21h
RET