PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Pocket Programming Language to have it's own assembler!

PPL will soon have a new universal mini-assembler language built-in. This language will allow to dynamically compile pseudo-assembly code directly to the target's machine code. This will give instant raw-speed to PPL.

Named PASM, this universal language will be tightly integrated within the PPL language allowing direct call to internal PPL functions and use of PPL variables.

The language will be a very easy to use and will be easy to access.

Example:

Code:
Func asm_test (a$)
// Compile PASM code into Intel or StrongArm bytecode.
code$ = asm ({
:label1 mov r1, var // Load value at variable (a$)
add r1, 0x10 // Add 0x10 to register 1
psh r1 // Push register 1 to ppl stack
cpf showmessage // Call ShowMessage()
ret

ddi var, a$ // Store a$ as 4-bytes integer value in label var.
});
asmcall (code$); // Call the asm code.
asmfree (code$); // Free the code from memory.
end;

proc main
asm_test(3420);
end;


This code is of course a dummy example. It doesn't reflect exactly what the PASM syntax is going to be.

Please give your feedback and ideas.
8O OMG! 8O

Is the virtual core modeled on some existing processor or something you designed? Are your assembly mnemonics based on an existing processor or again something you designed?

Do you see this as being part of the Version 1.0 initial release of PPL?

Will this have much of an impact on the size of the PPL core program?

Cool Idea

bmanske
Hi,

I will design the PASM syntax to be very easy to use. It won't be based on any specific processor for portability purposes.

If things go well, I would like to beta test it for v0.9. I will concentrate on a few little things for 0.8 first and then start work on this powerfull baby.
Will it teach you assembler too? :P

This could be PPL's "big thing" IMO, and will allow you to open up all the doors that have been closed by PPL's lack of speed sometimes. Incredible job.
Great idea ... adds even more potential to a very powerful develoipment environment.

thanks
Please, to watch this Web:


http://www.rainer-keuchel.de/wince/armasm.html

Greetings
I have been working quite hard lately on the PPL assembler 8) and I can say that it's working quite nicely on the PPC :D . I still have to finish up the PC code generation for some of the operands.

Here is an example of PPL assembler code that I am using for testing.

Code:

// Create a variable to be used within the assembler
new(a$, tint);
a$ = 10;

// Generate to machine code (StrongArm or Intel).
x$ = asm({
mov r0, 156
mov r4, 156
mov r1, [a$]
mov r2, 0
:label
add r2, 1
savesp
pplpush r2
ppl ShowMessage
cmp r2, 3
jmple label
});

// Call the generated machine code
callasm(x$);

// Free the memory allocated.
freeasm(x$);

free(a$);


As you might have noticed, the syntax is a mixed between 80386 and Risc syntax. There are only 8 registers available (r0-r3 are 32-bits registers and r4-r7 are 1 byte registers). You can use PPL variables within the assembler code without problems. You can also push and pull values on the PPL stack to call internal PPL functions.

Here is the output code:

