Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - Ldmicro black box idea for libraries

(you are viewing a thread; or go back to list of threads)

Ldmicro black box idea for libraries (by Alex)
Hello, i was thinking if we could add a black box for ldmicro where we can add our own (assembler) code (since i understand that it is the only way to add code to ldmicro via assembler, i am not sure), we could implement our own code for i2c, spi , etc, due to it is too much work for one person (developer), and taking as an example arduino forum, they share many codes between them, c/c+, arduino code, libraries codes, etc, people that are not familiar with assembler would just need to donwload the best header for their application (as people in arduino do), i say just header because or "C" would be the ladder, pdf idea picture attach
Sat Jan 26 2019, 16:16:44, download attachment ldmicro black box editor idea.pdf
(no subject) (by Ziggy)
Alex,

This, Your above suggestion is similar to what Jose is doing.
He is providing DLmicro as we know it but with addition of "hooks" so that You and any other user can hook in additional C source code in the form of libraries ( like the include statement) and then everything gets compiled to hex.

You are saying assembler which makes it a bit more involved.

The problem with assembler code is it becomes complicated to determine offsets and function calls and splice the code in correctly.

It may be simpler to stick to the LDmicro paradigm and provide black boxes within LDmicro the way Ihor did it rather than to ask people to go through a crash course in handling the compilation process.
Sat Jan 26 2019, 21:18:31
(no subject) (by Josť GILLES)
Hi Alex

That's an idea, but you don't imagine the complexity of ldmicro source code, especially for "black box" compiling:

- the ladder is first translated into a pseudo code (called intcode) reproducing instructions sequence ; variables are mapped to symbols

- this pseudo code is then translated in asm/hex, in a different manner according to the target (AVR, PIC...) or in C language.

- in asm/hex memory must be manage for variables and jumps calculated in code...

- here's for instance the translation of a simple INC instruction on an AVR:

//-------------------------------------------
static void Increment(DWORD addr, int sov, char *name)
//used ZL, r25
{
LoadZAddr(addr); //2 instructions
Instruction(OP_LD_Z, r25); //1 instruction
Instruction(OP_INC, r25, 0, name);
//Instruction(OP_SUBI, r25, 0xFF); // r25 = r25 + 1
Instruction(OP_ST_ZP, r25);
if(sov >= 2) {
DWORD noCarry = AllocFwdAddr();
Instruction(OP_BRNE, noCarry);
//Instruction(OP_BRCS, noCarry);
Instruction(OP_LD_Z, r25); // now Z is addl+1
Instruction(OP_INC, r25, 0, name);
//Instruction(OP_SUBI, r25, 0xFF); // r25 = r25 + 1
Instruction(OP_ST_ZP, r25);
if(sov >= 3) {
Instruction(OP_BRNE, noCarry);
//Instruction(OP_BRCS, noCarry);
Instruction(OP_LD_Z, r25); // now Z is addr+2
Instruction(OP_INC, r25, 0, name);
//Instruction(OP_SUBI, r25, 0xFF); // r25 = r25 + 1
Instruction(OP_ST_ZP, r25);
if(sov >= 4) {
Instruction(OP_BRNE, noCarry);
//Instruction(OP_BRCS, noCarry);
Instruction(OP_LD_Z, r25); // now Z is addr+2
Instruction(OP_INC, r25, 0, name);
//Instruction(OP_SUBI, r25, 0xFF); // r25 = r25 + 1
Instruction(OP_ST_ZP, r25);
}
}
FwdAddrIsNow(noCarry); //5 or (6-9) or (6-10-13) instruction
}
// 5 instructions for 8 bit var;
// 6 or 9 instructions for 16 bit var;
// 6 or 10 or 13 instructions for 24 bit var;
// ? instructions for 32 bit var;
}
//-------------------------------------------

It's a kind of home made pseudo assembler (sov= size of variable) but not ASM
See now what I mean ?

To add a function (I2C, SPI) I have had to achieve several steps:

- create and add the design for function (in ladder view)

- associate the design to intcode mnemonics and manage associated variables and instructions

- manage associated pins

- translate incode into C declarations and calls according to target compiler (AVR, PIC, ARM)

- create corresponding C libraries

So, as you undestand, its impossible to add complex functions directly in ldmicro without being a developper and having a global idea of source code... Its not only target but model dependant and it requires many tests because an error can easily occur => boring

Your idea may drive to writing libraries in asm, but it's more simple to do in C, as Ziggy rightly said !

Josť
Sun Jan 27 2019, 04:05:37
(no subject) (by Alex)
I just understand
Sun Jan 27 2019, 08:51:48
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):