Searching \ for '[SX]: Memory layout?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/ubicom/lib/mem/index.htm?key=memory
Search entire site for: 'Memory layout?'.

Exact match. Not showing close matches.
PICList Thread
'[SX]: Memory layout?'
2000\11\06@132937 by jamesnewton

picon face
Does anyone have some good ideas, doc's or samples that show more automatic
ways of getting the most out of the memory layout of the SX chips? Or the
PIC 16C5x chips?

I'm looking at using macros to re-org and compile jump tables and other
things that use a relative or computed jumps or calls (including all
subroutine entries) in a reserved chunk of "first half of page" memory.
Seems like a hell of a waste.

Ideally I'd like to find and document on the site the "best" layout of
memory in general (to support interrupts, debugging, subroutine placement
and calls, etc...) without having to shuffle things 500,000 times after each
code addition that over-runs the available "first half of page" space or
violates some other memory layout rule or ....

BTW, if you haven't seen the exhaustive "how to do a comparison" table at
www.sxlist.com/../scenix/lib/flow/compcon_sx.htm
and the SXKey Structured Programming macros built from it at
www.sxlist.com/techref/default.asp?url=scenix/keymacs.src
you might want to check it out. This version is much more stable than the
last. My testing hasn't found any bugs in a while so they may just work for
you!


---
James Newton 1-619-652-0593
spam_OUTjamesnewtonTakeThisOuTspamsxlist.com
SX FAQ: http://www.sxlist.com or .org

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use .....listservKILLspamspam@spam@mitvma.mit.edu?body=SET%20PICList%20DIGEST




2000\11\06@181436 by jamesnewton

face picon face
You sure? If you have an SX Key, try these out... I was playing around while
I was waiting for responses:

Subroutine MACRO
noexpand
;Usage: Define a Global lable, execute Subroutine, assign :Entry to the
value now
;set in SubEntryAddr. Continue the definition of the subroutine. Elsewhere,
call
;@Sub:Entry where Sub is the global lable you defined for the subroutine.
;Example
;SUB1   Subroutine
;:Entry = SubEntryAddr
;....
;       Call SUB1:Entry
_SubAddr = $
org LowHalfPage
SubEntryAddr = $
;if we got here, the pagesel bits must be set for here
IF ($ / $100) = (_SubAddr / $100)
jmp _SubAddr
ELSE
jmp @_SubAddr
 ENDIF
LowHalfPage = $
IF $+1 & $100
  ERROR 'Out of LowHalfPage Space'
  ENDIF
org _SubAddr
ENDM

GotoW MACRO
noexpand
_SaveAddr = $
org LowHalfPage
_GotoWPage = \1
REPT \0
 IF (\% / $100) <> (_GotoWPage / $100)
  _GotoWPage = \%;
  ENDIF
 ENDR
IF ($ / $100) = (_SaveAddr / $100)
cja WReg,\0,_SaveAddr
ELSE
CJA WReg,\0,@_SaveAddr
 ENDIF
IF _GotoWPage <> \1 ;has to be a big table
rl WReg
 IF \0 > 128
jc :TableMiddle
jmp PC+W
  REPT \0
   IF \% < 128
jmp @\%
    ENDIF
   IF $+1 & $100
    ERROR 'Out of LowHalfPage Space'
    ENDIF
   ENDR
  ENDIF ;\0 > 128
 ENDIF ;_GotoWPage <> \1
:TableMiddle
jmp PC+W
REPT \0
 IF _GotoWPage <> \1
  IF \% >= 128
jmp @\%
   ENDIF
 ELSE
jmp \%
  ENDIF
IF $+1 & $100
  ERROR 'Out of LowHalfPage Space'
  ENDIF
 ENDR
LowHalfPage = $
org _SaveAddr
:TableEnd
ENDM

