News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Using ASM file in MPLAB to make HEX

Started by thetrueman, Sep 28, 2026, 08:49 PM

Previous topic - Next topic

thetrueman

Hi,

Is there any way to use Proton PicBasic generated .ASM file in MPLAB to convert it into HEX file to download it in PIC16F887? Thanks.

RGV250

PicBasic is a different compiler so I assume you are referring to Positron.
What is wrong with just compiling it to get the hex file?

Bob

Stephen Moss

As @RGV250 stated, PIC compilers generate .Hex files when you compile your code as those are the file that get uploaded to the device.

It has been a many years since I used the MPLAB IDE as using Positron to write & compile my code the MPLAB IDE take up a rediculous amount of space just to use for programming the device/debugging. But as I recall there is a menu option when you select the device, and for setting the configuration bits, I am not sure if it is in the latter or elsewhere that you can check an option to use the configuration bits in the .Hex file instead of those set manully in the configuration bits section of the IDE.

As I recall then all you do is open the file menu and select import to import your .Hex file.

thetrueman

A humble thanks to all. I just clearly state that I have a proposal of a program in PIC16F887 but the client want to get the source code which I don't want to give.

So I thought if I give them ASM file then is not problem for me. But that file should be able to compile into same Hex as PicBasic.

If I open ASM file in notepad, there is mentioned to include .PBP file or some other required files. Can anybody tell me which files should I put in a folder to compile them to HEX with mpasmwin.exe which is included in the PDS or can be downloaded as MPLAB IDE. Thanks.

RGV250

Hi,
Are you actually using Positron as there is no pbp file. I have just compiled a simple program and looked at the assembler and there is no mention there either.
I wonder if you should be on the PicBasicPro forum? https://store.melabs.com/components/compilers/

Regards,
Bob
 

thetrueman

Once using Proton+ I just created a test program for 16F676. Here is its .ASM file content which includes a .PBP file which is also generated in the same folder of .BAS file along with some other files.

NOLIST
 #include "D:\60HZ F676\60HZ.PBP"
 LIST

 INDEX = 35
