• AVR Freaks

Helpful ReplyHot!Searching for information to program modern asm

Page: 12345 > Showing page 1 of 5
Author
Meta
Senior Member
  • Total Posts : 138
  • Reward points : 0
  • Joined: 2008/02/11 06:33:46
  • Location: Spain
  • Status: offline
2017/08/16 01:11:53 (permalink)
0

Searching for information to program modern asm

Hello:

I am looking at www.microchip.com if there is a modern document for the PIC16F88 and PIC16F88x to program in assembler.

The assembler or modern asm is what I look for, since this method of programming was used before and now another one is used, for example:

Before it was used:
CBLOCK 0x20
VAR1
VAR2
VAR3
ENDC


Now used:
VAR UDATA 0x20 or VAR UDATA_SHR 0x20


Before it was used:
VAR1 EQU 0x4F
VAR2 EQU 0x47
VAR3 EQU 0x10


Now used:
VAR1 RES 1
VAR2 RES 1
VAR3 RES 1


In principle the asm code used:
ORG 0x00


Now used:
CODE


They are details that I want to learn in depth to have modern and effective asm codes.

Greetings.
#1
qhb
Superb Member
  • Total Posts : 9998
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 01:53:39 (permalink)
+1 (1)
The "old" and "new" you describe are "absolute mode" and "linking mode" (aka "relocatable mode").
You didn't mention which version of MPLABX you are using.
If it's MPLABX, you can find the assembler document on your hard drive at:
C:\Program Files (x86)\Microchip\MPLABX\v3.26\mpasmx\docs\MPASM_MPLINK_User_Guide.pdf
 
(Update the "v3.26" to match your version of MPLABX)
#2
Meta
Senior Member
  • Total Posts : 138
  • Reward points : 0
  • Joined: 2008/02/11 06:33:46
  • Location: Spain
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 02:55:36 (permalink)
0
Hello:

I found the guide and I use the MPLAB X v4.00 that I have installed.

Version of the guide, last updated: 2013.
 
Thanks.
#3
CinziaG
die fucking humans
  • Total Posts : 3144
  • Reward points : 0
  • Joined: 2016/12/07 14:20:36
  • Location: Wien
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 03:17:29 (permalink)
0
Yeah Smile it's not quite "old" and "new", rather different ways.
Relocatable is better, anyway. Absolute may look like a "quicker" (and dirtier), but actually Relocatable is quick and good, once you have a Template and tools working correctly.
Absolute may still give you some "tighter" control upon variable positioning, and also the needed BANKSEL instructions, though this will be not usually needed (and often dangerous!)

in 2018 you signed for your annihilation. in 2019 it will come ;) I promise
my most wonderful creations here
https://www.youtube.com/c...dPFRvtwsbSTXp6Sk6azGOQ
#4
Meta
Senior Member
  • Total Posts : 138
  • Reward points : 0
  • Joined: 2008/02/11 06:33:46
  • Location: Spain
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 03:48:50 (permalink)
0
Hello:

I made a code that works and displays the RAM bar.

How do I know when it is harvestable or absolute?
 
[CODE];************************************ PIC16F84A_Descompila.asm ************************************
;
;
;
; ZONA DE DATOS **********************************************************************

    LIST    P=16F84A
    INCLUDE    <P16F84A.INC>
    __CONFIG    _CP_OFF &  _WDT_OFF & _PWRTE_ON & _XT_OSC
    ERRORLEVEL   0,   -302

    
;******************************  MAPA DE MEMORIA   ****************************
Grupo    UDATA_SHR 0x0C
    RAM_1    RES 1
    RAM_2    RES 1
    RAM_3    RES 1
    RAM_4    RES 1
    Resultado   RES 1
    Resul_2    RES 1

; ZONA DE CÓDIGOS ********************************************************************

    CODE     0x00                    ; El programa comienza en la dirección 0.
Inicio
    bsf    STATUS,RP0                ; Acceso al Banco 1.
    clrf    TRISB                    ; Las líneas del Puerto B se configuran como salida.
    movlw    b'00011111'                ; Las 5 líneas del Puerto A se configuran como entrada.
    movwf    TRISA
    bcf    STATUS,RP0                ; Acceso al Banco 0.

