flat assembler
Message board for the users of flat assembler.
Index
> Tutorials and Examples > New Z Language+Library + 10 Examples |
Author |
|
uart777 24 Oct 2013, 14:22
Z - The Final Language+Library+Examples
Much clearer than previous code. It's been a while since I've updated the Z77 library and it has been improved greatly. Includes edited FASM. Only one change: Optional ?if/?else/?while/etc for assembly-time directives. Defined if/else/while/etc macros for runtime. In functions, removed [] for locals and parameters.
|
||||||||||||||||||||
24 Oct 2013, 14:22 |
|
revolution 24 Oct 2013, 14:39
A lot of the syntax you use reminds me of C and the examples one sees with C code. Short generic function names. Short generic variable names. Dense coding that requires horizontal scanning. Little or no error checking. Lots of dots and other types of non-alphanumeric characters.
|
|||
24 Oct 2013, 14:39 |
|
hopcode 24 Oct 2013, 16:09
Hallo everybody,
revolution wrote: A lot of the syntax you use reminds me of C and the examples one sees with C code. Short generic function names. Short generic variable names. Dense coding that requires horizontal scanning. Little or no error checking. Lots of dots and other types of non-alphanumeric characters. pros 1) that language and functions do not break fasm assembler semantics. mov eax,eax is still allowed 2) most HLL coders do not require the bit/byte depth 3) the output in the picture is a real charming key-factor. contras 1) horizontal scanning, yes. because of the inner language's partially-organized semantics 2) extensibility: a language that does not make OOP easier for example, i imagine for what i read there. i like it anyway, because it is a starting point to think about a "raw language". a language that is neither HLL nor assembly, once granted assembly remains allowed. this will make portability easier, after considering graph primitives relying on a well-known documented and used external libraries, as SDL or SFML may be on different development systems. also, my tipps 1) reconsider semantics in a BNF way (http://de.wikipedia.org/wiki/Backus-Naur-Form) , as it seems i told you already in other thread 2) reconsider it for one more reason: extensibility (example OOP) the time is mature to run and develop stuff on ARM or low power systems. the dependency from a simple toolchain, respectively fasm and a graph library is what makes that raw language winning 1) at compile time 2) at run time 3) at portability time and once the semantics has been organized newly 4) at extensibility time. Cheers, _________________ ⠓⠕⠏⠉⠕⠙⠑ |
|||
24 Oct 2013, 16:09 |
|
sleepsleep 24 Oct 2013, 18:37
great potentials,
really great potentials, i reserve my comments, thanks uart777 for the gift to all human, |
|||
24 Oct 2013, 18:37 |
|
uart777 26 Oct 2013, 00:25
revolution: I was mainly a C programmer who only used ASM for little graphics demos (mode 13h/X/VESA) that are useless from a functional perspective.
Error checking? The library functions just return error code (usually 0) and the programmer can respond. I agree that LANGUAGE.INC should have more error checking (type safety), but it's not easy to get all macros synchronized on all levels throughout the entire library. Compact code? I write code in lower resolution (1024x768) with bigger fonts (Consolas 16-18 bold on my I32 netbook connected to 32" HDTV). I hate having to hunch over and squint my eyes to see small text. This can eventually cause spinal damage/curvature. Non-alphanumerics? It may appear as though my choice of symbols is completely random but there are reasons. Example: @ ('a'rray) is used for dynamic arrays temporarily until I can incorporate them in let (. p=array[i]) and function parameters (my.function array[i]). hopcode: To me, the code is 100% extensible and customizable. I've never encountered a situation that requires OOP/classes. The one who proposed the Lisp syntax made it sound like OOP is the most common thing. From my experience, 90%+ of code is basic arithmetic (a=b+c, mov, add, etc). OOP is on my 2-DO list, just not the highest priority. Array/structure access is more important and a prerequisite to advance this language further. You are welcome to present alternative macros/syntaxes. sleep: That's nice of you. If I get time, my next contributions may be programs to create visual documents/tutorials and share information. |
|||
26 Oct 2013, 00:25 |
|
TmX 26 Oct 2013, 17:21
Hi uart,
What about the manual? I must admit your language kinda look confusing (dots everywhere), although I can see some C influences in it. Or maybe I'm missing something? |
|||
26 Oct 2013, 17:21 |
|
uart777 26 Oct 2013, 20:21
TmX: Hi. You asked about documentation before and I didn't have time to explain. 1. LANGUAGE.INC is commented. 2. Study the examples. 3. I assume that programmers know how to copy and paste macros from LANGUAGE.INC. At the minimum, they should know how to reuse existing macros. 4. This code is not for everyone. My target audience is bare-metal, embedded, OS creators. If I get time today, I'll post a standard Window in this thread that only includes LANGUAGE.INC+minimal.
Regarding dots... * Assemblers generally prefix runtime macros with . - .if, .else, .while, etc * let keyword was renamed to dot (.) to follow the tradition. There's only one dot in the language for all arithmetic. You're referring to the library names or local labels which are a feature of FASM * Dot is the separator between words (draw.image) instead of the underscore _ which is hard (or impossible) to type on some keyboards. On every keyboard I've used, . and ? are always easy access (right ring finger down). Some symbols are reserved by FASM and can't be used in identifier names * Mixed underscore and dots seems inconsistent: my_icon.image.x * In FASM, labels that begin with a dot are local/attached to previous global label * I get the impression that revolution is just making objective observations, pointing out differences, not necessarily saying good or bad. We can look at specific syntaxes and think of ways to improve them, but it's hard to judge the entire system with 1,200+ macros. Let's just call this language Z or the macro language (please don't say uart's language). It's the only one we have now. Any questions about specific syntaxes? Ask. I can't explain all 1,200+ macros in one sentence or even one book. |
|||
26 Oct 2013, 20:21 |
|
uart777 27 Oct 2013, 02:15
Standard Window Example
Code: include 'z.inc' text title='My Window', wc.name='W1' HANDLE module, window MSG msg WNDCLASSEX wc ;;;;;;;;;;;;;;;;;;;;;; MAIN ;;;;;;;;;;;;;;;;;;;;; function main locals x, y, w, h get [module]=GetModuleHandleA 0 . [wc.cbSize]=WNDCLASSEX.$ . [wc.lpfnWndProc]=!window.procedure . [wc.hInstance]=[module] . [wc.lpszClassName]=wc.name . [wc.style]=CS_DBLCLKS . [wc.hbrBackground]=8 get [wc.hIcon]=LoadIconA 0, 7F00h get [wc.hCursor]=LoadCursorA 0, 7F00h try RegisterClassExA wc . w=720, h=480 . r0=[os.w], r0>>1 ; x=sw/2-w/2 . r2=w, r2>>1, r0-r2, x=r0 . r0=[os.h], r0>>1 ; y=sh/2-h/2 . r2=h, r2>>1, r0-r2, y=r0 try [window]=CreateWindowExA 0, wc.name,\ title, WS_DEFAULT, x, y, w, h,\ 0, 0, [module], 0 @@: GetMessageA msg, 0, 0, 0 fail .r TranslateMessage msg DispatchMessageA msg jmp @b .r: endf [msg.wParam] ;;;;;;;;;;;;;;;; WINDOW PROCEDURE ;;;;;;;;;;;;;;;; function window.procedure, w, message, wp, lp if message=WM_KEYDOWN say 'Key Press' else.if message=WM_LBUTTONDOWN say 'Mouse Click' else.if message=WM_CLOSE PostQuitMessage 0 return 1 end DefWindowProcA w, message, wp, lp endf |
|||
27 Oct 2013, 02:15 |
|
Sasha 27 Oct 2013, 17:16
Quote:
I agree. But some points are looking greate. try RegisterClassExA wc and what happens on error ? No "catch" ? Do I need to write " try say 'Hello' "? As someone could understand, I'm digging in the direction of my own language creation, too. Very slow. When looking at your work, I can't imagine how much time it took for you? I tried different approaches. Using fasm macro, and writing from scratch. Here is my macro attempts, and here I'm talking about parser. There is also an error handler in work. |
|||
27 Oct 2013, 17:16 |
|
uart777 27 Oct 2013, 23:49
Sasha: Your code is good and clear. It takes a long time to learn.
On cell phone. Real quick... (Motorola Photon=Best QWERTY phone): First, all syntaxes are defined in LANGUAGE.INC (and some in ARRAY.INC temporarily). . (aka, let) is for assignments and arithmetic. get calls a function then assigns its return value: Code: get c=rgb 7Fh, 0, 7Fh Code: try create file try p=allocate 4*KB Code: fault .0 ; try will jmp to .0 if error Quote: When is [] needed? |
|||
27 Oct 2013, 23:49 |
|
Sasha 28 Oct 2013, 02:08
Quote:
How much time did it took for you to design and implement your language? I'm learning from scratch! No programming background. Not a first year. After trying a different languages, I always go back to assembler... |
|||
28 Oct 2013, 02:08 |
|
uart777 28 Oct 2013, 08:40
You want the long answer?
89' - Introduced to programming on C64 BASIC. Playing with PRINT, INPUT, PSET. 94'-97' - First PC with DOS+Win3.1. Started programming seriously in BC 3.1 C/C++ and inline ASM+TASM. 97'-99'- MASM+VC++. Making games/graphics/utilities. 00'-09' - FASM+VC++, studying compilers, disassemblers, learned how to convert HL syntaxes (everything from bit fields to multi-dimensional array access), generating instruction tables, expression parsers, designing syntaxes, imaginary CPUs, making toy compilers, mini assemblers, executable formats. 09'-Now - Writing macros, languages, libraries. Programming was always something I did in my freetime whenever I had shelter and electricity. |
|||
28 Oct 2013, 08:40 |
|
Sasha 28 Oct 2013, 14:59
Once I found an esolangs.org and spent there a lot of time. All you are writing about I was thinking about it, but still haven't made something that could be shown. I even went deeper and started to learn fpga's and logic circuits. Not long time ago I've found this impressive article and begun to believe in possibility of creation my own processor.
|
|||
28 Oct 2013, 14:59 |
|
uart777 31 Oct 2013, 19:47
Sasha: You can find programs online to design integrated circuits with logic gates.
... Finally got external USB modem ($5 used) and obtained more WIFI passwords from unsuspecting neighbors. Now, I can submit code. Z, The Final Language. Easiest macro language ever created: Old-school simplicity and insane mental power. No language compares. Z gives one programmer the power to replace big teams, end careers overnight, put big corporations out of business (who think I'm not qualified to mop their floors, they better hope and pray that I never have money). Implementation will be a lifetime project, never finished. Example: Code: function main create f ; create file write s, n ; write to current file close ; close after create open f ; reopen read t, n ; read to t say t ; display text close ; close after open execute f ; execute maximize endf Z... Code: try p=allocate 4*KB try open name read p, 4*KB close Code: try p=load.file name ; or entire file Code: FILE *fp; char *p; if (!(p=(char*)malloc(4096))) { return 0; } if (!(fp=fopen(name, "rb"))) { return 0; } fread(p, 1, 4096, fp); fclose(fp); "Standard"/So-Called "Assembler". Strictly X86/Windoze Specific. Pointless stdcall/invoke prefixes. What's wrong with the word "call"? Why change it for different CPUs+OSs? Writing code this way teaches NOTHING about CPU/assembler Code: invoke HeapAlloc, [_heap], 0, 4096 mov [p], eax test eax, eax jz .r invoke CreateFileA, name, GENERIC_READ \ or GENERIC_WRITE, FILE_SHARE_READ, 0, \ OPEN_EXISTING, 0, 0 mov [fp], eax cmp eax, -1 je .r invoke ReadFile, [fp], [p], 4096, tmp.rw, 0 invoke CloseHandle, [fp] Code: call allocate, 4096 mov [p], r0 test r0, r0 jz .r call open, name mov [fp], r0 cmp r0, -1 je .r call read, [p], 4096 call close COMPARE: Z VS STANDARD VARIABLES Z: Multiple variables may be created on the same line with optional initial value (=) or 0. Code: ; Z: 1 line... integer x, y, w, h, i, j, n, p, q, s Code: ; Standard: 10 lines, 10 times as much code! x dd 0 y dd 0 w dd 0 h dd 0 i dd 0 j dd 0 n dd 0 p dd 0 q dd 0 s dd 0 Z: Straight forward, plain English. 3-5+ members or instances may be written on the same line and optional ? virtual structure after (Zero-based offsets. Add ?s.m to a base register that contains the address of a structure). Code: ; Z: 4 lines structure IMAGE void p integer x, y, w, h, bpp, key, alpha ends ?image Code: ; Standard: 21 lines, 5+ times as much code... struct IMAGE p dd 0 x dd 0 y dd 0 w dd 0 h dd 0 bpp dd 0 key dd 0 alpha dd 0 ends virtual at 0 ?image: .p dd 0 .x dd 0 .y dd 0 .w dd 0 .h dd 0 .bpp dd 0 .key dd 0 .alpha dd 0 end virtual |
|||
31 Oct 2013, 19:47 |
|
filox 09 Sep 2016, 11:36
Hi UART,
can u make an example of simple socket server? Otherwise very cool lib!!! |
|||
09 Sep 2016, 11:36 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.