LookupW MACRO
noexpand
;Defines an in-line DW/IREAD lookup table returns the 12 bit value indexed
by W in M:W.
;Affects M and W.
jmp @:TableEnd
:TableBegin
REPT \0
DW \%
ENDR
:TableEnd
MOV M,#:TableBegin>>8  ;upper 4-bits of table address
IREAD                  ;Retrieve data
;{use the data}
ENDM

       org 0
ISR ;Put the ISR here (or just a jump to the ISR somewere eles in memory.
:Out

;Jump tables are assembled here by the SUBROUTINE, and GOTOW macros.
LowHalfPage = $

       org 100
SUB1    Subroutine
:Entry = SubEntryAddr
       jmp :Out
:test
       ;so something
:Out

Main
       GotoW Main, ISR, SUB1
       LookupW Main, ISR, SUB1, 1, 2, 3
       call @SUB1:Entry        ;global call to subroutine
       call SUB1               ;local call to subroutine

---
James Newton 1-619-652-0593
jamesnewtonspamKILLspamsxlist.com
SX FAQ: http://www.sxlist.com

{Original Message removed}

2000\11\07@184207 by jamesnewton

face picon face
Ok, those were garbage, but these work a bit better... The idea is that
stuff you need to do with computation on the PC are replaced by a macro that
uses some (minor) smarts to A) compile a replacement (like with iread for
data lookups) B) put the subroutine entry jumps in the first low half page
if the subroutine is not already in the lower half of a code page C) compile
jump tables into the first low half page using page selects with each jump
only if the addresses it needs to get to are on different pages.

As long as there are less than 256 bytes used for the jump to the ISR, the
jumps to subroutines not in low half pages and the jump tables, memory will
take care of itsself... I think...

       RESET reset_entry

LookupW MACRO
noexpand
;Defines an in-line DW/IREAD lookup table which
;returns the 12 bit value indexed by W in M:W.
;Affects M and W.
expand
jmp @$+\0+2
; IF \0
_LookupWTableBegin = $
noexpand
REPT \0
expand
DW \%
noexpand
ENDR
_LookupWTableEnd = $
expand
IF _LookupWTableBegin & $FF <> 0
mov temp,w     ;WARNING temp modified by macro
mov w, #_LookupWTableBegin & $FF
add w, temp    ;offset from start of table
 ENDIF
mov m,#_LookupWTableBegin>>8
IF (_LookupWTableBegin / $100) <> (_LookupWTableEnd / $100)
snc            ;correct if carry
mov m,#_LookupWTableBegin>>8+1
ENDIF
iread          ;Retrieve data
noexpand
;{use the data}
ENDM

Subroutine MACRO
noexpand
;Usage: Define a Global lable, execute Subroutine, assign :Entry to the
value now
;set in SubEntryAddr. Continue the definition of the subroutine. Elsewhere,
call
;@Sub:Entry where Sub is the global lable you defined for the subroutine.
;Example
;SUB1   Subroutine
;:Entry = SubEntryAddr
;....
;       Call SUB1:Entry
_SubAddr = $
IF (_SubAddr & $100) <> 0
 org LowHalfPage
 SubEntryAddr = $
;if we got here, the pagesel bits must be set for here
 IF ($ / $100) = (_SubAddr / $100)
  expand
jmp _SubAddr
  noexpand
 ELSE
  expand
jmp @_SubAddr
  noexpand
  ENDIF
 LowHalfPage = $
 IF $+1 & $100
  ERROR 'Out of LowHalfPage Space'
  ENDIF
 org _SubAddr
ELSE ;The subroutine was already starting in a LowHalfPage
 SubEntryAddr = $
 ENDIF
ENDM

GotoW MACRO
noexpand
_SaveAddr = $
org LowHalfPage
_GotoWPage = \1
REPT \0
 IF (\% / $100) <> (\1 / $100)
  _GotoWPage = \% ;
  ENDIF
 ENDR
IF _GotoWPage <> \1 ;has to be a long jump table
 IF \0 > 127
  ERROR 'Since the addresses are in different pages, long jumps must be
used and no more than 127 entries can be supported'
  ENDIF
