Start of TRIGOL Compiler for a Program P7.tri at Tue Sep 18 11:55:38 2001


Program

# READ a
READ b
READ c
F:=((a*(b+(2*c)))/2)
WRITE F#

Parsing tree

root
READ
a
READ
b
READ
c
:=
F/
*
a+
b*
2c
2
WRITE
F

Table of constants
c1=2

Table of identifiers
i1=ai2=bi3=ci4=Fi5=DUMMY

Modified tree:

root
READ
a
READ
b
READ
c
:=
F/
*
a+
b*
2c
2
WRITE
F


Compiler to Assembler started

; gen_header: source text
; # READ a ; READ b ; READ c ;
; F := a * ( b + ( 2 * c ) ) / 2 ;
; WRITE F #
;
; Program P7.asm
	.MODEL	small
	.STACK	100h
; gen_header: Rd=1 Wr=1
EXTRN readint:PROC EXTRN bin2dec:PROC ; gen_header: # of identifiers=5
.DATA a DW 0 b DW 0 c DW 0 F DW 0 DUMMY DW 0 dTv0 DW 0 ; gen_header: generate I/O-text
Sisse DB 'Input the variable ','$' Trykk DB 'Variable ','$' a_S DB 'a=','$' b_S DB 'b=','$' c_S DB 'c=','$' F_S DB 'F=','$' ; gen_header: code segment'll start
.CODE ProgramStart: mov ax,@data mov ds,ax
Stacka
;compiling the operator READ a
READ
a
READ
b
READ
c
:=
F/
*
a+
b*
2c
2
WRITE
F
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 a_S int 21h call readint mov a,ax
Stack

Stackb
;compiling the operator READ b
READ
b
READ
c
:=
F/
*
a+
b*
2c
2
WRITE
F
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 b_S int 21h call readint mov b,ax
Stack

Stackc
;compiling the operator READ c
READ
c
:=
F/
*
a+
b*
2c
2
WRITE
F
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 c_S int 21h call readint mov c,ax
Stack

StackF

StackFa

StackFab

StackFab2

StackFab2c
;compiling the operator (2*c)
*
2c
mov ax,2 mov dx,c mul dx mov dTv0,ax ;compiling the operator (b+(2*c))
+
b*
2c
mov ax,b add ax,dTv0 mov dTv0,ax ;compiling the operator (a*(b+(2*c)))
*
a+
b*
2c
2
mov ax,a mov dx,dTv0 mul dx mov dTv0,ax
StackFtm2
;compiling the operator ((a*(b+(2*c)))/2)
/
*
a+
b*
2c
2
mov ax,dTv0 mov dl,2 div dl mov dTv0,ax ;compiling the operator F:=((a*(b+(2*c)))/2)
:=
F/
*
a+
b*
2c
2
WRITE
F
mov ax,dTv0 mov F,ax
Stack

StackF
;compiling the operator WRITE F
WRITE
F
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
Stack
mov ah,4ch int 21h END ProgramStart programm P7.asm is compiled

I'll start compiler from assembler, and linker

tasm P7 >>P7c.htm
Turbo Assembler Version 3.1 Copyright (c) 1988, 1992 Borland International Assembling file: P7.ASM Error messages: None Warning messages: None Passes: 1 Remaining memory: 460k
tlink P7+teek >>P7c.htm
Turbo Link Version 2.0 Copyright (c) 1987, 1988 Borland International

Compiler ended at Tue Sep 18 11:55:40 2001