• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::


Browsing this Thread:   1 Anonymous Users






關於 PICFORTH
#1
新會員
新會員


查看用戶資訊
請問 有沒有人用 PICFORTH v 1.2.5

大家可以一起討論研究研究
我現在正在改
1 FILE BANK 切換的程序
因 bank 切換 不影嚮 fsr 取消 回0bank 指令 ,兩個指位器不一樣
00 02 03 04 0A 0B 70~7f 為共用區 可在不切bank時 讀寫資料

2 P16F690 的 FILE NAME
從 p16f88/87 改為 690
(下一步 p14 reg 改為 include 方式)
3 變數位址 (variable )
改從 70~ 7f (共用區) 當全域變數用
(下一步 變數 分 全域 區域 )
基本上 14BIT 指令都一樣
只要改 2項即可

1 跟 3 為了減少多切 bank的指令




發表於: 2007/10/16 13:39
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於 PICFORTH
#2
新會員
新會員


查看用戶資訊
使用 patch -p1
=== patch picforth.fs 1.2.5 =========
--- picforth.fs Wed Dec 29 20:31:50 2004
+++ \temp\picforth-1.2.5\picforth.fs Tue Oct 16 16:46:58 2007
@@ -171,7 +171,7 @@
bank0

host
-
+70 data-org
\ tcompile is the equivalent of state for the cross-compiler

: set true swap ! ;
@@ -187,12 +187,22 @@
variable current-bank

: bank ( a -- n ) 180 and ;
+: chkfile ( a -- tf)
+ dup
+ 7b and 00 xor 0= \ 0 4 and fb =0
+ over
+ 76 and 02 xor 0= \ a b 2 3 and f6 , xor 02 =0
+ or swap
+ 70 and 70 xor 0=
+ or
+;

: check-bank ( a -- a )
tcompile? if exit then \ The compiler takes care of banks
+ dup chkfile 0<> if exit then
dup bank current-bank @ <> if
- s" wrong bank may be selected" warning
- then ;
+ s" wrong bank may be selected" warning
+ then ;

\ We are not being strict here. At this time, we assume that all the
\ code fits in 8kwords (13 bits addressing) and that main data fits in one
@@ -446,9 +456,10 @@
: nop 000 cs, ;
: retfie 009 cs, ;
: check-default-bank ( -- )
- current-bank @ if
- s" call, goto or return with possible non-0 bank selected" warning
- then ;
+\ current-bank @ if
+\ s" call, goto or return with possible non-0 bank selected" warning
+\ then ;
+;
: return check-default-bank 008 cs, ;
: sleep 063 cs, ;