ELSE
 IF \0 > 255
  ERROR 'No more than 255 entries can be supported'
  ENDIF
 ENDIF
expand
_GotoWTableBegin = $
IF _GotoWPage = \1 AND (_GotoWPage / $100) <> 0
page \1
 ENDIF
jmp PC+W
noexpand
REPT \0
 IF _GotoWPage <> \1
expand
jmp @\%
noexpand
  IF $+2 & $100
   ERROR 'Out of LowHalfPage Space'
   ENDIF
 ELSE
expand
jmp \%
noexpand
  IF $+1 & $100
   ERROR 'Out of LowHalfPage Space'
   ENDIF
  ENDIF
 ENDR
LowHalfPage = $
org _SaveAddr
IF _GotoWPage <> \1 ;its a long jump table
expand
rl WReg
noexpand
  ENDIF
expand
jmp @_GotoWTableBegin
noexpand
ENDM

       org 0
ISR ;(Interrupt Service Routine) **********************
;put your ISR (or just a jump to it) here.
       jmp @VPS

:Out ;-------------------------------------------------
;The Virtual Peripherals are expected to jump back
; to @ISR:Out when done
       ; << added to correct bug in 9818 chips
               mov m,#WKEN_B   ;Enable Port B interrupts
               mov !rb,#rbIntMask
               mov m,#TRIS     ;Point mode back to ports
       ; end bug fix >>
               mov !option, #myOpts
               mov     w,#-IntPeriod           ;1
               retiw                           ;3
;retiw adds w to RTCC which avoids
;jitter due to variations in ISR path or latency.

TABLES ;***********************************************
;Jump tables are assembled here by the SUBROUTINE,
; and GOTOW macros.
LowHalfPage = $

       org $100        ;Leave space in the first LowHalfpage

STARTUP ***********************************************
reset_entry             ;must be in the first page
       jmp @MAIN

       org $+2 ;Leave space for the debugger

MAIN ;PROGRAM *****************************************
       GotoW Main, $800, ISR, SUB1, $800, $100, $200, $300, $400, $500, $600,
$700, $400, $500, $600, $700, $800
       GotoW Main, SUB1

       LookupW Main,ISR,SUB1, 1, 2, 3, 4095

       call @SUB1:Entry        ;global call to subroutine
;       call SUB1               ;local call to subroutine

VPS ;Virtual Peripherals ******************************
;Time slice kernal goes here
       mov w, --VPSSlice
       snz
       mov w, #VPSCount
       mov VPSSlice, w
       GotoW UART, PWM


UART ;Universal Asynchronous Receiver Transmitter
;(UART) Virtual Peripheral-----------------------------
;etc
       jmp @ISR:Out

PWM ;Pulse Width Modulation Virtual Peripheral --------
;etc
       jmp @ISR:Out


;SUBROUTINES ******************************************
;with luck, the main program and VPS will push this
;into a new LowHalfPage. Subroutines can be rearranged
;manually to help the macros save memory.

SUB1 Subroutine ;======================================
:Entry = SubEntryAddr
       nop
;do stuff
       jc @:Out
:test
       djnc 10,@:test
:Out

---
James Newton 1-619-652-0593
.....jamesnewtonKILLspamspam.....sxlist.com
SX FAQ: http://www.sxlist.com

{Original Message removed}

2000\11\09@145447 by jamesnewton

face picon face
More clean up...
www.sxlist.com/techref/default.asp?url=scenix/keymacs.src
now incorporates all the macros I've written, with more bug fixes, into a
program template and layout that aims to allow very automated coding without
worrying about long or short jumps, or subroutine or jump table placement.

It also automates the building of the options settings for the prescaler,
etc... and lays out some conditionals for number of pins, date code,
processor difference, etc...

---
James Newton EraseMEjamesnewtonspam_OUTspamTakeThisOuTgeocities.com 1-619-652-0593


{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2000 , 2001 only
- Today
- New search...