Jump to content

Boostc 1.6 And Mplab 6.6 - Modulo Arithmetic Error

Recommended Posts

Bug description:


With the following code, I get the listed output log as well as an MPLab message box:




#include <system.h>


#pragma CLOCK_FREQ 10000000


void main()


unsigned char ctemp = 0;


trise = 0x00;


while (1 == 1)


porte = ctemp++;

ctemp = ctemp % 8;






Output Log:


Clean: Deleting intermediary and output files.

Clean: Deleted file "test1.OBJ".

Clean: Deleted file "C:\Shared\Programming\BoostC\MPLabTest1\test1.HEX".

Clean: Done.

Executing: "C:\Program Files\SourceBoost\boostc.pic18.exe" test1.c -O0 -W2 -di -v -t18F452

BoostC Optimizing C Compiler Version 1.6 Alpha (for PIC18 architecture)


Copyright© 2004 Pavel Baranov

Copyright© 2004 David Hobday



test1.c success


Executing: "C:\Program Files\SourceBoost\linker.exe" "C:\Shared\Programming\BoostC\MPLabTest1\test1.obj" -O0 -v -t18F452

BoostLink Optimizing Linker Version 1.6 Alpha


Copyright© 2004 Pavel Baranov

Copyright© 2004 David Hobday

Optimisation level:0 - Off

Warning: Unable to successfully create 'delay_us' with clock freq 10000000 Hz

Error: Unresolved external function:_rem_8_8

Error: unresolved external symbol, function:_rem_8_8



Loaded C:\Shared\Programming\BoostC\MPLabTest1\test1.HEX

BUILD SUCCEEDED: Tue Nov 02 18:44:04 2004



Message Box:


"The end of the file has been reached unexpectedly; the hex file appears to have been corrupted."



Expected Behavior:


The code works fine if, instead of "ctemp = ctemp % 8;", I put the following:


if (ctemp > 7)

ctemp = 0;



IDE version: MPLab 6.60

Compiler: BoostC

Compiler version: 1.6

Target device: PIC18F452

OS: Windows XP Pro

Link to post
Share on other sites

If code uses */% operations it needs to link with libc library. When building from SourceBoost IDE this is done automatically. Otherwise you need to link with libc library using other means. (For libc library look into the 'lib' subdirectory in your SourceBoost installation directory).




Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...