flat assembler
Message board for the users of flat assembler.
Index
> Tutorials and Examples > JASM: Java Assembler. Applet + JFrame! |
Author |
|
uart777 23 Aug 2013, 07:30
JASM is an extension of Tomasz's "Assembling JVM bytecode". Features: Minimal macros to create classes, methods, variables, if statements, imports, etc, and this is only the beginning. Includes: 3 examples/templates with .BAT scripts. Download: Click Here Console: Code: include 'j.inc' constants module MAIN string message='Java Assembler' endcs class MAIN method main(String[] a) System.out.println message endm endc JFrame Application: Code: include 'j.inc' constants module APPLICATION string message='Java Application' endcs class APPLICATION method main(String[] a) f=1 ; JFrame f = new JFrame ; new JFrame() dup ; use twice astore f calls JFrame.init() aload f ; f ipush 720 ; width ipush 480 ; height call JFrame.setSize() ; f.setSize(720, 480) aload f ; f ldc message ; "..." call JFrame.setTitle() ; f.setTitle("...") aload f ; f iconst_1 ; 1 call JFrame.setVisible() ; f.setVisible(1) endm endc Applet: Code: include 'j.inc' constants module APPLET string message='Java Assembler' endcs class APPLET extends Applet method create() aload 0 gets Color.blue call Applet.setBackground() endm method paint(Graphics g) aload 1 ldc message ipush 8 ipush 16 call Graphics.drawString() endm endc
Last edited by uart777 on 27 Aug 2013, 03:06; edited 3 times in total |
|||||||||||
23 Aug 2013, 07:30 |
|
TmX 23 Aug 2013, 13:38
Whoa. Programming in Java bytecode.
This is seriously awesome |
|||
23 Aug 2013, 13:38 |
|
sleepsleep 23 Aug 2013, 14:53
i think this is kinda cool!
|
|||
23 Aug 2013, 14:53 |
|
f0dder 23 Aug 2013, 20:22
bitRAKE wrote: I am not familiar with the Java execution environment. Is there a benefit to installing the JDK, or is the JRE sufficient? The JDK has documentation of the class libraries, a lot of source code, and a Java compiler. If you don't need any of those, don't bother Oh, might be one other difference - on Windows, the JRE didn't use to include the server version of the JIT, only the client... they have quite different optimization goals. This is why you'd see benchmark differences between Java on Windows vs. Linux, because server JIT is default on *u*x. Dunno what the situation is now, but iirc the JDK always included both. _________________ - carpe noctem |
|||
23 Aug 2013, 20:22 |
|
TmX 24 Aug 2013, 03:29
JDK is used to compile Java apps from source.
JRE is used only to run Java apps. I just take a look at the batch files and it seems that JRE is sufficient, because the bytecode generation is done by FASM, and not by Java compiler itself. |
|||
24 Aug 2013, 03:29 |
|
uart777 24 Aug 2013, 04:39
WHY JASM?
* Syntax is customizable, extendable * Understanding of bytecode which can be executed in hardware by some CPUs (example: ARM Jazelle technology) * Universal translation to/from X86/ARM/Bytecode, portability in every direction * Easy alternative to writing bytecode directly * Fast processing. FASM+IDE is a magnitude faster than javac+Eclipse/Netbeans/etc (JCreator is the only IDE I like). * For smaller OSs to make a JVM emulator Learning Java Bytecode * Oracle's Official .CLASS Specification * All Java Bytecode Instructions - Wikipedia * "Mastering Java Bytecode with ASM" .PDF animated slideshows. By Anton Arhipov. His teachings are straight forward and easy to understand * Jasmine Bytecode Assembler. Oldest, first Java Assembler. Instructional Videos: * JVM Bytecode for Dummies (and the Rest of Us Too). * Mastering Java Bytecode with ASM. Anton Arhipov Disassemble Bytecode Try my Java Disassembler package. Click DISASSEMBLE.JS. Usage: In FILENAME.TXT, just replace the first line MAIN with the NAME of your .class (case-sensitive, no .ext) then click DISASSEMBLE.JS. JavaScript will silently run DISASSEMBLE.BAT (no console), get FILENAME.TXT, try to detect JDK directory, run javac silently to output FILE.TXT, then it displays disassembly in text editor. MAIN.BAT is like a mini-library used by other .BAT files. COMPILE.BAT will use javac to compile MAIN.java (standard) to MAIN.class then run it after. RUN.JS/RUN.BAT just executes. JASM 2-DO List: It will take time to do all of this by myself: * #1. Automatic constant pool, names, numbers and literal text, forward references (somehow). Prevent redefinition and duplication of non-unique values/entries. In the meantime, users must manually create all class/field/method names and indices. * #2. Type recognition and safety. It should store types/sizes/etc internally and use appropriate instructions * Error checking. Extremely important. If a macro fails to detect syntax errors, it will generate incorrect code without warning, or even worse, no code at all or the error messages may be totally misleading. An example is a HL IF/LOOP block that always executes once. When this occurs, chances are, macro did not produce code, failed match with no verification. New "syntax" and "verify" keywords to minimize this. * Names of parameters and locals. In standard bytecode, you refer to locals and parameters by index #. One trick is to create a numeric constant that = index. Example: Replace iload 3 with n=3 then iload n. From here on, n = index #3 until it's reassigned. See APPLICATION.ASM > Font f * Members and local variables. Example: int a=1, char b='Z', String c='Future JASM' * Method calls with parameters. Example: aload f | iconst_1 | call JFrame.setVisible() should be replaced with just: f.setVisible(1) Type must be known first. Instance is the invisible first parameter. Example: g.drawString("X", 8, 16) = call Graphics.drawString(g, "X", 8, 16) * HL assignments and arithmetic: . a=b ; JVM stack-based architecture would make it easy to convert infix expressions with its predefined stack, arithmetic and unlimited "registers". * HL blocks: .if/.else/.while/.for/.loop/.repeat. * Imports should be easier and more versatile. Example: import JFrame:setTitle(String)(void), JFrame:setVisible(int)(void). With these improvements, JASM could realistically be used for serious development with the option to write pure bytecode inside asm-enda (asm {}) block. Preview of what JASM could be: JASM may be a way for FASM programmers to finally get paid by making Java applications for the Android market (if anyone could find documentation on the internals of .APK). What if we convert FASM to bytecode? Just the preprocessor+directives, not the actual assembler. Someday, I'd like to create a "Pocket Assembler" + IDE that supports X86+ARM+Bytecode + emulator. Then a HL compiler that generates code for any custom CPUs+OSs. In theory, one could be programming on an Android phone/tablet for WinX/Linux/X360/PS3/etc and vice versa. |
|||
24 Aug 2013, 04:39 |
|
uart777 24 Aug 2013, 06:02
TmX wrote:
Quote: the bytecode generation is done by FASM, and not by Java compiler itself. FASM is the most efficient, powerful preprocessor that I've ever seen, 1,000s of times faster and smaller than M$ compilers (though I wish FASM had a way to load/save/run external files, fsave would be opposite of file 'my.bmp'. Then we could eliminate these .BATs). A common misconception is that FASM is all about writing X86 assembler. It's not. We don't really need the assembler aspect of FASM that converts instructions, only the preprocessor + directives, that runs before (and while) assembly. We can use db/dw/dd/etc to define unrecognized CPU instructions and OS file formats. |
|||
24 Aug 2013, 06:02 |
|
HaHaAnonymous 24 Aug 2013, 17:50
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 20:05; edited 1 time in total |
|||
24 Aug 2013, 17:50 |
|
edfed 24 Aug 2013, 20:48
a sort of macro based assembler can be interresting.
in fact, we don't need a compiler with a build in instruction set. but a compiler than accepts a macro include, and let the user write code based only on macros defined before. the syntax of the operands and the tricks to declare/exploit address is the interresting part of fasm. Code: include 'x86.inc' macro copy a,b { ;a is a pointer to a source table ;b is also a pointer to a destination table mov ecx,[a];read the first dword (the size of the table) mov esi,a+4 mov edi,b+4 cld rep movsd } ... mov [buffer+4],PowerSignalColor;set the first pixel to a color copy buffer1,buffer2 ... |
|||
24 Aug 2013, 20:48 |
|
uart777 25 Aug 2013, 00:14
Quick logo sketch (5 minutes):
|
|||
25 Aug 2013, 00:14 |
|
typedef 26 Aug 2013, 01:58
and of course my awesome DNS filter.
HMM. Really ? |
|||
26 Aug 2013, 01:58 |
|
uart777 26 Aug 2013, 07:03
Zymic (zxq.net) servers went down again So, all of my images and downloads disappear until they restore. Wait about 1-4 days. A server from my own PC (I32 netbook) is impossible because I don't have my own internet service (use neighbor's and nearby WIFI modems).
|
|||
26 Aug 2013, 07:03 |
|
questlima 28 Aug 2014, 11:23
is that writing java in assembly this is awesome tho i have never tried to understand java anyway thank you
_________________ Linux command are not what you intended to learn but your were forced to learn it, without it you will be like a sitting duck on your beautiful newly installed Linux desktop:) |
|||
28 Aug 2014, 11:23 |
|
jiangfasm 12 Jul 2015, 13:51
I can't download, could you give a new address??
|
|||
12 Jul 2015, 13:51 |
|
typedef 12 Jul 2015, 23:39
jiangfasm wrote: I can't download, could you give a new address?? Wait until he pays his bills. Or you can simply donate $100 to my PayPal account. |
|||
12 Jul 2015, 23:39 |
|
filox 07 Sep 2016, 14:45
Hi uart777,
is there a Linux version of your environment? It is possible to make a version for all OS so? I think the problem is the "CASE INSENSITIVE" methods including files.... Many thanks |
|||
07 Sep 2016, 14:45 |
|
TheRaven 10 Sep 2016, 18:57
Anyone try this with .Net byte code yet?
At any rate, nice project here uart. This stuff should be interesting. |
|||
10 Sep 2016, 18:57 |
|
NEASM 31 May 2018, 00:51
uart777 wrote:
uart, excuse me for the answer. I would like to know how to import other classes and how to import and use their methods. I can not, I would like to know how it can be done. Would you help me? Thank you. (I'm a newbie, I ask idiotic questions by nature). |
|||
31 May 2018, 00:51 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.