#Define LED1HZ PORTC,0
#Define A60HZ PORTC,1
#Define B60HZ PORTC,2
#Define C60HZ PORTC,3
F1_SOF equ $ ; 60HZ.BAS
F1_000013 equ $ ; in [60HZ.BAS] Config XT_OSC, WDT_OFF, MCLRE_OFF, PWRTE_ON, BODEN_OFF
F1_000015 equ $ ; in [60HZ.BAS] OSCCAL = %00100000  '$20
Movlw 32
Bsf STATUS,5
ram_bank = 1
Movwf OSCCAL
F1_000016 equ $ ; in [60HZ.BAS] ALL_DIGITAL = True
Clrf ANSEL
Movlw 7
Bcf STATUS,5
ram_bank = 0
Movwf CMCON
F1_000018 equ $ ; in [60HZ.BAS] PORTA = 0 : PORTC = 0
Clrf PORTA
Clrf PORTC
F1_000019 equ $ ; in [60HZ.BAS] TRISA = %00111111
Movlw 63
Bsf STATUS,5
ram_bank = 1
Movwf TRISA
F1_000020 equ $ ; in [60HZ.BAS] TRISC = %00000000
Clrf TRISC
F1_000021 equ $ ; in [60HZ.BAS] PORTA = 0 : PORTC = 0
Bcf STATUS,5
ram_bank = 0
Clrf PORTA
Clrf PORTC
F1_000030 equ $ ; in [60HZ.BAS] CMCON = 7
Movlw 7
Movwf CMCON
F1_000031 equ $ ; in [60HZ.BAS] ADCON0 = %00000000
Clrf ADCON0
F1_000032 equ $ ; in [60HZ.BAS] ANSEL  = %00000000
Bsf STATUS,5
ram_bank = 1
Clrf ANSEL
F1_000040 equ $ ; in [60HZ.BAS] GoTo Start
Bcf STATUS,5
ram_bank = 0
Goto START
START
F1_000043 equ $ ; in [60HZ.BAS] A60Hz = 0
Bcf PORTC,1
F1_000044 equ $ ; in [60HZ.BAS] DelayUS 7365 : B60Hz = 0 : C60Hz = 0
Movlw 28
Movwf PP0H
Movlw 197
Call dlus@w
Bcf PORTC,2
Bcf PORTC,3
F1_000045 equ $ ; in [60HZ.BAS] DelayUS 1000 : B60Hz = 1 : C60Hz = 1
Movlw 3
Movwf PP0H
Movlw 232
Call dlus@w
Bsf PORTC,2
Bsf PORTC,3
F1_000046 equ $ ; in [60HZ.BAS] A60Hz = 1 : Inc Index
Bsf PORTC,1
Incf INDEX,F
F1_000047 equ $ ; in [60HZ.BAS] DelayUS 7365 : B60Hz = 0 : C60Hz = 0
Movlw 28
Movwf PP0H
Movlw 197
Call dlus@w
Bcf PORTC,2
Bcf PORTC,3
F1_000048 equ $ ; in [60HZ.BAS] DelayUS 1000 : B60Hz = 1 : C60Hz = 1
Movlw 3
Movwf PP0H
Movlw 232
Call dlus@w
Bsf PORTC,2
Bsf PORTC,3
F1_000050 equ $ ; in [60HZ.BAS] If Index = 30 Then Toggle LED1Hz : Index = 0
Movlw 30
Subwf INDEX,W
Btfss STATUS,2
Goto bc@LL2
Movlw 1
Xorwf PORTC,F
Bsf STATUS,5
ram_bank = 1
Bcf TRISC,0
Bcf STATUS,5
ram_bank = 0
Clrf INDEX
bc@LL2
F1_000052 equ $ ; in [60HZ.BAS] GoTo Start
Goto START
F1_000054 equ $ ; in [60HZ.BAS] End
Pb@lb4
Sleep
Goto Pb@lb4
F1_EOF equ $ ; 60HZ.BAS
 LIST
END


And here is .PBP file content...

LIST
LIST
;{
;FILE F1 = D:\60HZ F676\60HZ.BAS
;}
;[Variable Listing]
;INDEX,0023,DT_BYTE,1
;LED1HZ,0007.0,DT_BIT
;A60HZ,0007.1,DT_BIT
;B60HZ,0007.2,DT_BIT
;C60HZ,0007.3,DT_BIT
;[End Listing]
 #define CONFIG_REQ 1
 LIST  P = 16F676,f = INHX8M ,w = 2, x = on, r = DEC, mm = ON, n = 0, c = 255
 #include "C:\PROGRA~2\Proton\PDS\INC\P16F676.lpb"
 #define __16F676 1
 #define XTAL 4
 #define _CORE 14
 #define _MAXRAM 64
 #define _RAM_END 95
 #define _MAXMEM 1024
 #define _ADC 8
 #define _ADC_RES 10
 #define _EEPROM 128
 #define _PAGES 1
 #define _BANKS 2
 #define RAM_BANKS 1
 #define _USART 0
 #define _USB 0
 #define _FLASH 0
 #define BANK0_START 32
 #define BANK0_END 95
 #define _SYSTEM_VARIABLE_COUNT 3
ram_bank = 0
current@page = 0
dest@page = 0
 #define LCD#TYPE 0