@@ -1046,7 +1057,7 @@
: t-name ( addr -- ) 3 cells + @ count ;
: t-previous ( addr -- addr' ) 2 cells + @ ;
: t-length ( addr -- n ) 1 cells + @ ;
-
+: t-bank ( bank -- bank' ) 4 cells + @ ;
\ Code bank handling

variable current-cbank
@@ -1290,12 +1301,17 @@

target

+
+
+
\ Temporary variables
udata
variable tmp1
variable tmp2
idata

+20 set-stack-size
+
host

\ Words to manipulate temporary variables
@@ -1375,41 +1391,80 @@

\ Adjust the current bank so that it can appropriately select the right
\ address in memory
-
+: rp0bcf ( -- ) reg-rp0 bcf ;
+: rp1bcf ( -- ) reg-rp1 bcf ;
+: bank0chk ( bank -- )
+ case
+ 80 of rp0bsf endof
+ 100 of rp1bsf endof
+ 180 of rp0bsf rp1bsf endof
+ endcase
+;
+: bank1chk ( bank -- )
+ case
+ 00 of rp0bcf endof
+ 100 of rp0bcf rp1bsf endof
+ 180 of rp1bsf endof
+ endcase
+;
+
+: bank2chk ( banf -- )
+ case
+ 00 of rp1bcf endof
+ 80 of rp1bcf rp0bsf endof
+ 180 of rp0bsf endof
+ endcase
+;
+
+: bank3chk ( bank -- )
+ case
+ 00 of rp1bcf rp0bcf endof
+ 80 of rp1bcf endof
+ 100 of rp0bcf endof
+ endcase
+;
+
: adjust-bank ( a -- a )
+ dup chkfile 0<> if exit then \ a
suspend-warnings >r
- case dup bank dup current-bank !
- 80 of rp0bsf endof
- 100 of rp1bsf endof
- 180 of rp0bsf rp1bsf endof
- endcase
+\ 0= if
+ case dup bank dup current-bank @ \ a ba ba cba
+ 00 of bank0chk endof \ a ba ba
+ 80 of bank1chk endof
+ 100 of bank2chk endof
+ 180 of bank3chk endof
+\ 00 of rp1bcf rp0bcf endof
+\ 80 of rp1bcf rp0bsf endof
+\ 100 of rp1bsf rp0bcf endof
+\ 180 of rp1bsf rp0bsf endof
+ endcase \ a ba
+ current-bank ! \ a
+\ else
+
+\ then
r> restore-warnings
;

\ Select the right bank and returned a trimmed address in the page

: select-bank ( a -- a' ) adjust-bank 7f and ;
-
-: rp0bcf ( -- ) reg-rp0 bcf ;
-: rp1bcf ( -- ) reg-rp1 bcf ;
-
: restore-bank ( -- )
- suspend-warnings >r
- case current-bank @
- 80 of rp0bcf endof
- 100 of rp1bcf endof
- 180 of rp1bcf rp0bcf endof
- endcase
- 0 current-bank !
- r> restore-warnings
+\ suspend-warnings >r
+\ case current-bank @
+\ 80 of rp0bcf endof
+\ 100 of rp1bcf endof
+\ 180 of rp1bcf rp0bcf endof
+\ endcase
+\ 0 current-bank !
+\ r> restore-warnings
;

: const-! ( addr -- )
const? if
kill-const dup 0= if
- drop select-bank clrf restore-bank
+ drop select-bank clrf restore-bank
else
- movlw select-bank movwf restore-bank
+ movlw select-bank movwf restore-bank
then
else
meta> popw select-bank movwf restore-bank
@@ -2234,7 +2289,7 @@
meta

\ Address of main program
-: main ( -- ) 0 set-vector init-picforth ;
+: main ( -- ) 30 set-stack-size 30 data-org 0 set-vector init-picforth ;

\ ----------------------------------------------------------------------
\ Tables
@@ -2485,7 +2540,9 @@
c00 of .op" btfss" endof
endcase
dup .file ." ," 380 and 7 rshift .bconst
-;
+ ;
+
+

\ Control operations

@@ -2600,4 +2657,4 @@
\ Reserve space for jump to main (4 bytes, because of the need to erase
\ 4 bytes at a time on 16F8xxA devices)

-4 org
+
========================end =======================

發表於: 2007/10/16 21:53
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於 PICFORTH
#3
中級會員
中級會員


查看用戶資訊
感覺這個好冷門喔, 比起那個PIC Basic用的人還要少

不過期待你的結果.

發表於: 2007/10/20 15:43
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於 PICFORTH
#4
新會員
新會員


查看用戶資訊
好玩麻
這是 201 lab6 的題目
我覺得 可以較省code 用 asm 寫 常常 bank 忘了切
init 
61 osccon 
!
begin nop hts bit-setuntil
trisc2 bit
-clr
0 trisd 
!
0c ccp1con !
7f t2con !

0 adcon0 !
adcs1 bit-set 
adon bit
-set
0e adcon1 
!
gie bit-clr
0 adcon0 
!

;


ad-out 
go bit
-set
begin not_done bit
-clruntil 

adresh 
dup portd !  dup  c bit-clr  ccpr1l rrf!   pr2 !
;


main main init begin ad-out again ;



dis
map
host
23f4 configword
-!
file-dump lab6.hex
bye

發表於: 2007/10/21 9:44
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於 PICFORTH
#5
版主
版主


查看用戶資訊
原始程式是比較小,但實際編譯過的 Machine Code 還是會比用組合語言的方式還要大些,你可以看一下最後的反組譯後的程式,依樣還是要切換 BANK 的。

發表於: 2007/10/22 13:16
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於 PICFORTH
#6
中級會員
中級會員


查看用戶資訊
BANK都肯定是要切煥的,畢竟到最後都要成為機器代碼運行,他只是說寫的時候不用顯式切換.

發表於: 2007/10/22 20:34
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於 PICFORTH
#7
新會員
新會員


查看用戶資訊
切 bank 是 mcu 的硬體設計 誰也沒辦法改變
會比c小
用 asm 寫 常忘了切bank
我試過比較 會比asm 大一點
畢竟 asm 完全控制程序
但又有點累



發表於: 2007/10/23 1:41
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------