Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Pic Basic

Status
Not open for further replies.

GatorGnet

New Member
I recently picked up a copy of Picbasic and have been testing some sample files through it to see how it converts. I am seeing some asm that doesn't look right. I'm pretty new to asm but I will let you guys take a look:


PB code in sample:
Code:
        Include "modedefs.bas"          ' Include serial modes
SO      con     0                       ' Define serial output pin
B       con     5                       ' Define Button input pin

B0      var     byte

B0 = 0				           ' Zero Button Working Buffer
loop:   Button B,1,10,5,B0,0,notp       ' Check Button (Skip if Not Pressed)
Serout SO,N2400,["Press",13,10]        ' Indicate Button Pressed
notp:   Serout SO,N2400,[#B0,13,10]     ' Show Working Variable
Pause 100			                     ' Visual Pause
Goto loop

asm output:
Code:
	INCLUDE	"16F628A.INC"

RAM_START       		EQU	00020h
RAM_END         		EQU	0014Fh
RAM_BANKS       		EQU	00003h
BANK0_START     		EQU	00020h
BANK0_END       		EQU	0007Fh
BANK1_START     		EQU	000A0h
BANK1_END       		EQU	000EFh
BANK2_START     		EQU	00120h
BANK2_END       		EQU	0014Fh
EEPROM_START    		EQU	02100h
EEPROM_END      		EQU	0217Fh

R0              		EQU	RAM_START + 000h
R1              		EQU	RAM_START + 002h
R2              		EQU	RAM_START + 004h
R3              		EQU	RAM_START + 006h
R4              		EQU	RAM_START + 008h
R5              		EQU	RAM_START + 00Ah
R6              		EQU	RAM_START + 00Ch
R7              		EQU	RAM_START + 00Eh
R8              		EQU	RAM_START + 010h
FLAGS           		EQU	RAM_START + 012h
GOP             		EQU	RAM_START + 013h
RM1             		EQU	RAM_START + 014h
RM2             		EQU	RAM_START + 015h
RR1             		EQU	RAM_START + 016h
RR2             		EQU	RAM_START + 017h
_B0              		EQU	RAM_START + 018h
_PORTL           		EQU	 PORTB
_PORTH           		EQU	 PORTA
_TRISL           		EQU	 TRISB
_TRISH           		EQU	 TRISA

; Constants.
_T2400           		EQU	00000h
_T1200           		EQU	00001h
_T9600           		EQU	00002h
_T300            		EQU	00003h
_N2400           		EQU	00004h
_N1200           		EQU	00005h
_N9600           		EQU	00006h
_N300            		EQU	00007h
_OT2400          		EQU	00008h
_OT1200          		EQU	00009h
_OT9600          		EQU	0000Ah
_OT300           		EQU	0000Bh
_ON2400          		EQU	0000Ch
_ON1200          		EQU	0000Dh
_ON9600          		EQU	0000Eh
_ON300           		EQU	0000Fh
_MSBPRE          		EQU	00000h
_LSBPRE          		EQU	00001h
_MSBPOST         		EQU	00002h
_LSBPOST         		EQU	00003h
_LSBFIRST        		EQU	00000h
_MSBFIRST        		EQU	00001h
_CLS             		EQU	00000h
_HOME            		EQU	00001h
_BELL            		EQU	00007h
_BKSP            		EQU	00008h
_TAB             		EQU	00009h
_CR              		EQU	0000Dh
_UnitOn          		EQU	00012h
_UnitOff         		EQU	0001Ah
_UnitsOff        		EQU	0001Ch
_LightsOn        		EQU	00014h
_LightsOff       		EQU	00010h
_Dim             		EQU	0001Eh
_Bright          		EQU	00016h
_SO              		EQU	00000h
_B               		EQU	00005h
	INCLUDE	"BUTTON.MAC"
	INCLUDE	"PBPPIC14.LIB"

	MOVE?CB	000h, _B0

	LABEL?L	_loop	
	BUTTONPIN?C	_B
	BUTTONDS?C	001h
	BUTTONDEL?C	00Ah
	BUTTONRATE?C	005h
	BUTTONTS?C	000h
	BUTTON?BL	_B0, _notp
	SERPIN?C	_SO
	SERMODE?C	_N2400
	SEROUT?C	050h
	SEROUT?C	072h
	SEROUT?C	065h
	SEROUT?C	073h
	SEROUT?C	073h
	SEROUT?C	00Dh
	SEROUT?C	00Ah

	LABEL?L	_notp	
	SERPIN?C	_SO
	SERMODE?C	_N2400
	SEROUTD?B	_B0
	SEROUT?C	00Dh
	SEROUT?C	00Ah
	PAUSE?C	064h
	GOTO?L	_loop

	END
 
Why are you trying to take apart a basic compilers results? It's going to be hard to read, compilers don't do things like people do.
 
Last edited:
The Basic compilers will out put pages of includes in assembly views and only use 10 or 20 lines in the code and it never looks like assembly to me If you want to no
been testing some sample files through it to see how it converts
It's easier to learn assembly then to learn how to read the output basic spits out
in asm
 
Especially if you use math routines. The ASM is gonna be a nightmare.
 
As long as it is valid ASM. I have used basic for years and feel more comfortable with it. However, I am still going to learn asm better.

This is part of the asm that looks "funny".

Code:
SEROUT?C	00Ah
	PAUSE?C	064h
 
It just loading some values from ram But like I said it's easier to learn assemble then to read that.
It sending what at (00Ah)
and if it reads (064h)
It done is all I can tell from that
 
As long as it is valid ASM. I have used basic for years and feel more comfortable with it. However, I am still going to learn asm better.

This is part of the asm that looks "funny".

Code:
SEROUT?C	00Ah
	PAUSE?C	064h
PBP asm is Macro Based, easier to read (sort of) but there's no chance you'll learn from it. If you open the .LST file, then it might help a little bit more. If you open the .LIB file in your \PBP folder, then you'll discover how each macro are made, but still, it's not 'pure' asm.

SEROUT?C 00Ah send 0A hex serially, PAUSE?C 064h is your PAUSE 100.
 
As long as it converts to hex for programming. Would I just use MPlab and convert this to a hex file? Sorry it has been a while with programming pics.
 
Mplab It will not convert a asm from pic basic to a hex assemby has no idea what
SEROUT?C 00Ah
PAUSE?C 064h
Is assembly is like this
Code:
#include <p16F690.inc>
     __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
     org 0
Start:
     bsf     STATUS,RP0       ; select Register Page 1
     bcf     TRISC,0          ; make IO Pin C0 an output
     bcf     STATUS,RP0       ; back to Register Page 0
     bsf     PORTC,0          ; turn on LED C0 (DS1)
     goto    $                ; wait here
     end
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top