__CONFIG XT_OSC&WDT_OFF&MCLRE_OFF&PWRTE_ON&BODEN_OFF
f@call macro dest
if (dest < 1)
else
if (dest > $)
else
endif
endif
call dest
endm
f@jump macro dest
if (dest < 1)
else
if (dest > $)
else
endif
endif
goto dest
endm
set@page macro dest
endm
s@b macro varin
if((varin & 384) == 0)
if(ram_bank == 1)
bcf 3,5
endif
if(ram_bank == 2)
bcf 3,6
endif
if(ram_bank == 3)
bcf 3,5
bcf 3,6
endif
ram_bank = 0
endif
if((varin & 384) == 128)
if(ram_bank == 0)
bsf 3,5
endif
if(ram_bank == 2)
bsf 3,5
bcf 3,6
endif
if(ram_bank == 3)
bcf 3,6
endif
ram_bank = 1
endif
if((varin & 384) == 256)
if(ram_bank == 0)
bsf 3,6
endif
if(ram_bank == 1)
bcf 3,5
bsf 3,6
endif
if(ram_bank == 3)
bcf 3,5
endif
ram_bank = 2
endif
endm
r@b macro
if((ram_bank & 1) != 0)
bcf 3,5
endif
if((ram_bank & 2) != 0)
bcf 3,6
endif
ram_bank = 0
endm
 #include "C:\PROGRA~2\Proton\PDS\INC\REG_LD14.INC"
PP0 = 32
PP0H = 33
PP4 = 34
org 0
goto Start@
dl@us clrf 33
dlus@w addlw 232
movwf 32
comf 33,f
movlw 252
skpc
goto $ + 4
addwf 32,f
skpnc
goto $ - 2
addwf 32,f
nop
incfsz 33,f
goto $ - 6
btfsc 32,0
goto $ + 1
btfss 32,1
goto $ + 3
nop
goto $ + 1
return
__XTAL = 4
Start@
main@prog@start

So can we merge these files to make a complete .ASM to be compile to generate .HEX in mpasmwin.exe? Thanks

RGV250

Hi,
Proton+ is over 10 years ago. I doubt anyone (apart from Les) would be able to answer your question.
Why not upgrade to the latest version which is far superior to the older one.
Positron is the reincarnation of Proton so virtually no learning curve.

Regards,
Bob

thetrueman

You are right... But old is gold and it seems very easy too me to make a program.
Sure I'll upgrade to Positron once I get the project but at the moment problem is source file to provide to client which I want to give ASM file. Thanks everyone.

JonW

Why not share the .bas file with the client? You can see the basic statements in that file you posted anyway.

You can create an asm project and strip out all of the asm code and combine the files.

The only other way to get raw asm is running the hex through disassembly and then create an asm project in mplab and paste in the asm.

In all honesty if I were sharing any code with a client I would want it clearly documented and if a third party compiler was used, then either buy the customer a copy or provide the exact build the compiler was at the time of writing.

I was under the impression that the asm produced by the compiler should assemble using mpasm

Pepe

Positron generates a single ASM file (as shown in the example where your sample program was compiled by Positron and simulated in Proteus); judging by what you've shown, Proton+ relied on multiple ASM files to compile with MPASMWin. If you look at the "60 hz.lst" file, it is—with a few differences—a combination of the two sample files you provided.

thetrueman

QuoteYou can create an asm project and strip out all of the asm code and combine the files.

@JonW Thanks for suggestions and just to clarify that I'm honest always but this client seems very clever to me to get source code and then maybe skip me. So to be on safe side I want to give them compile able ASM file (by removing BAS comments), not BAS file. Please take it positive.

@Pepe Can you confirm that single ASM file generated by Positron8 can compile exactly in mpasmwin.exe like Positron?
Also can we use same code of Proton+ in Positron8 without changing it? Thanks for your time.

RGV250

Hi,
QuoteAlso can we use same code of Proton+ in Positron8 without changing it?
Very unlikely as there have been many improvements in the last 10 years. It will probably need some fine tuning but without posting the code it would be impossible to say.

QuoteSo to be on safe side I want to give them compile able ASM file (by removing BAS comments), not BAS file
Do you actually know they will accept this, when I was at work if we got presented with an uncommented file it would be rejected. Also, it they have specified basic then ASM would not be accepted.
On a more realistic note, we would go back to programmers who did a job that was well written and fully commented so you may get by with this one job but lose out in the future.

