News:

;) This forum is the property of Proton software developers

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.

▲