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
Hi,
You have
call scan_num
and there is no scan_num routine defined.
Steve N.
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.
Dear sir,
where in code to define scan_num
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.