|
|
|
(you are viewing a thread; or go back to
list of threads)
avr.cpp - CompileAvr() (by Xiao Feng)
Hi, I have research the source code in one month, there has also some question.
First, how to write the similar CompileAvr() for 8051, the ports(.h) are no problem, but how to use the Instruction() is so hard for me.
Second, the HEX file can write into the chip directly? I know the PLC should have its own inside scan program. The compileAvr() contains it?
Thank you for your excellent share.
Best wishes.
(no subject) (by Jonathan Westhues)
The function Instruction() passes an instruction to the assembler built in to LDmicro. The assembler is fairly simple; the only jobs that it does are to represent the instruction in the specified bit format, and to resolve forward references. Since LDmicro contains that assembler, its output is native binary code for the target, and the .hex file can be written to the chip directly.
Beyond the compiled logic, the program also must contain the infrastructure to periodically run that logic, with period equal to the scan time. That infrastructure code is also generated by avr.cpp, in the function WriteRuntime().
continue (by Xiao Feng)
Dear Jonathan Westhues,
Thank you!
But the following question is below:
First,such as
LoadXAddr(Prog.mcu->ram[0].start + Prog.mcu->ram[0].len);
Instruction(OP_LDI, 16, 0);
Instruction(OP_LDI, 18, (Prog.mcu->ram[0].len) & 0xff);
Instruction(OP_LDI, 19, (Prog.mcu->ram[0].len) >> 8);
DWORD loopZero;
loopZero = AvrProgWriteP;
Instruction(OP_SUBI, 26, 1);
Instruction(OP_SBCI, 27, 0);
Instruction(OP_ST_X, 16, 0);
Instruction(OP_SUBI, 18, 1);
Instruction(OP_SBCI, 19, 0);
Instruction(OP_TST, 18, 0);
Instruction(OP_BRNE, loopZero, 0);
Instruction(OP_TST, 19, 0);
Instruction(OP_BRNE, loopZero, 0);
could you introduce the theory simple?
And where is the scan beginning point?
The .HEX file could carry out on time and on sign?
Second,I find the PIC16.cpp has great different from the AVR.cpp, what configuration must be needed?
Best wishes!
(no subject) (by Jonathan Westhues)
I'm afraid there is no simple way to explain this. Code like the above generates AVR (or PIC16, in pic16.cpp) assembly language instructions, that then get assembled into the binary output. To understand how they work, it's necessary to understand the instruction set and peripherals of the micro, which are typically documented in its datasheet.
Post a reply to this comment:
|