summaryrefslogtreecommitdiff
path: root/ldmicro
diff options
context:
space:
mode:
authorRr422018-06-23 14:31:58 +0530
committerRr422018-06-23 14:31:58 +0530
commit27ba12ab2e6014f80b7391a5f765f6cd657f5707 (patch)
tree5d684fddf12c626603f0f795ec5f7e2d3d84525d /ldmicro
parentdde93f78fd502ff62d7977460faf1d20a3f98c54 (diff)
downloadLDMicroGtk-27ba12ab2e6014f80b7391a5f765f6cd657f5707.tar.gz
LDMicroGtk-27ba12ab2e6014f80b7391a5f765f6cd657f5707.tar.bz2
LDMicroGtk-27ba12ab2e6014f80b7391a5f765f6cd657f5707.zip
Fixed bug where ladder program did not compile from GUI.
Diffstat (limited to 'ldmicro')
-rw-r--r--ldmicro/compilecommon.cpp2
-rw-r--r--ldmicro/ldmicro.cpp15
-rw-r--r--ldmicro/maincontrols.cpp2
-rw-r--r--ldmicro/miscutil.cpp2
-rw-r--r--ldmicro/pic16.cpp23
5 files changed, 24 insertions, 20 deletions
diff --git a/ldmicro/compilecommon.cpp b/ldmicro/compilecommon.cpp
index a25d742..f66e7f9 100644
--- a/ldmicro/compilecommon.cpp
+++ b/ldmicro/compilecommon.cpp
@@ -118,8 +118,8 @@ static void MemForPin(char *name, DWORD *addr, int *bit, BOOL asInput)
if(strcmp(Prog.io.assignment[i].name, name)==0)
break;
}
- if(i >= Prog.io.count) oops();
+ if(i >= Prog.io.count) oops();
if(asInput && Prog.io.assignment[i].type == IO_TYPE_DIG_OUTPUT) oops();
if(!asInput && Prog.io.assignment[i].type == IO_TYPE_DIG_INPUT) oops();
diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp
index e2a36d8..dd40cd7 100644
--- a/ldmicro/ldmicro.cpp
+++ b/ldmicro/ldmicro.cpp
@@ -154,7 +154,7 @@ static void CompileProgram(BOOL compileAs)
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
- ofn.parentWindow = NULL;
+ ofn.parentWindow = MainWindow;
ofn.lpstrTitle = _("Compile To");
if(Prog.mcu && Prog.mcu->whichIsa == ISA_ANSIC) {
ofn.lpstrFilter = C_PATTERN;
@@ -178,12 +178,12 @@ static void CompileProgram(BOOL compileAs)
}
if(!GenerateIntermediateCode()) return;
-
+
if(Prog.mcu == NULL) {
Error(_("Must choose a target microcontroller before compiling."));
return;
}
-
+
if(UartFunctionUsed() && Prog.mcu->uartNeeds.rxPin == 0) {
Error(_("UART function used but not supported for this micro."));
return;
@@ -193,7 +193,7 @@ static void CompileProgram(BOOL compileAs)
Error(_("PWM function used but not supported for this micro."));
return;
}
-
+
switch(Prog.mcu->whichIsa) {
case ISA_AVR: CompileAvr(CurrentCompileFile); break;
case ISA_PIC16: CompilePic16(CurrentCompileFile); break;
@@ -203,7 +203,8 @@ static void CompileProgram(BOOL compileAs)
default: oops();
}
- IntDumpListing("t.pl");
+
+ IntDumpListing("t.pl");
}
//-----------------------------------------------------------------------------
@@ -286,7 +287,7 @@ void ProgramChanged(void)
{
ProgramChangedNotSaved = TRUE;
GenerateIoListDontLoseSelection();
- // RefreshScrollbars();
+ RefreshScrollbars();
}
#define CHANGING_PROGRAM(x) { \
UndoRemember(); \
@@ -1178,7 +1179,7 @@ int main(int argc, char** argv)
}
GenerateIoListDontLoseSelection();
- RefreshScrollbars();
+ RefreshScrollbars();
UpdateMainWindowTitleBar();
// MSG msg;
diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp
index e964aa1..93136d5 100644
--- a/ldmicro/maincontrols.cpp
+++ b/ldmicro/maincontrols.cpp
@@ -980,7 +980,7 @@ void GenerateIoListDontLoseSelection(void)
break;
}
}
- // IoListSelectionPoint = GenerateIoList(IoListSelectionPoint);
+ IoListSelectionPoint = GenerateIoList(IoListSelectionPoint);
// can't just update the listview index; if I/O has been added then the
// new selection point might be out of range till we refill it
diff --git a/ldmicro/miscutil.cpp b/ldmicro/miscutil.cpp
index 777b721..fb3275a 100644
--- a/ldmicro/miscutil.cpp
+++ b/ldmicro/miscutil.cpp
@@ -102,7 +102,7 @@ void Error(char *str, ...)
printf("%s\n", buf);
} else {
//HWND h = GetForegroundWindow();
- //MessageBox(h, buf, _("LDmicro Error"), MB_OK | MB_ICONERROR);
+ MessageBox(MainWindow, buf, _("LDmicro Error"), MB_OK | MB_ICONERROR);
}
}
diff --git a/ldmicro/pic16.cpp b/ldmicro/pic16.cpp
index a813420..d45eabb 100644
--- a/ldmicro/pic16.cpp
+++ b/ldmicro/pic16.cpp
@@ -508,7 +508,7 @@ static void CompileFromIntermediate(BOOL topLevel)
// Keep track of which 2k section we are using. When it looks like we
// are about to run out, fill with nops and move on to the next one.
DWORD section = 0;
-
+
for(; IntPc < IntCodeLen; IntPc++) {
// Try for a margin of about 400 words, which is a little bit
// wasteful but considering that the formatted output commands
@@ -518,6 +518,7 @@ static void CompileFromIntermediate(BOOL topLevel)
if(topLevel && (((PicProgWriteP + 400) >> 11) != section) &&
((PicProgWriteP + 400) < Prog.mcu->flashWords))
{
+
// Jump to the beginning of the next section
Instruction(OP_MOVLW, (PicProgWriteP >> 8) + (1<<3), 0);
Instruction(OP_MOVWF, REG_PCLATH, 0);
@@ -532,7 +533,7 @@ static void CompileFromIntermediate(BOOL topLevel)
}
IntOp *a = &IntCode[IntPc];
switch(a->op) {
- case INT_SET_BIT:
+ case INT_SET_BIT:
MemForSingleBit(a->name1, FALSE, &addr, &bit);
SetBit(addr, bit);
break;
@@ -579,7 +580,7 @@ static void CompileFromIntermediate(BOOL topLevel)
CompileIfBody(condFalse);
break;
}
- case INT_IF_VARIABLE_LES_LITERAL: {
+ case INT_IF_VARIABLE_LES_LITERAL: {
DWORD notTrue = AllocFwdAddr();
DWORD isTrue = AllocFwdAddr();
DWORD lsbDecides = AllocFwdAddr();
@@ -693,7 +694,7 @@ static void CompileFromIntermediate(BOOL topLevel)
CompileIfBody(notTrue);
break;
}
- case INT_SET_VARIABLE_TO_VARIABLE:
+ case INT_SET_VARIABLE_TO_VARIABLE:
MemForVariable(a->name1, &addrl, &addrh);
MemForVariable(a->name2, &addrl2, &addrh2);
@@ -708,7 +709,7 @@ static void CompileFromIntermediate(BOOL topLevel)
// results if the destination and one of the operands happen to
// be the same registers (e.g. for B = A - B).
- case INT_SET_VARIABLE_ADD:
+ case INT_SET_VARIABLE_ADD:
MemForVariable(a->name1, &addrl, &addrh);
MemForVariable(a->name2, &addrl2, &addrh2);
MemForVariable(a->name3, &addrl3, &addrh3);
@@ -746,7 +747,7 @@ static void CompileFromIntermediate(BOOL topLevel)
Instruction(OP_DECF, addrh, DEST_F);
break;
- case INT_SET_VARIABLE_MULTIPLY:
+ case INT_SET_VARIABLE_MULTIPLY:
MultiplyNeeded = TRUE;
MemForVariable(a->name1, &addrl, &addrh);
@@ -823,7 +824,7 @@ static void CompileFromIntermediate(BOOL topLevel)
break;
}
- case INT_UART_RECV: {
+ case INT_UART_RECV: {
MemForVariable(a->name1, &addrl, &addrh);
MemForSingleBit(a->name2, TRUE, &addr, &bit);
@@ -1171,7 +1172,7 @@ static void CompileFromIntermediate(BOOL topLevel)
oops();
break;
}
- if(((PicProgWriteP >> 11) != section) && topLevel) {
+ if(((PicProgWriteP >> 11) != section) && topLevel) {
// This is particularly prone to happening in the last section,
// if the program doesn't fit (since we won't have attempted
// to add padding).
@@ -1415,6 +1416,7 @@ void CompilePic16(char *outFile)
WipeMemory();
AllocStart();
+
Scratch0 = AllocOctetRam();
Scratch1 = AllocOctetRam();
Scratch2 = AllocOctetRam();
@@ -1423,7 +1425,7 @@ void CompilePic16(char *outFile)
Scratch5 = AllocOctetRam();
Scratch6 = AllocOctetRam();
Scratch7 = AllocOctetRam();
-
+
// Allocate the register used to hold the high byte of the EEPROM word
// that's queued up to program, plus the bit to indicate that it is
// valid.
@@ -1435,6 +1437,7 @@ void CompilePic16(char *outFile)
// bootloaders rewrite the beginning of the program to do their magic.
// PCLATH is init to 0, but apparently some bootloaders want to see us
// initialize it again.
+
Instruction(OP_BCF, REG_PCLATH, 3);
Instruction(OP_BCF, REG_PCLATH, 4);
Instruction(OP_GOTO, progStart, 0);
@@ -1576,7 +1579,7 @@ void CompilePic16(char *outFile)
ComplainAboutBaudRateError(divisor, actual, percentErr);
}
if(divisor > 255) ComplainAboutBaudRateOverflow();
-
+
WriteRegister(REG_SPBRG, divisor);
WriteRegister(REG_TXSTA, 0x20); // only TXEN set
WriteRegister(REG_RCSTA, 0x90); // only SPEN, CREN set