generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Making a bin scripting language

Previous Thread :: Next Thread 
JangoBuffet is not online. JangoBuffet
Joined: 15 Sep 2012
Total Posts: 204
06 Oct 2012 02:17 PM
There's not really a specific reason I'm doing this... just moreso boredom. I also wanted to get used to handling binary files, so I guess this helps.

Basically, it's a scripting language, but it uses values rather than strings of text. For example, if you had a binary files with the values inside of it:

0x0A, 'H', 'e', 'l', 'l', 'o', '\n', 0x00

The hex value 0x0A is what you put if you want to display a literal. You also end your statements with the hex value 0x00.

Here is an example of something I have so far:

0x0C, 'n','a','m','e',0x00,
0x0D, 'n','a','m','e',0x00,70,0x00,
0x0A, 'V','a','l','u','e',':',' ',0x00,
0x1A, 'n','a','m','e',0x00,
0x0A, '\n', 0x00,
0x0B, 0x00

The "0x0C" hex value tells the reader that you are declaring a number variable (0x1C is for strings). The next values you input, all the way up to the end of your statement, is the name of your variable. In this case, I named my variable "name".

0x0D says you are assigning a number variable a value. First, you put the name of the variable, then you end your statement, put the value you want to put into that number variable, and then you want to end the statement again. In this case, I moved 70 into the variable named "name".

0x0A says you want to display some text. In this case, it displays "Value: ".
0x1A says you want to display a number variable. In this case, I am displaying "name".
Then we use 0x0A again to display the newline character.

0x0B is for pausing. This just pauses the terminal and says "Press return to continue . . .".


The output of this binary file when read would be:
Value: 70
Press return to continue . . .


I'm writing it in C++ and trying to make it cross-platform. Although, if I were to give it some control over the terminal (such as, being able to control the cursor position, text color, background color, etc within the terminal) that would not be cross-platform. I'd have to make them separately depending on the platform you are using. :\

I'm just doing this for fun. Not really any other reason.
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
06 Oct 2012 02:18 PM
Has to be awful to program in.
Report Abuse
comiconor is not online. comiconor
Joined: 26 May 2009
Total Posts: 16893
06 Oct 2012 02:19 PM
That would be a lot faster to type. Harder to remember too, but I know I personally could do it, and many other intelligent programmers too.
Report Abuse
JangoBuffet is not online. JangoBuffet
Joined: 15 Sep 2012
Total Posts: 204
06 Oct 2012 02:22 PM
@Prehistoric

Well, most likely I'd also create a "compiler" for it. Where you could type ASCII strings, like, instead of:


0x0C, 'n','a','m','e',0x00,
0x0D, 'n','a','m','e',0x00,70,0x00,
0x0A, 'V','a','l','u','e',':',' ',0x00,
0x1A, 'n','a','m','e',0x00,
0x0A, '\n', 0x00,
0x0B, 0x00

You can type in a text file with:

DEFINE NUM name;
ASSIGN NUM name; 670;
PRINT LIT Value: ;
PRINT NUM name;
PRINT LIT \n;
PAUSE

And then it will convert it to binary for you.

Report Abuse
JangoBuffet is not online. JangoBuffet
Joined: 15 Sep 2012
Total Posts: 204
06 Oct 2012 05:01 PM
I've added a few things. Like, you can run comparisons with:

0x31, 'n','a','m','e',0x00,79,0x00,

Here, I used "0x31" which says you want to compare a number variable to a literal. I compared "name" to "79". And it stored in the "flag" variable the results (true/false).

You can also do jumps now, so like

0x0E is a relative jump, which lets you jump either forwards or backwards in data based on how much you want. So like,
0x0E, 5, 0x00

Will jump forwards 5 bytes. 0x3E is for exact jumps. Like, "0x3E, 0, 0x00" will jump to 0, or the very beginning of the program.

You can also jump based on comparisons. Like, 0x1E is a relative jump only if the "flag" variable is set to true. "0x2E" does the same thing except for false.

