Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / My attempt at a simple programming language

Author
Message
Dgamer
21
Years of Service
User Offline
Joined: 30th Sep 2002
Location:
Posted: 4th Aug 2003 04:42
i was bored today so I made this, this is a small 1 command programming language, and that command is print .

just try it, it's less than a 500kb download

once u run the exe, just load the txt file where your code is.

Here's the link
http://www.ween.co.uk/~dgamer5000/ScriptingLanguage.zip
The statement below is true
The statement above is false
Doublecrosser
20
Years of Service
User Offline
Joined: 18th Jul 2003
Location:
Posted: 4th Aug 2003 07:01
wtf man? why would anyone take the time to download a thing like that? and take the risk of running another exe on their computer?! But i do like your signing!
The statement below is true
The statement above is false
lol i like it!

Gone Fishing!
members.aol.com/Erik9081/gonefishing.zip
MikeS
Retired Moderator
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 4th Aug 2003 07:15
Yea, I don't think I'll d/l, but at least it's a good start I suppose.

LMAO!!!



good sig display!



Jenny: New Recruit to Police Force Jacob: Jenny's Associate
Problem? You may soon find out. "It could take the world."
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 4th Aug 2003 10:25
try adding different commands like some of the functions in db make one command do more than 1 thing for instance

make object cube objnum,texturefilename$,size

that would make it better!

I have a website!!!
So go there: http://www.freewebs.com/darkb/index.htm
on second thought you probably shouldn't
Dgamer
21
Years of Service
User Offline
Joined: 30th Sep 2002
Location:
Posted: 4th Aug 2003 16:21 Edited at: 4th Aug 2003 16:26
hehe, it not my first, but its the only I posted here in this forums. I was just bored one day and started coding this. I think im going to do the maths and text commands first rather than graphics(my worst enemy)

I actually started on the variables first, but i thought what would be the use if it the program cant use print or any other command to tell the user that the variables are actually there.

[Edit]
Oh and yes... I'll add the annoying error messages too

The statement below is true
The statement above is false
Dgamer
21
Years of Service
User Offline
Joined: 30th Sep 2002
Location:
Posted: 4th Aug 2003 17:05 Edited at: 4th Aug 2003 17:13
hmm you know what? im going to stop working on this. It was 200 lines just for the print and int command.(int for declaring the variable an integer.) and now im expecting anothing 200 lines for a simple variable=value.

Imagine how much it would take to make a multiparameter command. You would have to detect where each of the commas reside and get the value's inside. check if the value is in a variable(and what kind of variable), is it a number, is it a string, then check if its an array, if so, check if the array was previouly declared and if so, check what type of an array it is. (string, integer, float, etc.) then if the type is correct for the parameter, detect which item of the array. Now repeat for all the other arguments. But when it turns into an expression, thats even worse.

The statement below is true
The statement above is false
Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 4th Aug 2003 17:52
my attemp at a simple compiler went like this...

go to google
look up how to make a compiler
see the word parse
be confused
go to bed
forget about it...

and so i will never make a compiler cuase i am lazy and i am not yet about to go all out and make a programming language...

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 4th Aug 2003 19:09
Maybe a script language would be a good way to learn, because it can get more and more complicated as you advance. I mean, start with a game engine, then make a script language to control it. That's how the pro's do it - a lot of the biggest PC games and every PC game that can be modded (Quake, HL etc) uses a script language.

I reckon that'd be a little more fun than memory management and complicated parsers .


Van-B

My cats breath smells of cat food.
Dgamer
21
Years of Service
User Offline
Joined: 30th Sep 2002
Location:
Posted: 4th Aug 2003 19:29 Edited at: 4th Aug 2003 19:33
hehe, memory management, yeah, thats one of the reasons i quit C++. Another thing I need to work on is to use rem statements. I forget what my code does after 30 minutes or so.(Its true, i work on my game/app and then suddenly forget what is it i was suppose to be doing. )

The statement below is true
The statement above is false
Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 4th Aug 2003 19:30
i bet...now to learn scripting...oh wait i already did that part...Orange...hehe

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 4th Aug 2003 19:55 Edited at: 4th Aug 2003 20:12
how does any compiler make it so that what comes out is a .EXE cause i really dont see how that is, unless it has to be told how to be compiled...like the binary...i just dont understand do you know dgamer or van...

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
Dgamer
21
Years of Service
User Offline
Joined: 30th Sep 2002
Location:
Posted: 4th Aug 2003 20:54 Edited at: 4th Aug 2003 21:06
Well my guess is that its made like all other files. you write a series of things in there, save in exe, walla, theres ur exe. Though they have to be in a certain order or whatever.