Principal
    movlw    0x11                    ; Carga el valor 0x11
    movwf    RAM_1                    ; en la RAM_1.
    movlw    0x12
    movwf    RAM_2
    movlw    0x13
    movwf    RAM_3
    movlw    0x14
    movwf    RAM_4
    
    movlw    RAM_1
    addwf    Resultado, W
    addwf    Resultado, F
    
    movwf    Resul_2
    
    goto    $
    
    END

[/CODE]

Greetings.
#5
CinziaG
die fucking humans
  • Total Posts : 3144
  • Reward points : 0
  • Joined: 2016/12/07 14:20:36
  • Location: Wien
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 03:51:30 (permalink)
0
RES is for relocatable, definitely Smile
 
You don't usually need "UDATA_SHR 0x0C" , a simple UDATA will be ok to start with.
 
Also, note that code tags are lower case.

in 2018 you signed for your annihilation. in 2019 it will come ;) I promise
my most wonderful creations here
https://www.youtube.com/c...dPFRvtwsbSTXp6Sk6azGOQ
#6
Meta
Senior Member
  • Total Posts : 138
  • Reward points : 0
  • Joined: 2008/02/11 06:33:46
  • Location: Spain
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 04:06:21 (permalink)
0
Hello:

If I use UDATA when compiling it produces error.
 
CLEAN SUCCESSFUL (total time: 203ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'C:/Users/Meta/MPLABXProjects/PIC16F84A/dist/default/production'
make  -f nbproject/Makefile-default.mk dist/default/production/production.production.hex
make[2]: Entering directory 'C:/Users/Meta/MPLABXProjects/PIC16F84A/dist/default/production'
"C:\Program Files (x86)\Microchip\MPLABX\v4.00\mpasmx\mpasmx.exe" -q -p16f84a -l"build/default/production/PIC16F84A_Descompila.lst" -e"build/default/production/PIC16F84A_Descompila.err" -o"build/default/production/PIC16F84A_Descompila.o" "PIC16F84A_Descompila.asm"
Warning[207] C:\USERS\META\MPLABXPROJECTS\PIC16F84A\DIST\DEFAULT\PRODUCTION\PIC16F84A_DESCOMPILA.ASM 15 : Found label after column 1. (RAM_1)
Warning[207] C:\USERS\META\MPLABXPROJECTS\PIC16F84A\DIST\DEFAULT\PRODUCTION\PIC16F84A_DESCOMPILA.ASM 16 : Found label after column 1. (RAM_2)
Warning[207] C:\USERS\META\MPLABXPROJECTS\PIC16F84A\DIST\DEFAULT\PRODUCTION\PIC16F84A_DESCOMPILA.ASM 17 : Found label after column 1. (RAM_3)
Warning[207] C:\USERS\META\MPLABXPROJECTS\PIC16F84A\DIST\DEFAULT\PRODUCTION\PIC16F84A_DESCOMPILA.ASM 18 : Found label after column 1. (RAM_4)
Warning[207] C:\USERS\META\MPLABXPROJECTS\PIC16F84A\DIST\DEFAULT\PRODUCTION\PIC16F84A_DESCOMPILA.ASM 19 : Found label after column 1. (Resultado)
Warning[207] C:\USERS\META\MPLABXPROJECTS\PIC16F84A\DIST\DEFAULT\PRODUCTION\PIC16F84A_DESCOMPILA.ASM 20 : Found label after column 1. (Resul_2)
"C:\Program Files (x86)\Microchip\MPLABX\v4.00\mpasmx\mplink.exe"    -p16f84a  -w  -m"dist/default/production/production.production.map"   -z__MPLAB_BUILD=1  -odist/default/production/production.production.cof  build/default/production/PIC16F84A_Descompila.o     
MPLINK 5.08, LINKER
Device Database Version 1.38
Copyright (c) 1998-2011 Microchip Technology Inc.
Error - section 'Grupo' can not fit the absolute section. Section 'Grupo' start=0x0000000c, length=0x00000006
Errors    : 1

nbproject/Makefile-default.mk:124: recipe for target 'dist/default/production/production.production.hex' failed
make[2]: Leaving directory 'C:/Users/Meta/MPLABXProjects/PIC16F84A/dist/default/production'
nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/Meta/MPLABXProjects/PIC16F84A/dist/default/production'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[2]: *** [dist/default/production/production.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 4s)
 
;)
#7
1and0
Access is Denied
  • Total Posts : 9623
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 04:18:35 (permalink)
+1 (1)
Meta
If I use UDATA when compiling it produces error.
 