So, like, here's a program:

0x0C, 'n','a','m','e',0x00,
0x0D, 'n','a','m','e',0x00,73,0x00,
0x2D, 'n','a','m','e',0x00,2,0x00,
0x0A, 'V','a','l','u','e',':',' ',0x00,
0x1A, 'n','a','m','e',0x00,
0x0A, '\n', 0x00,
0x0B, 0x00,
0x31, 'n','a','m','e',0x00,79,0x00,
0x2E, -38, 0x00

I will explain the lines by which "command" starts them.

0x0C - declare a number variable named "name".
0x0D - Assign the variable "23".
0x2D - Add "2" to the number variable "name".
0x0A - display the text "Value: "
0x1A - Display the contents of the variable "name".
0x0A - Display a newline character (\n).
0x0B - Pause the program (Press return to continue . . .).
0x31 - Compare the number variable "name" to the literal "79".
0x2E - If the "flag" variable is "false", then jump -38 bytes (goes back to 0x2D).

So basically, this program will display this:

Value: 75
Press return to continue . . .
Value: 77
Press return to continue . . .
Value: 79
Press return to continue . . .




Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
06 Oct 2012 05:59 PM
What you're essentially designing here is a very strange assembly language. What's weird is how your variable names stay there - normally they would be replaced with a numerical index/memory address. With your first example:

    // compiler decides 'name' refers to variable number 0x42, for example

    0x0C, 0x42, 0x00,
    0x0D, 0x42, 70, 0x00
    0x0A, 'V','a','l','u','e',':',' ',0x00,
    0x1A, 0x42, 0x00,
    0x0A, '\n', 0x00,
    0x0B, 0x00

Your structure has a fundamental flaw - I cannot store 0 in any variable!
Report Abuse
JangoBuffet is not online. JangoBuffet
Joined: 15 Sep 2012
Total Posts: 204
06 Oct 2012 06:11 PM
@NXTBoy
You can store 0 in a variable:
0x0D, 'v','a','r', 0x00, 0, 0x00

It reads the next value after "0x00". The next 0x00 I put, the last on the line, actually doesn't do anything. It's just there for looks.

0x0D, 'v','a','r', 0x00, 0
Would do the same thing.


And this isn't really an assembly language, that's why some things are different. For example, the variables are being stored in space I already opened up. It's not allocating the space and naming the addresses like a programming language does. I'm just storing it in one I already opened up, I also made a variable that holds all of the variable names you create. So basically, I can take a variable name, search for it through others, and find the value of the variable.

It's a bit weird, but it's not quite as complicated as Assembly. It's a system that works much simpler and higher up from the OS than Assembly. It's more comparable to Java byte code, although, no where near as advanced.

" // compiler decides 'name' refers to variable number 0x42, for example"
There's no compiler, yet. It's more of an interpreter. For now, you have to write the binary directly.

And like I said, basically it stores "name" at an index, and the value of it and the same index of another variable. So like, if I search through the indexes and find "name" is stored at index "4", then index for of the other one will have the value of name.

Report Abuse
JangoBuffet is not online. JangoBuffet
Joined: 15 Sep 2012
Total Posts: 204
06 Oct 2012 06:23 PM
I actually didn't quite consider what you said, and I decided that way was much better.

Now, the variables are going to be referenced by their number. This makes it much easier to work with.

Now like,
0x0D,1,73,
0x3D,1,2

That will assign 1 the value of "73".
0x3D will subtract 2 from the variable 1, making it 71.

That makes much more sense. I dunno what I was thinking.
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
06 Oct 2012 06:27 PM
Yep, that's exactly what I was describing. You don't need trailing zeros (in most cases) any more, since the instructions are of known length.
Report Abuse
JangoBuffet is not online. JangoBuffet
Joined: 15 Sep 2012
Total Posts: 204
06 Oct 2012 06:36 PM
@NXTBoy
Yeah, thanks. That makes much more sense. I still kinda need zeros when dealing with strings, though. Like for print, you need:

