[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

simple

Posted on 1999-11-08
15
Medium Priority
?
239 Views
Last Modified: 2010-05-02
can somebody send me a way of crating com files . I have writen my own programing language called simple and iwant some help in witing a compilier for it.
0
Comment
Question by:Marktalbot
  • 7
  • 6
  • 2
15 Comments
 
LVL 14

Expert Comment

by:mcrider
ID: 2191039
What is "simple" written in?
0
 
LVL 12

Expert Comment

by:mark2150
ID: 2191255
COM files are a simple RAM image with an offset of 0100H. You can create a .COM file in the debugger simply by writing your code starting at offset 0100H and then saving it to disk. You're limited to one, 64kb segment for your entire program.

To write a compiler you need to figure out what the appropriate assembly language steps are for each of your programming languages statements. Your compiler can almost be a macro editor where the ASM is substitued for your "source" on a 1:1 basis. Then you use MASM to compile the ASM into the actual 1's and 0's or you directly write your own binary into the .COM file.

Is not hard conceptually, but can be *tough* to get "right".

mcriders comment notwithstanding, what you've written "simple" in is really immaterial. All you have to do is write a binary file with the equivalents of the ASM you'ld generate for each statement and there you are. Branching and looping are the tricky parts.

M
0
 

Author Comment

by:Marktalbot
ID: 2194830
simple is a vb module which i intend to create a full program out of
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 12

Expert Comment

by:mark2150
ID: 2195761
If its in VB then you're going to have to use VB's tools to make the .EXE - not a .COM. IF you're talking about writing a compiler IN VB, that's ok, The *COMPILER* will be an .EXE that will, in turn, generate a .COM from your source files.

M
0
 

Author Comment

by:Marktalbot
ID: 2196736
this is the simple module. It is not quite finished(goto commands are needed)

Global v(255) As Integer
Public Sub parse(a As String)
Dim b As String
Dim c, d, e As String
Dim f As Integer
1 b = Left(a, 1)
Select Case b
Case "*"
c = Mid(a, 2, 1)
d = Mid(a, 3, 1)
e = Mid(a, 4, 1)
v(Asc(e)) = v(Asc(c)) * v(Asc(c))
Case "+"
c = Mid(a, 2, 1)
d = Mid(a, 3, 1)
e = Mid(a, 4, 1)
v(Asc(e)) = v(Asc(c)) + v(Asc(c))
Case "-"
c = Mid(a, 2, 1)
d = Mid(a, 3, 1)
e = Mid(a, 4, 1)
v(Asc(e)) = v(Asc(c)) - v(Asc(c))
Case "/"
c = Mid(a, 2, 1)
d = Mid(a, 3, 1)
e = Mid(a, 4, 1)
v(Asc(e)) = v(Asc(c)) / v(Asc(c))
Case "@"
c = Mid(a, 2, 1)
f = Mid(a, 3)
v(Asc(c)) = f
Case "S"
c = Mid(a, 2, 1)
f = Mid(a, 3)
v(Asc(c)) = Sin(f)
Case "C"
c = Mid(a, 2, 1)
f = Mid(a, 3)
v(Asc(c)) = Cos(f)
Case "T"
c = Mid(a, 2, 1)
f = Mid(a, 3)
v(Asc(c)) = Tan(f)
Case "s"
c = Mid(a, 2, 1)
f = Mid(a, 3)
v(Asc(c)) = Atn(f / Sqr(-f * f + 1))
Case "c"
c = Mid(a, 2, 1)
f = Mid(a, 3)
v(Asc(c)) = Atn(-f / Sqr(-f * f + 1)) + 2 * Atn(1)
Case "t"
c = Mid(a, 2, 1)
f = Mid(a, 3)
v(Asc(c)) = Atn(f)
Case "D"
c = Mid(a, 2, 1)
MsgBox (v(Asc(c)))
Case "I"
c = Mid(a, 2, 1)
f = CInt(InputBox("INPUT"))
v(Asc(c)) = f
Case "<"
c = Mid(a, 2, 1)
d = Mid(a, 3, 1)
If v(Asc(c)) < v(Asc(d)) Then
a = Mid(a, 4)
GoTo 1
End If
Case ">"
c = Mid(a, 2, 1)
d = Mid(a, 3, 1)
If v(Asc(c)) > v(Asc(d)) Then
a = Mid(a, 4)
GoTo 1
End If
Case "="
c = Mid(a, 2, 1)
d = Mid(a, 3, 1)
If v(Asc(c)) = v(Asc(d)) Then
a = Mid(a, 4)
GoTo 1
End If
End Select
End Sub
0
 
LVL 12

Expert Comment

by:mark2150
ID: 2196835
That's simple alright. This is your "core" execution module - right? Ok, so you're writing an "interpritter", not a compiler. Your "source code" will be in an ASCII file that this piece of VB will read and take the appropriate actions.

A little constructive critism? Use labels instead of numbers (GOTO Top instead of GOTO 1)

Put lables on separate lines.

Indent statements between cases:

Select Case b
  Case "*"
    c = Mid(a, 2, 1)
    d = Mid(a, 3, 1)
    e = Mid(a, 4, 1)
    v(Asc(e)) = v(Asc(c)) * v(Asc(c))
  Case "+"
    c = Mid(a, 2, 1)
    d = Mid(a, 3, 1)
....

Use more descriptive variable names instead of A/B/C/D etc.

Put some *comments* in the code. A sub/function should have an explanation at the top along the lines of:

' Sub to do this and that
' Pass: a - expression to be evaluated
'   form is AxBCD where A is operator ...
' Returns: ...

VB style sheet with these and other guides for readable code is on my web page - www.cyberchute.com/rvbus/madmark

M
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2196892
You know, since your writing an interpreter in VB, you should probably just read the "simple" program and use the microsoft script control (MSSCRIPT.OCX) to execute it.

You can download it at:

http://msdn.microsoft.com/scripting/default.htm?/scripting/scriptcontrol/scdownfinish.htm 
 

Cheers!
0
 

Author Comment

by:Marktalbot
ID: 2198140
as i said the code is not finished and needs work but the whole idea of simple is that it is simple to the point that it is almost machine code. It is to be used in the analog sampling software that i am constructing to alow scripts to aply mathmatical functions to the tracee
0
 

Author Comment

by:Marktalbot
ID: 2198148
I want to create a compiled version of simple but i desigted that seing that i can`t do this at the moment i wrote the inteprited version.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 2198842
Ummm. I think you'll find that it is *NOT* "simple to the point that it is almost machine code" I've written compilers and interpritters (in .ASM) and let me tell you it can get *hairy* in a hurry. The fact that you're "language" syntax is simple has little to do with what it takes to write a *compiler* for it!

Your interpritter is *performing* the operations. What your compiler needs to do is translate the operations into *BINARY* and *then* write all of that to a file.

Also, have you given any thought to *IO*? How is "simple" going to accept input? Generate output? Will it talk to printers? At the DOS level or windows? How much DOS INT21 programming have you done? Do you anticipate doing any *disk* operations? The MATH part is almost trivial. Getting the values in and out is the *hard* part!

M
0
 

Author Comment

by:Marktalbot
ID: 2200008
commands i and d do the io
Case "D"
c = Mid(a, 2, 1)
MsgBox (v(Asc(c)))
Case "I"
c = Mid(a, 2, 1)
f = CInt(InputBox("INPUT"))
v(Asc(c)) = f
 when i said it is ment to be like machine code i ment the syntax of simple. All it is ment to do is do a mathmatical caclulation on an inputed variable (I and O are the two variables in question) and write a value to o and stop
0
 
LVL 12

Expert Comment

by:mark2150
ID: 2200076
I see what you're coding in the interpritter, but have you given any thought as to how much .asm code it will take to duplicate that functionality?

M
0
 

Author Comment

by:Marktalbot
ID: 2202564
no i have never done asm programing and would like to now ether a good site on compiliers or asm to get this info from
0
 
LVL 12

Accepted Solution

by:
mark2150 earned 150 total points
ID: 2202756
ASM programming is *NOT* for the faint hearted. You'll *need* a copy of the "80x86 Family Users Manual" from Intel, a copy of "DOS Programmers Reference" by Que as well as purchasing a copy of MASM from Microsoft. Web sites aren't going to be enough reference to write .ASM.

M
0
 

Author Comment

by:Marktalbot
ID: 2204023
thanks you have given me enough information to get going thanks.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question