Code:
00330000 E1A0C00D mov r12, sp
00330004 E92D4FFF stmdb sp!, {r0 - r11, lr}
00330008 E3A0B400 mov r11, #0, 8
0033000C E38BB833 orr r11, r11, #0x33, 16
00330010 E38BBC00 orr r11, r11, #0, 24
00330014 E38BB060 orr r11, r11, #0x60
00330018 E59B501C ldr r5, [r11, #0x1C]
0033001C E5DB501C ldrb r5, [r11, #0x1C]
00330020 E59BA018 ldr r10, [r11, #0x18]
00330024 E59A6000 ldr r6, [r10]
00330028 E59B7014 ldr r7, [r11, #0x14]
0033002C E1A0E00F mov lr, pc
00330030 E59BF010 ldr pc, [r11, #0x10]
00330034 E1A00007 mov r0, r7
00330038 E1A0E00F mov lr, pc
0033003C E59BF00C ldr pc, [r11, #0xC]
00330040 E1A0E00F mov lr, pc
00330044 E59BF008 ldr pc, [r11, #8]
00330048 E59BA004 ldr r10, [r11, #4]
0033004C E087700A add r7, r7, r10
00330050 E59BA000 ldr r10, [r11]
00330054 E157000A cmp r7, r10
00330058 DAFFFFF3 ble 0033002C
0033005C E8BD8FFF ldmia sp!, {r0 - r11, pc}
00330060 00000003 andeq r0, r0, r3
00330064 00000001 andeq r0, r0, r1
00330068 00046570 andeq r6, r4, r0, ror r5
0033006C 000268A4 andeq r6, r2, r4, lsr #17
00330070 000417CC andeq r1, r4, r12, asr #15
00330074 00000000 andeq r0, r0, r0
00330078 B0672700 ???
0033007C 0000009C muleq r0, r12, r0


:idea: All values passed within the assembler on the PPC platform, are stored starting at temporary register (r11) and indexed through an extra opcode in a temporary register (r10). I will optimize this part to use all values < 4096 directly in the opcode. This will also be fixed soon.

:idea: I am still working on a procedure to allow stack push and pull on the PPC. It's a little thougher than the PC side. But this will come soon.

:!: The PPL assembler will be available in the next release of PPL which should be out hopefully by the end of next week.

I will post the output generated for the PC machine code soon.
Here is an update on the status of the PASM (PPL Assembler).

I have been doing a lot of progress in the last few days. The PASM is very powerful now. I am really proud that it works like a charm on the PC and PPC.

Here is a little example to show you the power of the PASM.

Code:
sdim(a$, tint, 10);
a$[0] = 10;

ShowMessage(a$[1]);

x$ = asm(1024, {
:main
mov [a$, 4], 100
});

callasm(x$);

ShowMessage(a$[1]);

freeasm(x$);

free(a$);


You can access PPL variables directly from inside the PASM code and you can use index addressing to access array elements.

The MOV and PUSH are very complete operators, they support all the fancy addressing and stuff. The rest of the operators mainly works of of registers and values. They won't support all this fancy addressing yet. Maybe later. Ex:

Code:
add r0, 0xABC // This is supported
add [r0], 0xABC // Not supported.
add r0, [r1] // Not supported.


I have new DIV, ROR, ROL operators even though they are not supported on the ARM processor, they are internal C functions called directly from the binary code.

All the registers are saved and loaded when needed by the PASM. This garantees safe register values at all time.
What kind of speed do you see with this code compared to regular PPL?
Well, I did some testing. And boy PPL is fast! :)

You have to understand the PASM, is pure binary code translation, so it should be as fast as any assembler would produce. However I get very similar results on the PC with PPL, but on the PPC, it's something like 10x faster so far. This is just doing a simple loop count btw. Don't use these results as anything official yet, it might change a lot and PPL was still running in debug mode.

I haven't done more elaborate testing yet. It's still a long way since it's stable and fully useable for game programming. But it's getting there pretty quickly.
this is propbaply a dumb question, but would this work on an AMD driven computer?
Yeah it should. But will PPL work on an ARM computer?I doubt it. The PASM generates standard ARM code, not even Thumb Arm! You could take the PASM generated code and save it to disk. Maybe you can create a sort of .exe for the ARM computer?
when you say it won't run on a ARM computer, you don't mean a Pocket PC do you?
I totaly didn't read your question properly! I thought I saw ARM and not AMD! :oops:

Yes the PASM is 100% cross-platform between PC and PocketPC. On the PC side it generates 80386 code, so AMD will be compatible too. You write your assembly code once and it will run on both platforms.
DIV, ROR, ROL operators even though they are not supported on the ARM processor

DIV isn't supported, but if ROR and ROL are just rotations, then just use the MOV instruction (for ROL use 32 minus):

Code:
MOV r0,r0,ROR #29
MOV r0,r0,ROR r1


It also does RRX if you need that too (rotate through the carry flag).
Since I don't support ROR within the MOV operator, I have added the ROR and ROL operators as internal C functions just like DIV function. Not the fastest but the most portable for sure! :)
zen333 · 23 Oct 2005, 12:13 UTC — when i can download this ?
where download this ?
You can download the beta 0.8 at http://ppl.arwen.com However the PASM (PPL Assembler) in this version is bugged. The new version will come out this week. The PASM is still a work-in-progress.
Just to give you an update on the status of the PASM:

BMANSKE is doing a lot of test with the PASM. He is doing his best to crash it all the time and he succeeds! :evil: Just joking, the PASM has to go through this rough phase in order to become a solid product. Thanks Brad for all the effort and time you are putting into this. Your patience legendary. :lol:

Anyway, the PASM is becoming better each day. It's super easy to use, 100% cross-platform, very powerful and most of all, it's super fast!

Sounds more like a tv-commercial than a status update! :oops:

I will try to add memory management functions and GameAPI functions directly into the PASM next week, this will make it even better to code more interesting programs.
Where is the download link???
sponge wrote:Will it teach you assembler too? :P

This could be PPL's "big thing" IMO, and will allow you to open up all the doors that have been closed by PPL's lack of speed sometimes. Incredible job.

-------------------------------------
1969 , Chuck Moore wrote Forth w/ inbedded
assembler . Nuemonics were easy cause you
could easily change them , and you could quickly mod it to eliminate all
the obtuse details you must deal with in other assemblers . It was the smallest Opsys ever written . Im looking for a way
to boot ARM-9 to write my own Forth .
I can use anything , even a Basic .
But i wont waste my time on C and its
1500 page manuals . Forth needs NO manuals.
You never compile , you simply key in OpCodes and test them . No faster way to
learn assembly . Then you define all the stupid details to Forth "Macros" so they
are automated ! Clever !
Problem is its being obtused to look like C . ANS Forth is obsolete , for old 16KB , 40 year old computers .
Gemme some help finding a way to boot
up a minimal assembler or Basic and
i will give a Forth free ...
I hate the non binary methods of C and
Linux so much , i cant even keep my cool .
Forth is written in Forth and starts at
5KB in an ARM 9 ROM loader . At this point
it can create code,saved into a linked Dictionary in SRAM . You code , you test it immediately , no source code , no
debug listings , FAST !!
werty@swissinfo.org
Have GP2X and will have ARM-9 ARMkit MH4
soon ...
Even though I didn't understand the goal of your post, I have a GP2X too and like it very much.

PPL is not compatible with the GP2X even if it uses a StrongARM assembler.
werty posts produces more
obtuse werty posts !

Dan East