Regards,
Bob

JonW

#12
This code is extremely simple; even in ASM, it will be easy for any engineer to understand.  If you have no contractual binds or have not signed NDA's then I would only supply hex and would ensure that the code is embedded deeply within the hex with bloat code and jumps, etc.

In the end, it's your IP, but if the customer has contracted this work to you, then by rights, they own it.  That's the risk with any consultant: if you educate the customer too much, you risk being bypassed.  Many customers insist on code to protect themselves against loss, not to rip you off.  Draft a document, have them sign it to protect your IP, and then send the code.






Stephen Moss

Quote from: thetrueman on Sep 30, 2026, 07:54 AM
QuoteYou can create an asm project and strip out all of the asm code and combine the files.

@JonW Thanks for suggestions and just to clarify that I'm honest always but this client seems very clever to me to get source code and then maybe skip me. So to be on safe side I want to give them compile able ASM file (by removing BAS comments), not BAS file. Please take it positive.
While not as easy to read as a .BAS file a .ASM file is still reasonably readable, so if your concern is that the client will subsequently alter the software without contracting you to do so I would say only provide the .HEX file only as at least if they tried to cut you out of any changes that would put then to the trouble of having to try and convert it back to something readable.

However, it really depends on the wording of any contract between you and the client so you should check into the copyright and any other applicable legalities of the situation yourself to be sure of where you stand.

I may be wrong but I think that if you are an independent contractor employed by a third party then you own the copyright to the software and so are not required to provide the client with the source code or intermediary files unless that was agreed to and explicitly stated in the contract between you before the contract is formally accepted by both parties, and/or the wording of the contract is such that you are relinquishing copyright of the software to the client, in which case the client would own the copyright to the software and so I doubt you would have any right to withhold any associated files from them.

Pepe

Positron generates only an ASM file, which can be reassembled using mpasmwin.exe; the IDE includes a tab to invoke the assembler, display the ASM file, and recompile it to generate the HEX file. However, the source code syntax—originally written for Proton+—must be adapted for Positron to ensure successful compilation without errors.

thetrueman

Thanks to all... The client is referred to me by a friend and the client want to take advantage to get the source code which normally we do not provide because of time cost investment. We don't have contract about this but the client want to take advantage by courtesy. Anyhow I'm just hesitant to be in loss after a lot of time spending on the project. So I thought just for formality I'll provide them ASM which is difficult to modify so that they could not skip me. And if they are so sharp to take advantage with ASM file then at least I'll not regret by not providing ready food in the shape of BAS file. Thanks for understanding.

The proposed project is a bit complicated which involves UART base LCD display so if it is possible to have compile able ASM file then I can buy Positron. So anybody can confirm about this by testing any their existing project like @Pepe described in the last message? Thanks.

trastikata

Did you actually confront the client as to why he wants the source code? This is a normal question to ask when being asked for the source and whatever his response might be, next question is how your rights will be guaranteed.

In my experience, direct honest common sense questions always work the best, no need of trying to outsmart the other person and it never works trying to make a fool of the other one.

If you hope getting more work from this person, then it is even better to make sure everything is clear now, before you start. If it was one time order - then what is the problem of settling the IP rights and payment scheme - payment based on usage and you provide the compiled code, or lump sum payment and you transfer the IP.



John Lawton

It can be a difficult question. My clients very rarely ask for the source code, but they usually keep being customers by requiring updates/changes and dare I say bug fixes :)

John
-----------------------------------------------------------------------------------------
Amicus 8 and 16A/16B dev boards
Especially created for Positron development
https://www.easy-driver.co.uk/Amicus

thetrueman

@trastikata We are honest but who knows other is honest. I've been ditched with such promises for future business but future does not come. Also different country and cultures practice different styles of business so I'm seeking technical way to avoid unexpected situation in future.

@JohnLawton usually my situation is same like you. Anyhow Thanks so much to all.

▲