...
Warning[207] C:\USERS\META\MPLABXPROJECTS\PIC16F84A\DIST\DEFAULT\PRODUCTION\PIC16F84A_DESCOMPILA.ASM 15 : Found label after column 1. (RAM_1)
...
Error - section 'Grupo' can not fit the absolute section. Section 'Grupo' start=0x0000000c, length=0x00000006

For the 16F84A, you cannot use the UDATA directive as this PIC device has _only_ shared data memory; so use UDATA_SHR instead and without the absolute address.
 
"Found label after column 1" should be self-explanatory. ;)
 
 
#8
CinziaG
die fucking humans
  • Total Posts : 3144
  • Reward points : 0
  • Joined: 2016/12/07 14:20:36
  • Location: Wien
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 04:59:22 (permalink)
0
Nice to know - that old stuff Smile
(tho, in my mind, in such a case "UDATA" should default back to "UDATA_SHR" ...  :) )

in 2018 you signed for your annihilation. in 2019 it will come ;) I promise
my most wonderful creations here
https://www.youtube.com/c...dPFRvtwsbSTXp6Sk6azGOQ
#9
Meta
Senior Member
  • Total Posts : 138
  • Reward points : 0
  • Joined: 2008/02/11 06:33:46
  • Location: Spain
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 05:04:18 (permalink)
+1 (1)
Good Morning:

How can I know when a PIC is compatible with UDATA and which ones are not?
 
How do I avoid the warnings?

Greetings.
#10
vloki
Jo, alla!
  • Total Posts : 6805
  • Reward points : 0
  • Joined: 2007/10/15 00:51:49
  • Location: Germany
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 05:20:58 (permalink)
+1 (1)
Meta
How can I know when a PIC is compatible with UDATA and which ones are not?

You simply have to read the data sheet and the assemblers user guide ;-)
 
In the data sheet you will find the memory organization (whether the RAM is organized in BANKs)
In the user guide you should find the meaning of UDATA, UDATA_SHR, UDATA_ACCESS ...

Uffbasse !
#11
Meta
Senior Member
  • Total Posts : 138
  • Reward points : 0
  • Joined: 2008/02/11 06:33:46
  • Location: Spain
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 06:02:40 (permalink)
0
Good:

PIC16F84A will be organized in banks.
PIC16F88 as well.
PIC16F18875 Any ideas?

Greetings.
#12
vloki
Jo, alla!
  • Total Posts : 6805
  • Reward points : 0
  • Joined: 2007/10/15 00:51:49
  • Location: Germany
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 06:20:15 (permalink)
+1 (1)
f*ck that damn forum:
Meta
...

sad
post edited by vloki - 2017/08/16 06:23:47

Uffbasse !
#13
vloki
Jo, alla!
  • Total Posts : 6805
  • Reward points : 0
  • Joined: 2007/10/15 00:51:49
  • Location: Germany
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 06:21:42 (permalink)
+1 (1)

Access Denied

You don't have permission to access "http://www.microchip.com/forums/post.aspx?" on this server.
Reference #18.14bf1402.1502889664.131a7e3c

