;a factorial program with a key piece missing.
; can you find: how to print a message to the screen
;how to "declare a variable"
;where to declare a variable
;how to read in
a char and convert to a digit
;how does multiply work? (mul)
;can you find the loop?
;how do you increment a value in assembly?
;exercise: write the program in c and compare...
;what piece is missing?
.model small
.stack 100h
.data
factval dw ?
fact dw 1
prompt db 'enter a value
between 1 and 9' ,0ah,0dh,'$'
input db ' was input*',10,13,'$'
output db ' is the answer',0ah,0dh,'$'
.code
INCLUDE decout.asm
factorial:
mov ax, @data
mov ds,ax
&nbs
p; mov ah,9
;put message on screen
mov dx, offset prompt
int 21h
mov ah,1  
;
;get int value
int 21h
and al, 0Fh
;preserve digit part
xor ah,ah
mov cx,ax
;store this
digit in CX
mov ax,1
looptop:
mul [fact]
inc [fact]
loop looptop
mov [factval],ax
;save factorial
mov dx, offset input
mov ah,9
int 21h
call dec_out
mov dx, offset output
mov ah,9
int 21h
mov ah,4ch
;terminate sequence
int 21h
END facto
rial
END