0x0A, 'h','i','\n', 0x00


But yeah. Using the number rather than assigning it a name in the binaries makes a lot more sense.
Report Abuse
chickenman158 is not online. chickenman158
Joined: 18 Jan 2011
Total Posts: 915
06 Oct 2012 07:39 PM
Why u no use ASM? It is more well known, and more powerful.
Or, better yet, make a NISC architecture, I could help you with that.
Report Abuse
SN0X is not online. SN0X
Joined: 24 Oct 2011
Total Posts: 7277
07 Oct 2012 04:32 AM
I thought of doing the same thing, but it got too complicated.

Good luck, I guess.
Report Abuse
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
07 Oct 2012 06:27 AM
"That would be a lot faster to type. Harder to remember too, but I know I personally could do it, and many other intelligent programmers too."

If this sentence has a scrap of non-sarcasm then you are a terrible programmer
Report Abuse
comiconor is not online. comiconor
Joined: 26 May 2009
Total Posts: 16893
07 Oct 2012 06:36 AM
"If this sentence has a scrap of non-sarcasm then you are a terrible programmer"

If this sentence has a scrap of non-sarcasm then you probably have narcissistic personality disorder.
Report Abuse
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
07 Oct 2012 07:22 AM
It's not faster to type.
You don't need to be intelligent to use it.
It doesn't look particularly hard to remember.
Report Abuse
LPGhatguy is online. LPGhatguy
Forum Moderator
Joined: 27 Jun 2008
Total Posts: 4725
07 Oct 2012 11:57 AM
>I still kinda need zeros when dealing with strings, though.

But that's the case with *every* language, there's always a trailing NULL value.
Report Abuse
comiconor is not online. comiconor
Joined: 26 May 2009
Total Posts: 16893
07 Oct 2012 12:18 PM
I've never met a programmer who wasn't intelligent.
Report Abuse
JangoBuffet is not online. JangoBuffet
Joined: 15 Sep 2012
Total Posts: 204
07 Oct 2012 03:56 PM
@trapping
Again, this is not how you are going to program. In Java, you don't write Java byte code to program Java. You write Java code that gets compiled by the Java Compiler which converts it to Java byte code, which is then read by the interpreter.

This is the same concept. What I am making here is the interpreter. I also am working on a compiler along with it.

I'm calling this language Kaliber. Today, I reworked the entire thing from scratch to have neater code, so a lot of values are different.


But here's an example of my compiler and interpreter so far:

1. I create a file named "test.kb" and put this Kaliber code inside of it:

------------------------------------------------------------------------------------
ASSIGN:NUM 1 7
ADD:NUM 1 5
PRINT:NUM 1
PAUSE
COMPARE:NUM/LIT 1 42
JUMP:FALSE 3
JUMP:TRUE 0
------------------------------------------------------------------------------------

a. "ASSIGN:NUM" assigns the number and index 1 to the value of 7.
b. "ADD:NUM" adds 5 to the number at index 1.
c. "PRINT:NUM" prints the value of the number at index 1.
d. "PAUSE" pauses the terminal until the user presses a key.
e. "COMPARE:NUM/LIT" compares the number at index 1 with the literal 42 and sets the flag.
f. "JUMP:FALSE" jumps to position 3 in data (which is ADD:NUM) if the flag is FALSE.
g. "JUMP:TRUE" jumps to position 0 in data (which is ASSIGN:NUM) if the flag is true.


2. Now, I run my Kaliber compiler, like so:
./kaliberc test.kb

3. This generates a binary file named "test.kbc." This binary file contains the values:
------------------------------------------------------------------------------------
0x20, 1, 7, 0x30, 1, 5, 0x11, 1, 0x70, 0x51, 1, 42, 0x62, 3, 0x61, 0
------------------------------------------------------------------------------------