Uffbasse !
#14
vloki
Jo, alla!
  • Total Posts : 6805
  • Reward points : 0
  • Joined: 2007/10/15 00:51:49
  • Location: Germany
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 06:23:22 (permalink)
+1 (1)
3.2 Data Memory Organization
The data memory is partitioned into 32 memory banks
with 128 bytes in each bank.

 
Common RAM
(Accesses 70h – 7Fh)

 
Or view the linker script in: ... /microchip/mplabx/vX.YZ/mpasmx/LKR
Or the template in ...microchip/mplabx/vX.YZ/mpasmx/templates/Object
post edited by vloki - 2017/08/16 06:57:00

Uffbasse !
#15
Meta
Senior Member
  • Total Posts : 138
  • Reward points : 0
  • Joined: 2008/02/11 06:33:46
  • Location: Spain
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 06:51:23 (permalink)
+1 (1)
The data memory is partitioned into 32 memory banks
with 128 bytes in each bank. Each bank consists of
(
Figure 3-2
):
• 12 core registers
• 20 Special Function Registers (SFR)
• Up to 80 bytes of General Purpose RAM (GPR)
• 16 bytes of common RAM
The active bank is selected by writing the bank number
into the Bank Select Register (BSR). Unimplemented
memory will read as ‘
0
’. All data memory can be
accessed either directly (via instructions that use the
file registers) or indirectly via the two File Select
Registers (FSR). See
Section 3.5 “Indirect
Addressing””
for more information.
Data memory uses a 12-bit address. The upper five bits
of the address define the Bank address and the lower
seven bits select the registers/RAM in that bank.
 

COMMON RAM
There are 16 bytes of common RAM accessible from all
banks.

It tells you that you can change the 32 banks of memory.
Where does it tell you how to change the bank you want?

The STATUS register does not work as in the PIC16F88.

I know it can be changed with the BANKSEL directive on the PIC16F886, PIC18F2550.

Is there any way to use the same BANKSEL method to switch banks for the PIC16F18875?
#16
qhb
Superb Member
  • Total Posts : 9998
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 06:57:55 (permalink)
+2 (2)
Meta
It tells you that you can change the 32 banks of memory.
Where does it tell you how to change the bank you want?

In the datasheet. It's done using the MOVLB instruction.
 

The STATUS register does not work as in the PIC16F88.

I know it can be changed with the BANKSEL directive on the PIC16F886, PIC18F2550.

Is there any way to use the same BANKSEL method to switch banks for the PIC16F18875?

Yes. Just use it. The assembler knows what to do already.
 
#17
vloki
Jo, alla!
  • Total Posts : 6805
  • Reward points : 0
  • Joined: 2007/10/15 00:51:49
  • Location: Germany
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 07:05:07 (permalink)
+1 (1)
MetaThe active bank is selected by writing the bank number
into the Bank Select Register (BSR).


MetaI know it can be changed with the BANKSEL directive on the PIC16F886, PIC18F2550.
Is there any way to use the same BANKSEL method to switch banks for the PIC16F18875?
Should work the exactly the same way.



Uffbasse !
#18
Meta
Senior Member
  • Total Posts : 138
  • Reward points : 0
  • Joined: 2008/02/11 06:33:46
  • Location: Spain
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 07:35:00 (permalink)
0

 
http://technology.niagara...ruction_Set/MOVLB.html
 
Trying to make an example by switching banks with MOVLB.
For example:
I'm in the bank 0.
Change to bank 17.
Change to bank 28
Change to bank 31
Change to bank 5
Change to bank 22
Change to bank 3

To name some. It is to catch the trick is the MOVLB instruction.
#19
1and0
Access is Denied
  • Total Posts : 9623
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Searching for information to program modern asm 2017/08/16 07:47:42 (permalink)
+1 (1)
Just use the BANKSEL directive. It will assemble to the correct instruction(s) for the PIC device you used.
 
Regarding the various UDATA directives, they are used to reserve variables in the GPRs _only_. The plain UDATA directive reserves variables in the banked GPRs. The UDATA_SHR directive reserves variables in the shared (common) data memory. PIC18 devices have the UDATA_ACS directive to reserve variables in the access RAM.
#20
Page: 12345 > Showing page 1 of 5
Jump to:
© 2019 APG vNext Commercial Version 4.5