; Program P5.asm
.MODEL small
.STACK 100h
; gen_header: Rd=1 Wr=1
EXTRN readint:PROC
EXTRN bin2dec:PROC
; gen_header: # of identifiers=3
.DATA
n DW 0
F DW 0
I DW 0
dTv0 DW 0
; gen_header: generate I/O-text
Sisse DB 'Input the variable ','$'
Trykk DB 'Variable ','$'
n_S DB 'n=','$'
F_S DB 'F=','$'
; gen_header: code segment'll start
.CODE
ProgramStart:
mov ax,@data
mov ds,ax
; compiling the operator READ n
READ | := | := | := | IF | := | GOTO | WRITE |
mov ah,9h
mov bx,1
mov cx,17
mov dx,OFFSET Sisse
int 21h
mov ah,9h
mov bx,1
mov cx,2
mov dx,OFFSET n_S
int 21h
call readint
mov n,ax
; compiling the operator F:=1
mov ax,1
mov F,ax
; compiling the operator I:=0
mov ax,0
mov I,ax
; compiling the operator (I+1)
M1: mov ax,I
add ax,1
; compiling the operator I:=(I+1)
mov I,ax
; compiling the operator (I>n)
mov ax,I
cmp ax,n
jg M2
; compiling the operator IF (I>n) THEN
; compiling the operator (F*I)
mov ax,F
mov dx,I
mul dx
; compiling the operator F:=(F*I)
mov F,ax
; compiling the operator M1:
; compiling the operator GOTO M1
jmp M1
; compiling the operator WRITE F
M2: mov ah,9h
mov bx,1
mov cx,8
mov dx,OFFSET Trykk
int 21h
mov ah,9h
mov bx,1
mov cx,2
mov dx,OFFSET F_S
int 21h
mov ax,F
mov dx,0
cmp ax,0
jg s1h2o3w
mov dx,1
s1h2o3w:
mov ch,1
call bin2dec
mov ah,4ch
int 21h
END ProgramStart
programm P5.asm is compiled
I'll start compiler from assembler, and linker
tasm P5 >>P5oc.htm
Turbo Assembler Version 3.1 Copyright (c) 1988, 1992 Borland International
Assembling file: P5.ASM
Error messages: None
Warning messages: None
Passes: 1
Remaining memory: 460k
tlink P5+teek >>P5oc.htm
Turbo Link Version 2.0 Copyright (c) 1987, 1988 Borland International
Compiler ended at
Fri Jun 01 15:19:49 2001