I tried converting an EXE made to txt and all I saw was bunch of unreadable characters with a few english such as 'This program cannot be run in DOS mode.'

[EDIT]
I copied the whole txt file into MSWord to see how much lines it is, (DBPro cant use non western characters) It currently is at 5000 pages and counting

[EDIT]
Its done, and it reached well over 10,000 pages. 52,922 lines

The statement below is true
The statement above is false
Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 4th Aug 2003 21:51
ok...so how does a compiler create an .exe?

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
Dgamer
21
Years of Service
User Offline
Joined: 30th Sep 2002
Location:
Posted: 4th Aug 2003 22:08
Quote:

"Well my guess is that its made like all other files. you write a series of things in there, save in exe, walla, theres ur exe. Though they have to be in a certain order or whatever."

i think thats it. The compiler just writes things that is needed to run the program in windows and in one way or another, magically include your code in there.

The statement below is true
The statement above is false
Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 4th Aug 2003 22:12
...wow, how informative...lol...anyone know where to find these parts before i kill myself learning parsing...

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 5th Aug 2003 01:24 Edited at: 5th Aug 2003 01:25
To write a compiler you need to know the following:

- The structure of the EXE file (called PE file for portable executable file)
(http://www.microsoft.com/whdc/hwdev/hardware/PECOFF.mspx)
- The opcodes of the Intel CPUs. (http://courses.ece.uiuc.edu/ece291/resources/opcodes.html)
- x86 Assembler


Although not nessecary most compilers (except DBpro for instance) work (basically) like this:
- compile the source into an object file (C and C++ ".obj", Delphi ".dcu"). This file is (basically again ) binary code with offset tables and pointers to types/structs and functions.
- link one or more object files to one EXE file and include resources like icons etc.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 5th Aug 2003 13:43
It would be a little easier with an interpreted language like DBC. What you would do is store the source code inside an exe, then the exe reads the source from itself and runs it. If you made your interpreter so it could run source code that is imbedded in the final .exe, you could in thoery just keep this executable and change the imbedded source for each compile, this means you could create your own executables for your own language - but using a DBPro executable wrapper.

About 5 million times easier than trying to create the .exe from scratch.


Van-B

My cats breath smells of cat food.
M00NSHiNE
20
Years of Service
User Offline
Joined: 4th Aug 2003
Location: England, UK
Posted: 5th Aug 2003 14:53
Rather than make a programming language from scratch, it would be good to make a scripting language that was compatible with and possibly made in db, like the type used for adventure games. The Gabriel Knight games used a scripting language to set up puzzles, like a database type system. An example of this system:

CHIMNEY CLIMB NOT_HAVE_ROPE 1 "How would I do that?"

"It's amazin' what you can do with a computer and access to t'internet"
Wiggett
20
Years of Service
User Offline
Joined: 31st May 2003
Location: Australia
Posted: 5th Aug 2003 16:13
well you'd use your hands and feet and try and position your self to shimmey down or upt eh inside, or if you were outside you'd try and scale the bricks through many different manners. Stupid adventure games, sometimes they say i cant do that when they obviously can.

Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 5th Aug 2003 18:38
Compiler languages are difficult and varying depending on what you want to achieve really.

your end goal for a true language really is to convert the given script syntax into the ASM equviliants using a base script for the globals things suchas memory management & data type protection.

you can make it in any language which is capable of running ASM script natively - once you have that done your either exporting a prescript for another language to use else you'll want to create an executable file.

for the executeable file you need to make sure you have the source setup for the specific header for a system to recognise and start the asm from the original point of the program.
for other operating systems it is oftenly an idea to also make sure that the asm being exported is right for the given processor it is aimed at.

knowing the Op codes for an x86 processor is pretty useless for a PPc

really when you think about it all your doing is given a higher language and more english/native language to accessing the processor which can then access the rest of the system.
well anyways no matter how you think of it, you really need a core setup working and good to go before you start on anything else.

you don't need a high count of code lines to produce something when you use the languages own system to perform tasks.
i mean if you have an #IF function already there, no point in hard coding that again - just do a jmp to that function.

it all just take a very logical mind to achieve what you want

Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 5th Aug 2003 18:43
Did someone say COBOL...i honestly dont why i just thought that...as for its all logical...ur the one who plays Spock in DARKTREK...lol...and well its not so much logic after you understand how EXE are recognized by the operating system

thanks Raven...respect...returning...oh, and Empty for those links...

Well with my new found knowledge i plan writing a faster more stable compiler for DBPro that uses the same DLL...had u goin didnt i...i am not that dumb...ambitious...no, thats not a compiler behind my back...i am not working on one...lol, i am not honestly...

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 5th Aug 2003 19:57
LOL, it's always impressive how Raven manages to say nothing in so many lines.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 5th Aug 2003 20:05
yeah, well, if you wanted a direct answer you dont ask raven...he write long paragraphs...and then tell you what he means...so, anyways, empty do you know anywhere that i can find more resources like that of the top of your head...or favorite bar...

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
HZence
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 5th Aug 2003 20:19
This kind of thing would be easier to do in VB or C++ (as DBPro proves )

SW Games - www.freewebs.com/swgames

Yeah, I know, I only have one game. Yeah, I know it sucks. But I made it! Me!
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 5th Aug 2003 20:24
Quote: "
empty do you know anywhere that i can find more resources like that of the top of your head...or favorite bar...
"

I use Opera and Mozilla so it's bookmarks not favo(u)rites

First you might want to get some tutorials on parsing a source code:
-Crenshaw's compiler tut
It's in and about Pascal and Motorola 68k CPUs but it might give you some idea how to start.
Additionally search the net for "postfix notation".


You should also get into Assembler to find out what's possible with the CPU's commands. Search in google for x86 assembler tutorials. There are a lot.
-http://wwwartsci.clarion.edu/cis/wyatt/253/asm_ref.html
-http://www.online.ee/~andre/i80386/
-http://webster.cs.ucr.edu/Page_asm/ArtofAssembly/0_ArtofAsm.html


Also for the start, try to keep it as simple as possible. Only use assembler commands that are really needed like MOVE, PUSH, POP and arithmetics. Especially for Intel CPUs, focus on Integer only. Floats are handle completely differently by that CPUs. Don't care about dynamic strings and arrays either.

But you should probably start to write a simple interpreter first, or something that compiles the source to so call P-Code and runs it on a virtual machine before you utake the challege to write a native compiler. Just my advice, though

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 5th Aug 2003 20:35
Is it hard to give a compiler access to the Windows APIs?

And Thanks Again,

i know it sounds like i wanna make a compiler, i just wanna learn how its done i dont have the skill to make one...

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 5th Aug 2003 20:43
Quote: "
Is it hard to give a compiler access to the Windows APIs?
"

No, that's fairly easy.
In the pe file you have import tables where you specify which functions in which libraries you want to use. The desired parameters are pushed onto the stack(s), and then you simply call the function.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 5th Aug 2003 21:03 Edited at: 5th Aug 2003 21:05
so if i made a compiler then all i would have to do is find these libraries and tell it what to do with it...like where do i get these libraries? and are libraries like DLLs that just need to be called, or do i need to make a non-iterpretive langauge to have the APIs part of the application?

Oh, and what languages can you make a compiler in?...DBPro(lol lol), C++, Pascal

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 5th Aug 2003 21:17 Edited at: 5th Aug 2003 21:18
Quote: "
like where do i get these libraries? and are libraries like DLLs that just need to be called,
"

With libraries I meant DLLs (Dynamic Link Libraries).
As for the Windows API, all functions are in the system DLLs. For instance gdi32.dll, user32.dll, kernel32.dll etc.
Compiler use the above method (with the import table) mainly for the Windows API. There's another way to link to libraries, which involves a Windows API function that loads the DLL and return the addresses of the functions.

Quote: "
Oh, and what languages can you make a compiler in?...DBPro(lol lol), C++, Pascal
"

Actually any language that has string functions (for parsing) and is able to write files can be used to write a compiler. It might be easier with languages like C++ or Delphi/Pascal, however, it is possible even in DB(pro).

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 5th Aug 2003 22:03
If i can get access to the APIs with gdi32.dll then why did RobK have to make a dll for using the APIs for windows?

And as for strings and parsing whats that...i read those OPCODES are those what tell the program to do through the processor?

And if those OPCODES are for compilers to tell the processors and hardware how to manage memory then how would DBPro or Pascal or C++ do that?

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 5th Aug 2003 22:16
perhaps because some people don't want to have to load windows functions and setup resources by hand...

its not simple to use the Windows DLLs natively in C++ with the headers & libraries directly at your disposal. Use the DLLs requires you to setup all the nessisary data by hand rather than just including a file and using a premade object for it.

if your going to create a language, your just technically PASSING it through the language ... and creating your in ASM.
i'd recommend reading up on the "Art of Asm Programming"

it explains everything pretty plainly - but i can't remember the link right now.

empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 5th Aug 2003 22:29 Edited at: 5th Aug 2003 22:34
Quote: "
If i can get access to the APIs with gdi32.dll then why did RobK have to make a dll for using the APIs for windows?
"

gdi32.dll is part of the API.
Nonetheless you can access the whole Windows API from DBpro. RobK's DLLs just make it more than a lot easier to use windows control in your DBpro app.

Quote: "
And as for strings and parsing whats that...i read those OPCODES are those what tell the program to do through the processor?

And if those OPCODES are for compilers to tell the processors and hardware how to manage memory then how would DBPro or Pascal or C++ do that?
"

A simple example for a Basic Compiler that compiles to the fictitious CPU named E.M.P.T.Y :

The BASIC source code:
n = 42
i = 18

now variables stored in memory. In this example the address for "n" is $F1 and for "i" it's $F2 (both hexadecimal)
now the compiler reads the first line and parses it:
n = 42 so the compiler needs to move the value 42 into the memory at address $F1. The opcode for "MOVE INTEGER TO MEMORY" for the EMPTY CPU is for instance $02. so
$02 $F1 $2A means MOVE $F1,$2A (move $2A (hex. for 42) to the address of variable n that is $F1). Same goes for the variable i and the value 18.
So the above source would compile to (or would look like this if opened in a Hex-Editor)
02 F1 2A 02 F2 12

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 5th Aug 2003 22:39
Quote: "
if your going to create a language, your just technically PASSING it through the language ... and creating your in ASM.
"

LOL ?

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 5th Aug 2003 22:51
why would it be funny?
essentially thats all your doing for most languages...
you use a higher language to convert another higher language into ASM directly which is then structured with a template header for the system your aiming it for.

although you could program it directly into asm you still need a language with an ASM layer to be able to access the processor directly in order to create the language to access the processor again directly.

catch22 really unless your using an OS which allows you to access the processor directly as standard.
else you have to use a go through language to get through the OS layer to create what you need ... and asm itself is just a simplified access layer to the calls gates on the processor to access the different aspect of the system through the registers & opcodes.

in essence what every compiled language is doing ... i compiling into another language with the exception of C/Pascal/Cobol/Fortran which all are natively coded and are OS independant and only thier compilers are actually made OS specific because a dos exe won't run on unix ... but they still export independant of the OS itself and will work dependantly on the OS & Processor Opcodes

Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 5th Aug 2003 22:58
Ok, so the GUI is only part of the API, what else is in the API?

So a parse tables is just what string to write into the EXE that tells it what OPCODES to use when the program is running? and the POINTER is just what tells the program to do according to the source code of the program?

I just am missing a big part here whats this parse tables? and how is using strings to parse supposed to work? and that HEX is what, the OPCODE equivalent of the source?

Hers what i am getting so far...

-You have to use OPCODES to get the iformations stored properly
-You use Parse Table to tell The program how to translate the OPCODES to hex and how to make the commands from the language how to run
-You have to write the HEX in strings after the Header for the EXE
-You have access to the APIs but have to do something to the GDI32.dll

so how do they add custom commands like print and text and such...after you have a core i know it would be simple to make the rest of the more complex commands...

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 5th Aug 2003 23:11 Edited at: 5th Aug 2003 23:11
Quote: "
-You have to use OPCODES to get the iformations stored properly
"

CPU Commands are stored as values (opcodes). Each CPU command has an opcode- commands like MOVE, POP, PUSH, ADD, SUB...

Quote: "
-You use Parse Table to tell The program how to translate the OPCODES to hex and how to make the commands from the language how to run
"

You parse the source of your language to know to what it should be compiled. Like moving values, adding and so on.

Quote: "
-You have to write the HEX in strings after the Header for the EXE
"

No not strings. You write them as Bytes or Words or DWords. I used Hex values as they occupy 2 chars for a byte, that makes it look better.

Quote: "
-You have access to the APIs but have to do something to the GDI32.dll
"

No, GDI32.dll is just part of the whole API. It contains functions for (very slow) graphics output (not to be confused with anything related to DirectX)

Quote: "
so how do they add custom commands like print and text and such...
"

Either you use the Windows API (eg for printing text on the console). DBpro uses a different approach. Nearly everything is inside their DLLs and the executable just calls the functions in those DLLs.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 5th Aug 2003 23:15 Edited at: 5th Aug 2003 23:22
Quote: "
why would it be funny?
"

Because the quoted sentence doesn't make sense.

And what do you mean with ASM? Assembly? That wouldn't make sense either. If so then at least you should mention that you need an assembler to compile it to an executable file. And a linker.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 5th Aug 2003 23:38
So how would i write the HEX after the EXE header? word? Dword? Byte?

So dark basic isnt technically a language its just calling functions...unlike a machine code compiler like C++ that uses libraries(i thought they were the same)

And how would i write a parse table?

And once its been parsed how do i know what the HEX cod is for making the variable stored correctly?

And how would i make it call DLLs?

and when it compile whats this pointer thing and how does it know what order to call these commands in? Does it write them in order...then moves the pointer accordingly?

So how does DB do it?

I have alot of questions dont I?

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 5th Aug 2003 23:56 Edited at: 5th Aug 2003 23:56
Quote: "
I have alot of questions dont I?
"

Indeed

Quote: "
So how would i write the HEX after the EXE header? word? Dword? Byte?
"

That depends. For example the x86 opcode $6A (Push Byte on stack) is 1 Byte in size and would expect another Byte (the value to push). The opcode $68 (Push Dword to Stack) would expect a Dword.
And then there are Opcodes that are longer than 1 Byte.

Quote: "
So dark basic isnt technically a language its just calling functions...unlike a machine code compiler like C++ that uses libraries(i thought they were the same)
"

It is a compiler and it compiles to native machine code. However the complete DirectX stuff (and I guess dynamic arrays and a few other things too) use dlls written in another language (C++).

Quote: "
And how would i write a parse table?
"

What do you mean by parse table?

Quote: "
And how would i make it call DLLs?
"

I think I explained that in a previous post (Windows API access)

Quote: "
and when it compile whats this pointer thing and how does it know what order to call these commands in? Does it write them in order...then moves the pointer accordingly?
"

What pointer do you mean?

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 6th Aug 2003 00:31
yes but most high level languages which are capable of using asm already have the linkers & assemblers builtin

else they wouldn't be able to use asm ... although you could use a more direct version like nasm, masm, goasm, etc - but really coding the compiler in one of them can wastes the point in programming it outside of assembly and as a higher language.

and most of them are C based anyways, the extra Opcodes are simply coded routines within C which called segmented calls.
really makes perfect sense

Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 6th Aug 2003 00:36
Quote: "and when it compile whats this pointer thing and how does it know what order to call these commands in? Does it write them in order...then moves the pointer accordingly?"


a pointer is simply a jump for your program to the first address of memory which contains a stringed data segment.

think of the goods you want a warehouse - the pointer would be the row in which you've stored your goods, you'd then add the section number of the data to get the goods your stored

Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 6th Aug 2003 00:36
ok, you just said to call DLLs i wanna know how i would include a function that loaded DLLs into the application.

I heard the pointer is how the program knows where in the code the program is at and there is some sort of code that says to move the pointer according to the situations in the programs...

Do you know where i can get a HEX list of the OPCODES and a tutorial or something on how to write the OPCODES and stuff...

I dont wanna make a compiler i am just extremly curious now as to how programs really work after compiled...

By parse table i mean how would i know what OPCODES to write in HEX for the commands...like a list of OPCODES for the commands and theyre HEX equivalent...

And about the HEX, so where does the hex go...i have a dword and i want to push it on a stack(whatever that is) where does the hex code for pushing it onto the stack go?

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 6th Aug 2003 00:41 Edited at: 6th Aug 2003 00:42
@Raven
Still doesn't make sense.

" the extra Opcodes are simply coded routines within C which called segmented calls."
Ah yes. Extra opcodes, segmented calls...

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 6th Aug 2003 01:00 Edited at: 6th Aug 2003 01:01
Quote: "
ok, you just said to call DLLs i wanna know how i would include a function that loaded DLLs into the application.
"

Well, it'll be a little much to explain all that here. Sorry. But you might want to read this and also download the zip "LUEVELSMEYER's description about PE file format" (bottom of page).

Quote: "
I heard the pointer is how the program knows where in the code the program is at and there is some sort of code that says to move the pointer according to the situations in the programs...
"

Ah, in x86 CPUs that would be a special register that is called PC (Program Counter). You can 'move' it by increasing, decreasing, overwriting the PC or using commands like JUMP, CALL etc. then it's automatically changed by the CPU.


Quote: "
Do you know where i can get a HEX list of the OPCODES and a tutorial or something on how to write the OPCODES and stuff...
"

The link to the opcode I gave show the opcodes in binary code because a lot bits change according to the registers it affects. If you want you can convert that to hexadecimal with the Windows calculator.

Quote: "
By parse table i mean how would i know what OPCODES to write in HEX for the commands...like a list of OPCODES for the commands and theyre HEX equivalent...
"

Well not every Basic command has an equivalent opcode. The whole trick is to convert a high-level language like Basic to machine code.

Quote: "
And about the HEX, so where does the hex go...i have a dword and i want to push it on a stack(whatever that is) where does the hex code for pushing it onto the stack go?
"

It's in the memory. And it stays there. The Program Counter points at that opcode, the opcode is "sent" to the CPU, the CPU now waits for the value to push and increases the PC by 1 (Byte 'cause the size of this opcode is 1 Byte), the value the PC points at is sent to the CPU, the CPU pushes the value onto the stack.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Dgamer
21
Years of Service
User Offline
Joined: 30th Sep 2002
Location:
Posted: 6th Aug 2003 06:24
=O

The statement below is true
The statement above is false
Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 6th Aug 2003 16:08
aha...so the binary form of the OPCODES can be converted from binary to HEX and i caould tell DarkBasic(LMAO) to make it write them after the EXE header. Then i would need to use my parse tables to comvert the Simplex of the language into Hexadecimal machine code then i would write it in order according to the sources setup and the Program Counter would start at the begining and all i would have to tell it to jump/call etc according to the OPCODES i have written in HEX. So is there and OPCODE for the IF commands or is there a trick to getting a computer to thinking its doin an IF?...I know that converting a language doesnt involve just an equivalent OPCODE...or else we would just write OPCODES...so what i meant by parse table is my own thing that say for GOTO write FU in the HEX...lol...as for the ponter thing is that how to make it GOSUB by getting it current line and localizing it and telling it to come back to that line when it reaches a certain other OPCODE, like it would be using GOTO but making sure it came back to the line it left off...

Wait a minute then DBPro would be good at making a compiler cause its pretty fast at writing files...how ironic...lmao...

PS i used alot of binary, but i like HEX more to, cause its like A1 and F4 and stuff and its all cool...lol

Yeah i understand that a command is just a set of OPCODE commnds that tell it how setup the opcodes...

But i still curious as to how i can draw to the screen? and maybe you might know where i can find the commands to make sure the things has a winbox around it cause i was thinking thats part of the APIs...

Ok, yeah now i wanna write a simple compiler just for fun...lmao i said fun...probly cause it would make me look smart...me look smart make me feel good and stuff...

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 6th Aug 2003 16:14
Ok that link confused me...uh oh questions...

Ok, so is the PE_HEADER the thing that is the frame of the executable?

If so than is it different for a windows based program than a dos program?

And was that link to the Microsoft site the explaination of the PE_HEADER for windows applications?(the link in the first link of lists)

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 6th Aug 2003 16:53
Ok i looked at the MicroSoft documentation on the PE header and i am so lost...is that in HEX that those adresses are being shown...i think i need to know more about HEX...isnt Binary like 16 columns...as for what its saying is that i need to write strings into the Header so is that the header for the EXE and do i need to convert it to dwords or byte or sumthin...

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 6th Aug 2003 17:54
The problem is that the "EXE-Header" is not just an ordinary header. It changes depending on what the executable code does, plus on the input tables, plus on many other things.
To write a compiler isn't that hard (well unless we want to optimize the code). The harder part is to write the linker which is among other things responsible to create the header. The zip download from the above link shows an example of what a compiler does and what a linker does. Although you should keep in mind that this example is for NT platforms only. IIRC it's explained in there why it is that way.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 6th Aug 2003 19:57
Ok, so does that mean that a linker is what writes the HEADER to the new file?

And what commands in DBPro would be used to write HEX...Byte...Dword...Word?

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)

Login to post a reply

Server time is: 2024-04-26 03:54:40
Your offset time is: 2024-04-26 03:54:40