Start of TRIGOL Optimizing Compiler for a Program P9.tri at Sun Jun 03 16:42:20 2001


Program

# READ a
y:=((a*3)+(a*2))
WRITE y#

Parsing tree

root
READ
a
:=
y+
*
a3
*
a2
WRITE
y

Table of constants
c1=3c2=2

Table of identifiers
i1=ai2=y

Modified tree:

root
READ
a
:=
y+
*
a3
*
a2
WRITE
y


Compiler to Assembler started

; gen_header: source text
; READ a ; y := ( a * 3 ) + ( a * 2 ) ; WRITE y
;
; Program P9.asm
	.MODEL	small
	.STACK	100h
; gen_header: Rd=1 Wr=1
EXTRN readint:PROC EXTRN bin2dec:PROC ; gen_header: # of identifiers=2
.DATA a DW 0 y DW 0 dTv0 DW 0 dTv1 DW 0 ; gen_header: generate I/O-text
Sisse DB 'Input the variable ','$' Trykk DB 'Variable ','$' a_S DB 'a=','$' y_S DB 'y=','$' ; gen_header: code segment'll start
.CODE ProgramStart: mov ax,@data mov ds,ax
Stacka
; compiling the operator READ a
READ
a
:=
y+
*
a3
*
a2
WRITE
y
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

Stacky

Stackya

Stackya3
; compiling the operator (a*3)
*
a3
*
a2
mov ax,a mov dx,3 mul dx mov dTv0,ax
Stackytma

Stackytma2
; compiling the operator (a*2)
*
a2
mov ax,a mov dx,2 mul dx mov dTv1,ax ; compiling the operator ((a*3)+(a*2))
+
*
a3
*
a2
mov ax,dTv0 add ax,dTv1 mov dTv0,ax ; compiling the operator y:=((a*3)+(a*2))
:=
y+
*
a3
*
a2
WRITE
y
mov ax,dTv0 mov y,ax
Stack

Stacky
; compiling the operator WRITE y
WRITE
y
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 y_S int 21h mov ax,y 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 P9.asm is compiled

I'll start compiler from assembler, and linker

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

Compiler ended at Sun Jun 03 16:42:21 2001