(the ones with 0x# represent hex values)

4. Now, I can use my intepreter. I would run the program with:
./kaliber test.kbc

This would give me an output similar to this:

------------------------------------------------------------------------------------
12Press return to continue . . .
17Press return to continue . . .
22Press return to continue . . .
27Press return to continue . . .
32Press return to continue . . .
37Press return to continue . . .
42Press return to continue . . .
12Press return to continue . . .
17Press return to continue . . .
22Press return to continue . . .
27Press return to continue . . .
32Press return to continue . . .
37Press return to continue . . .
42Press return to continue . . .
12Press return to continue . . .
17Press return to continue . . .^C
------------------------------------------------------------------------------------

Notice how it starts at 12 and keeps on incremental by 5 until it his 42, then it goes back down to 12.
Also, how there is no line break between the number and the "Press return to continue . . ." is not a flaw. If you want a new line, you are going to want to use:

PRINT \n
Report Abuse
JangoBuffet is not online. JangoBuffet
Joined: 15 Sep 2012
Total Posts: 204
07 Oct 2012 04:00 PM
Here's the list of "command" values, or whatever you want to call them. These hex values, when the interpreter comes across one, it will do something based on that.

//0x10 Print (Lit)
//0x11 Print (Num)
//0x20 Assign (Num)
//0x30 Add (Num)
//0x31 Sub (Num)
//0x32 Mul (Num)
//0x33 Div (Num)
//0x40 Get (Num)
//0x50 Compare (Lit/Lit)
//0x51 Compare (Num/Lit)
//0x60 Exact Jump
//0x61 Exact Jump (True)
//0x62 Exact Jump (False)
//0x63 Relative Jump
//0x64 Relative Jump (True)
//0x65 Relative Jump (False)
//0x70 Pause

Notice, I have not yet gotten around to making string variables. I will, though.
Report Abuse
fremontboy is not online. fremontboy
Joined: 15 Jun 2009
Total Posts: 807
07 Oct 2012 06:52 PM
[ Content Deleted ]
Report Abuse
JangoBuffet is not online. JangoBuffet
Joined: 15 Sep 2012
Total Posts: 204
07 Oct 2012 09:39 PM
@Fremonthnoy

I'm writing it in C++.
Report Abuse
JangoBuffet is not online. JangoBuffet
Joined: 15 Sep 2012
Total Posts: 204
07 Oct 2012 10:23 PM
Woot! I'm modifying my compiler to make things easier to work with.

Like, "JUMP 5" would jump to address 5. But obviously, calculating all the addresses is difficult. So I programmed labels into my applications. Basically, you can do this:


ASSIGN:NUM 1 10
:QR
ADD:NUM/LIT 1 5
PRINT:NUM 1
:LBL
PRINT:LIT \n
PAUSE
JUMP :QR


If you put a line with a ":LABELNAME" you can name labels. This basically just represents that position in data. Then, anytime you use ":LABELNAME" in your program, it will replace ":LABELNAME" with the address.

So like, when I wrote ":QR" it labeled address "3" as ":QR". So when I wrote "JUMP :QR" it replaces that when it compiles to say "JUMP 3".

Now I just need to setup variables.
Report Abuse
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
08 Oct 2012 09:49 AM
"Again, this is not how you are going to program. In Java, you don't write Java byte code to program Java. You write Java code that gets compiled by the Java Compiler which converts it to Java byte code, which is then read by the interpreter."

Please don't assume you know what I'm talking about when you don't.

I'm well aware of how these systems work, assembly being the most obvious example.

I was replying to the other guy
Report Abuse
JangoBuffet is not online. JangoBuffet
Joined: 15 Sep 2012
Total Posts: 204
08 Oct 2012 02:53 PM
@trapping
>Please don't assume you know what I'm talking about when you don't.
But I do.

>I was replying to the other guy
Derp?
Report Abuse
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
08 Oct 2012 03:03 PM
He said it is easier to make stuff with and that you need to be smart to understand it

neither of those points are true

it's incredibly difficult to make things with languages like and they are easy to understand (Or this form is since it's all emulated, whereas real assembly has a huge amount of back-end knowledge necessary)

they also require not intelligence but insane patience.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image