The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: arul on February 27, 2009, 02:18:53 PM

Title: "how to give input to the foll prog"
Post by: arul on February 27, 2009, 02:18:53 PM
pls tell me how to give user input after we link,debug.  what to do after debug . after debugging I am getting a message access denied. I am using MASM1.5.
the foll is the code I got from internet
 

;Factorial - factorial.asm
;This sample gets the number from the user, and calculates factorial for it. Supported input from 0 to 8 inclusive!


   
; factorial.asm

; this example gets the number from the user,
; and calculates factorial for it.
; supported input from 0 to 8 inclusive!

name "fact"

; this macro prints a char in AL and advances
; the current cursor position:
putc    macro   char
        push    ax
        mov     al, char
        mov     ah, 0eh
        int     10h
        pop     ax
endm



org     100h

jmp start


result dw ?



start:

; get first number:

mov dx, offset msg1
mov ah, 9
int 21h
jmp n1
msg1 db 0Dh,0Ah, 'enter the number: $'
n1:

call    scan_num


; factorial of 0 = 1:
mov     ax, 1
cmp     cx, 0
je      print_result

; move the number to bx:
; cx will be a counter:

mov     bx, cx

mov     ax, 1
mov     bx, 1

calc_it:
mul     bx
cmp     dx, 0
jne     overflow
inc     bx
loop    calc_it

mov result, ax


print_result:

; print result in ax:
mov dx, offset msg2
mov ah, 9
int 21h
jmp n2
msg2 db 0Dh,0Ah, 'factorial: $'
n2:


mov     ax, result
call    print_num_uns
jmp     exit


overflow:
mov dx, offset msg3
mov ah, 9
int 21h
jmp n3
msg3 db 0Dh,0Ah, 'the result is too big!', 0Dh,0Ah, 'use values from 0 to 8.$'
n3:
jmp     start

exit:

; wait for any key press:
mov ah, 0
int 16h

ret

Title: Re: "how to give input to the foll prog"
Post by: FORTRANS on February 27, 2009, 02:40:27 PM
Hi,

   You have

call    scan_num

and there is no scan_num routine defined.

Steve N.
Title: Re: "how to give input to the foll prog"
Post by: arul on February 27, 2009, 02:49:58 PM
dear sir,
I am just a beginner in masm I cant understand wat u said, my question is should I give input in cmd if so how can I give.
Title: Re: "how to give input to the foll prog"
Post by: arul on February 27, 2009, 02:53:27 PM
Dear sir,
where in code to define scan_num
Title: Re: "how to give input to the foll prog"
Post by: Farabi on March 07, 2009, 03:49:08 AM
Quote from: arul on February 27, 2009, 02:53:27 PM
Dear sir,
where in code to define scan_num
You have to make it on your own, or ask your teacher to do it.