Revision: 1465 Author: [email protected] Date: Fri Nov 6 22:38:43 2009 Log: large array library added http://code.google.com/p/jallib/source/detail?r=1465
Added: /trunk/include/jal/large_array.jal /trunk/sample/18f452_large_array.jal ======================================= --- /dev/null +++ /trunk/include/jal/large_array.jal Fri Nov 6 22:38:43 2009 @@ -0,0 +1,782 @@ +-- Title: Large Array library +-- Author: Matthew Schinkel - borntechi.com, copyright (c) 2009, all rights reserved. +-- Adapted-by: +-- Compiler: >=2.4l +-- +-- This file is part of jallib (http://jallib.googlecode.com) +-- Released under the ZLIB license (http://www.opensource.org/licenses/zlib-license.html) +-- +-- Description: This is library for creating an array that take up more then +-- 256 bytes memory. Tested on 18F devices only. +-- +-- Sources: +-- +-- Notes: +-- Supports byte array with up to 2048 entries +-- Supports word array with up to 1024 entries +-- Supports dword array with up to 512 entries +-- Creates an array named large_array_1 +-- Use "alias new_array_name is large_array_1" to rename the array +-- +-- Example: +-- const dword ARRAY_SIZE = 600 -- choose number of array variables +-- const dword ARRAY_VARIABLE_SIZE = 2 -- choose size of variables (byte*2) +-- include large_array -- include the array library +-- alias test is large_array_1 -- rename/alias the array to test +-- + +if ARRAY_VARIABLE_SIZE == 1 then -- if array will be byte*1 + + -- create smaller byte arrays + var byte large_array_byte_1h[256] + var byte large_array_byte_2h[256] + var byte large_array_byte_3h[256] + var byte large_array_byte_4h[256] + var byte large_array_byte_5h[256] + var byte large_array_byte_6h[256] + var byte large_array_byte_7h[256] + if !(ARRAY_SIZE == (256 * 7)) then -- don't make an array with 0 entries + var byte large_array_byte_8h[ARRAY_SIZE - (256 * 7)] + end if + + var byte large_array_byte_1g[256] + var byte large_array_byte_2g[256] + var byte large_array_byte_3g[256] + var byte large_array_byte_4g[256] + var byte large_array_byte_5g[256] + var byte large_array_byte_6g[256] + if !(ARRAY_SIZE == (256 * 6)) then + var byte large_array_byte_7g[ARRAY_SIZE - (256 * 6)] + end if + + var byte large_array_byte_1f[256] + var byte large_array_byte_2f[256] + var byte large_array_byte_3f[256] + var byte large_array_byte_4f[256] + var byte large_array_byte_5f[256] + if !(ARRAY_SIZE == (256 * 5)) then + var byte large_array_byte_6f[ARRAY_SIZE - (256 * 5)] + end if + + var byte large_array_byte_1e[256] + var byte large_array_byte_2e[256] + var byte large_array_byte_3e[256] + var byte large_array_byte_4e[256] + if !(ARRAY_SIZE == (256 * 4)) then + var byte large_array_byte_5e[ARRAY_SIZE - (256 * 4)] + end if + + var byte large_array_byte_1d[256] + var byte large_array_byte_2d[256] + var byte large_array_byte_3d[256] + if !(ARRAY_SIZE == (256 * 3)) then + var byte large_array_byte_4d[ARRAY_SIZE - (256 * 3)] + end if + + var byte large_array_byte_1c[256] + var byte large_array_byte_2c[256] + if !(ARRAY_SIZE == (256 * 2)) then + var byte large_array_byte_3c[ARRAY_SIZE - (256 * 2)] + end if + + var byte large_array_byte_1b[256] + if !(ARRAY_SIZE == 256) then + var byte large_array_byte_2b[ARRAY_SIZE - (256)] + end if + + if !(ARRAY_SIZE == 0) then + var byte large_array_byte_1a[ARRAY_SIZE] + end if + + -- get a value from a large byte array + function large_array_1'get(word in address) return byte is + var byte data + + if ARRAY_SIZE > 1792 then + if address >= 1792 then + data = large_array_byte_8h[address - 1792] + elsif address >= 1536 then + data = large_array_byte_7h[address - 1536] + elsif address >= 1280 then + data = large_array_byte_6h[address - 1280] + elsif address >= 1024 then + data = large_array_byte_5h[address - 1024] + elsif address >= 768 then + data = large_array_byte_4h[address - 768] + elsif address >= 512 then + data = large_array_byte_3h[address - 512] + elsif address >= 256 then + data = large_array_byte_2h[address - 256] + elsif address >= 0 then + data = large_array_byte_1h[address - 0] + end if + elsif ARRAY_SIZE > 1536 then + if address >= 1536 then + data = large_array_byte_7g[address - 1536] + elsif address >= 1280 then + data = large_array_byte_6g[address - 1280] + elsif address >= 1024 then + data = large_array_byte_5g[address - 1024] + elsif address >= 768 then + data = large_array_byte_4g[address - 768] + elsif address >= 512 then + data = large_array_byte_3g[address - 512] + elsif address >= 256 then + data = large_array_byte_2g[address - 256] + elsif address >= 0 then + data = large_array_byte_1g[address - 0] + end if + elsif ARRAY_SIZE > 1280 then + if address >= 1280 then + data = large_array_byte_6f[address - 1280] + elsif address >= 1024 then + data = large_array_byte_5f[address - 1024] + elsif address >= 768 then + data = large_array_byte_4f[address - 768] + elsif address >= 512 then + data = large_array_byte_3f[address - 512] + elsif address >= 256 then + data = large_array_byte_2f[address - 256] + elsif address >= 0 then + data = large_array_byte_1f[address - 0] + end if + elsif ARRAY_SIZE > 1024 then + if address >= 1024 then + data = large_array_byte_5e[address - 1024] + elsif address >= 768 then + data = large_array_byte_4e[address - 768] + elsif address >= 512 then + data = large_array_byte_3e[address - 512] + elsif address >= 256 then + data = large_array_byte_2e[address - 256] + elsif address >= 0 then + data = large_array_byte_1e[address - 0] + end if + elsif ARRAY_SIZE > 768 then + if address >= 768 then + data = large_array_byte_4d[address - 768] + elsif address >= 512 then + data = large_array_byte_3d[address - 512] + elsif address >= 256 then + data = large_array_byte_2d[address - 256] + elsif address >= 0 then + data = large_array_byte_1d[address - 0] + end if + elsif ARRAY_SIZE > 512 then + if address >= 512 then + data = large_array_byte_3c[address - 512] + elsif address >= 256 then + data = large_array_byte_2c[address - 256] + elsif address >= 0 then + data = large_array_byte_1c[address - 0] + end if + elsif ARRAY_SIZE > 256 then + if address >= 256 then + data = large_array_byte_2b[address - 256] + elsif address >= 0 then + data = large_array_byte_1b[address - 0] + end if + elsif ARRAY_SIZE > 0 then + if address >= 0 then + data = large_array_byte_1a[address - 0] + end if + end if + + return data + end function + + -- store a value into a large byte array + procedure large_array_1'put (word in address, byte in data) is + if ARRAY_SIZE > 1792 then + if address >= 1792 then + large_array_byte_8h[address - 1792] = data + elsif address >= 1536 then + large_array_byte_7h[address - 1536] = data + elsif address >= 1280 then + large_array_byte_6h[address - 1280] = data + elsif address >= 1024 then + large_array_byte_5h[address - 1024] = data + elsif address >= 768 then + large_array_byte_4h[address - 768] = data + elsif address >= 512 then + large_array_byte_3h[address - 512] = data + elsif address >= 256 then + large_array_byte_2h[address - 256] = data + elsif address >= 0 then + large_array_byte_1h[address - 0] = data + end if + elsif ARRAY_SIZE > 1536 then + if address >= 1536 then + large_array_byte_7g[address - 1536] = data + elsif address >= 1280 then + large_array_byte_6g[address - 1280] = data + elsif address >= 1024 then + large_array_byte_5g[address - 1024] = data + elsif address >= 768 then + large_array_byte_4g[address - 768] = data + elsif address >= 512 then + large_array_byte_3g[address - 512] = data + elsif address >= 256 then + large_array_byte_2g[address - 256] = data + elsif address >= 0 then + large_array_byte_1g[address - 0] = data + end if + elsif ARRAY_SIZE > 1280 then + if address >= 1280 then + large_array_byte_6f[address - 1280] = data + elsif address >= 1024 then + large_array_byte_5f[address - 1024] = data + elsif address >= 768 then + large_array_byte_4f[address - 768] = data + elsif address >= 512 then + large_array_byte_3f[address - 512] = data + elsif address >= 256 then + large_array_byte_2f[address - 256] = data + elsif address >= 0 then + large_array_byte_1f[address - 0] = data + end if + elsif ARRAY_SIZE > 1024 then + if address >= 1024 then + large_array_byte_5e[address - 1024] = data + elsif address >= 768 then + large_array_byte_4e[address - 768] = data + elsif address >= 512 then + large_array_byte_3e[address - 512] = data + elsif address >= 256 then + large_array_byte_2e[address - 256] = data + elsif address >= 0 then + large_array_byte_1e[address - 0] = data + end if + elsif ARRAY_SIZE > 768 then + if address >= 768 then + large_array_byte_4d[address - 768] = data + elsif address >= 512 then + large_array_byte_3d[address - 512] = data + elsif address >= 256 then + large_array_byte_2d[address - 256] = data + elsif address >= 0 then + large_array_byte_1d[address - 0] = data + end if + elsif ARRAY_SIZE > 512 then + if address >= 512 then + large_array_byte_3c[address - 512] = data + elsif address >= 256 then + large_array_byte_2c[address - 256] = data + elsif address >= 0 then + large_array_byte_1c[address - 0] = data + end if + elsif ARRAY_SIZE > 256 then + if address >= 256 then + large_array_byte_2b[address - 256] = data + elsif address >= 0 then + large_array_byte_1b[address - 0] = data + end if + elsif ARRAY_SIZE > 0 then + if address >= 0 then + large_array_byte_1a[address - 0] = data + end if + end if + end procedure + +elsif ARRAY_VARIABLE_SIZE == 2 then + var word large_array_word_1h[128] + var word large_array_word_2h[128] + var word large_array_word_3h[128] + var word large_array_word_4h[128] + var word large_array_word_5h[128] + var word large_array_word_6h[128] + var word large_array_word_7h[128] + if !(ARRAY_SIZE == (128 * 7)) then + var word large_array_word_8h[ARRAY_SIZE - (128 * 7)] + end if + + var word large_array_word_1g[128] + var word large_array_word_2g[128] + var word large_array_word_3g[128] + var word large_array_word_4g[128] + var word large_array_word_5g[128] + var word large_array_word_6g[128] + if !(ARRAY_SIZE == (128 * 6)) then + var word large_array_word_7g[ARRAY_SIZE - (128 * 6)] + end if + + var word large_array_word_1f[128] + var word large_array_word_2f[128] + var word large_array_word_3f[128] + var word large_array_word_4f[128] + var word large_array_word_5f[128] + if !(ARRAY_SIZE == (128 * 5)) then + var word large_array_word_6f[ARRAY_SIZE - (128 * 5)] + end if + + var word large_array_word_1e[128] + var word large_array_word_2e[128] + var word large_array_word_3e[128] + var word large_array_word_4e[128] + if !(ARRAY_SIZE == (128 * 4)) then + var word large_array_word_5e[ARRAY_SIZE - (128 * 4)] + end if + + var word large_array_word_1d[128] + var word large_array_word_2d[128] + var word large_array_word_3d[128] + if !(ARRAY_SIZE == (128 * 3)) then + var word large_array_word_4d[ARRAY_SIZE - (128 * 3)] + end if + + var word large_array_word_1c[128] + var word large_array_word_2c[128] + if !(ARRAY_SIZE == (128 * 2)) then + var word large_array_word_3c[ARRAY_SIZE - (128 * 2)] + end if + + var word large_array_word_1b[128] + if !(ARRAY_SIZE == 128) then + var word large_array_word_2b[ARRAY_SIZE - (128 * 1)] + end if + + if !(ARRAY_SIZE == (0)) then + var word large_array_word_1a[ARRAY_SIZE - (128 * 0)] + end if + + function large_array_1'get(word in address) return word is + var word data + + if ARRAY_SIZE > 896 then + if address >= 896 then + data = large_array_word_8h[address - 896] + elsif address >= 768 then + data = large_array_word_7h[address - 768] + elsif address >= 640 then + data = large_array_word_6h[address - 640] + elsif address >= 512 then + data = large_array_word_5h[address - 512] + elsif address >= 384 then + data = large_array_word_4h[address - 384] + elsif address >= 256 then + data = large_array_word_3h[address - 256] + elsif address >= 128 then + data = large_array_word_2h[address - 128] + elsif address >= 0 then + data = large_array_word_1h[address - 0] + end if + elsif ARRAY_SIZE > 768 then + if address >= 768 then + data = large_array_word_7g[address - 768] + elsif address >= 640 then + data = large_array_word_6g[address - 640] + elsif address >= 512 then + data = large_array_word_5g[address - 512] + elsif address >= 384 then + data = large_array_word_4g[address - 384] + elsif address >= 256 then + data = large_array_word_3g[address - 256] + elsif address >= 128 then + data = large_array_word_2g[address - 128] + elsif address >= 0 then + data = large_array_word_1g[address - 0] + end if + elsif ARRAY_SIZE > 640 then + if address >= 640 then + data = large_array_word_6f[address - 640] + elsif address >= 512 then + data = large_array_word_5f[address - 512] + elsif address >= 384 then + data = large_array_word_4f[address - 384] + elsif address >= 256 then + data = large_array_word_3f[address - 256] + elsif address >= 128 then + data = large_array_word_2f[address - 128] + elsif address >= 0 then + data = large_array_word_1f[address - 0] + end if + elsif ARRAY_SIZE > 512 then + if address >= 512 then + data = large_array_word_5e[address - 512] + elsif address >= 384 then + data = large_array_word_4e[address - 384] + elsif address >= 256 then + data = large_array_word_3e[address - 256] + elsif address >= 128 then + data = large_array_word_2e[address - 128] + elsif address >= 0 then + data = large_array_word_1e[address - 0] + end if + elsif ARRAY_SIZE > 384 then + if address >= 384 then + data = large_array_word_4d[address - 384] + elsif address >= 256 then + data = large_array_word_3d[address - 256] + elsif address >= 128 then + data = large_array_word_2d[address - 128] + elsif address >= 0 then + data = large_array_word_1d[address - 0] + end if + elsif ARRAY_SIZE > 256 then + if address >= 256 then + data = large_array_word_3c[address - 256] + elsif address >= 128 then + data = large_array_word_2c[address - 128] + elsif address >= 0 then + data = large_array_word_1c[address - 0] + end if + elsif ARRAY_SIZE > 128 then + if address >= 128 then + data = large_array_word_2b[address - 128] + elsif address >= 0 then + data = large_array_word_1b[address - 0] + end if + elsif ARRAY_SIZE > 0 then + if address >= 0 then + data = large_array_word_1a[address - 0] + end if + end if + + return data + end function + + + + procedure large_array_1'put (word in address, word in data) is + if ARRAY_SIZE > 896 then + if address >= 896 then -- + large_array_word_8h[address - 896] = data + elsif address >= 768 then + large_array_word_7h[address - 768] = data + elsif address >= 640 then + large_array_word_6h[address - 640] = data + elsif address >= 512 then + large_array_word_5h[address - 512] = data + elsif address >= 384 then + large_array_word_4h[address - 384] = data + elsif address >= 256 then + large_array_word_3h[address - 256] = data + elsif address >= 128 then + large_array_word_2h[address - 128] = data + elsif address >= 0 then + large_array_word_1h[address - 0] = data + end if + elsif ARRAY_SIZE > 768 then + if address >= 768 then + large_array_word_7g[address - 768] = data + elsif address >= 640 then + large_array_word_6g[address - 640] = data + elsif address >= 512 then + large_array_word_5g[address - 512] = data + elsif address >= 384 then + large_array_word_4g[address - 384] = data + elsif address >= 256 then + large_array_word_3g[address - 256] = data + elsif address >= 128 then + large_array_word_2g[address - 128] = data + elsif address >= 0 then + large_array_word_1g[address - 0] = data + end if + elsif ARRAY_SIZE > 640 then + if address >= 640 then + large_array_word_6f[address - 640] = data + elsif address >= 512 then + large_array_word_5f[address - 512] = data + elsif address >= 384 then + large_array_word_4f[address - 384] = data + elsif address >= 256 then + large_array_word_3f[address - 256] = data + elsif address >= 128 then + large_array_word_2f[address - 128] = data + elsif address >= 0 then + large_array_word_1f[address - 0] = data + end if + elsif ARRAY_SIZE > 512 then + if address >= 512 then + large_array_word_5e[address - 512] = data + elsif address >= 384 then + large_array_word_4e[address - 384] = data + elsif address >= 256 then + large_array_word_3e[address - 256] = data + elsif address >= 128 then + large_array_word_2e[address - 128] = data + elsif address >= 0 then + large_array_word_1e[address - 0] = data + end if + elsif ARRAY_SIZE > 384 then + if address >= 384 then + large_array_word_4d[address - 384] = data + elsif address >= 256 then + large_array_word_3d[address - 256] = data + elsif address >= 128 then + large_array_word_2d[address - 128] = data + elsif address >= 0 then + large_array_word_1d[address - 0] = data + end if + elsif ARRAY_SIZE > 256 then + if address >= 256 then + large_array_word_3c[address - 256] = data + elsif address >= 128 then + large_array_word_2c[address - 128] = data + elsif address >= 0 then + large_array_word_1c[address - 0] = data + end if + elsif ARRAY_SIZE > 128 then + if address >= 128 then + large_array_word_2b[address - 128] = data + elsif address >= 0 then + large_array_word_1b[address - 0] = data + end if + elsif ARRAY_SIZE > 0 then + if address >= 0 then + large_array_word_1a[address - 0] = data + end if + end if + end procedure + + + +elsif ARRAY_VARIABLE_SIZE == 4 then + var dword large_array_dword_1h[64] + var dword large_array_dword_2h[64] + var dword large_array_dword_3h[64] + var dword large_array_dword_4h[64] + var dword large_array_dword_5h[64] + var dword large_array_dword_6h[64] + var dword large_array_dword_7h[64] + if !(ARRAY_SIZE == (64 * 7)) then + var dword large_array_dword_8h[ARRAY_SIZE - (64 * 7)] + end if + + var dword large_array_dword_1g[64] + var dword large_array_dword_2g[64] + var dword large_array_dword_3g[64] + var dword large_array_dword_4g[64] + var dword large_array_dword_5g[64] + var dword large_array_dword_6g[64] + if !(ARRAY_SIZE == (64 * 6)) then + var dword large_array_dword_7g[ARRAY_SIZE - (64 * 6)] + end if + + var dword large_array_dword_1f[64] + var dword large_array_dword_2f[64] + var dword large_array_dword_3f[64] + var dword large_array_dword_4f[64] + var dword large_array_dword_5f[64] + if !(ARRAY_SIZE == (64 * 5)) then + var dword large_array_dword_6f[ARRAY_SIZE - (64 * 5)] + end if + + var dword large_array_dword_1e[64] + var dword large_array_dword_2e[64] + var dword large_array_dword_3e[64] + var dword large_array_dword_4e[64] + if !(ARRAY_SIZE == (64 * 4)) then + var dword large_array_dword_5e[ARRAY_SIZE - (64 * 4)] + end if + + var dword large_array_dword_1d[64] + var dword large_array_dword_2d[64] + var dword large_array_dword_3d[64] + if !(ARRAY_SIZE == (64 * 3)) then + var dword large_array_dword_4d[ARRAY_SIZE - (64 * 3)] + end if + + var dword large_array_dword_1c[64] + var dword large_array_dword_2c[64] + if !(ARRAY_SIZE == (64 * 2)) then + var dword large_array_dword_3c[ARRAY_SIZE - (64 * 2)] + end if + + var dword large_array_dword_1b[64] + if !(ARRAY_SIZE == (64)) then + var dword large_array_dword_2b[ARRAY_SIZE - (64 * 1)] + end if + + if !(ARRAY_SIZE == (0)) then + var dword large_array_dword_1a[ARRAY_SIZE] + end if + + + function large_array_1'get(dword in address) return dword is + var dword data + if ARRAY_SIZE > 448 then + if address >= 448 then + data = large_array_dword_8h[address - 448] + elsif address >= 384 then + data = large_array_dword_7h[address - 384] + elsif address >= 320 then + data = large_array_dword_6h[address - 320] + elsif address >= 256 then + data = large_array_dword_5h[address - 256] + elsif address >= 192 then + data = large_array_dword_4h[address - 192] + elsif address >= 128 then + data = large_array_dword_3h[address - 128] + elsif address >= 64 then + data = large_array_dword_2h[address - 64] + elsif address >= 0 then + data = large_array_dword_1h[address - 0] + end if + elsif ARRAY_SIZE > 384 then + if address >= 384 then + data = large_array_dword_7g[address - 384] + elsif address >= 320 then + data = large_array_dword_6g[address - 320] + elsif address >= 256 then + data = large_array_dword_5g[address - 256] + elsif address >= 192 then + data = large_array_dword_4g[address - 192] + elsif address >= 128 then + data = large_array_dword_3g[address - 128] + elsif address >= 64 then + data = large_array_dword_2g[address - 64] + elsif address >= 0 then + data = large_array_dword_1g[address - 0] + end if + elsif ARRAY_SIZE > 320 then + if address >= 320 then + data = large_array_dword_6f[address - 320] + elsif address >= 256 then + data = large_array_dword_5f[address - 256] + elsif address >= 192 then + data = large_array_dword_4f[address - 192] + elsif address >= 128 then + data = large_array_dword_3f[address - 128] + elsif address >= 64 then + data = large_array_dword_2f[address - 64] + elsif address >= 0 then + data = large_array_dword_1f[address - 0] + end if + elsif ARRAY_SIZE > 256 then + if address >= 256 then + data = large_array_dword_5e[address - 256] + elsif address >= 192 then + data = large_array_dword_4e[address - 192] + elsif address >= 128 then + data = large_array_dword_3e[address - 128] + elsif address >= 64 then + data = large_array_dword_2e[address - 64] + elsif address >= 0 then + data = large_array_dword_1e[address - 0] + end if + elsif ARRAY_SIZE > 192 then + if address >= 192 then + data = large_array_dword_4d[address - 192] + elsif address >= 128 then + data = large_array_dword_3d[address - 128] + elsif address >= 64 then + data = large_array_dword_2d[address - 64] + elsif address >= 0 then + data = large_array_dword_1d[address - 0] + end if + elsif ARRAY_SIZE > 128 then + if address >= 128 then + data = large_array_dword_3c[address - 128] + elsif address >= 64 then + data = large_array_dword_2c[address - 64] + elsif address >= 0 then + data = large_array_dword_1c[address - 0] + end if + elsif ARRAY_SIZE > 64 then + if address >= 64 then + data = large_array_dword_2b[address - 64] + elsif address >= 0 then + data = large_array_dword_1b[address - 0] + end if + elsif ARRAY_SIZE > 0 then + if address >= 0 then + data = large_array_dword_1a[address - 0] + end if + end if + return data + end function + + + procedure large_array_1'put (dword in address, dword in data) is + if ARRAY_SIZE > 448 then + if address >= 448 then + large_array_dword_8h[address - 448] = data + elsif address >= 384 then + large_array_dword_7h[address - 384] = data + elsif address >= 320 then + large_array_dword_6h[address - 320] = data + elsif address >= 256 then + large_array_dword_5h[address - 256] = data + elsif address >= 192 then + large_array_dword_4h[address - 192] = data + elsif address >= 128 then + large_array_dword_3h[address - 128] = data + elsif address >= 64 then + large_array_dword_2h[address - 64] = data + elsif address >= 0 then + large_array_dword_1h[address - 0] = data + end if + elsif ARRAY_SIZE > 384 then + if address >= 384 then + large_array_dword_7g[address - 384] = data + elsif address >= 320 then + large_array_dword_6g[address - 320] = data + elsif address >= 256 then + large_array_dword_5g[address - 256] = data + elsif address >= 192 then + large_array_dword_4g[address - 192] = data + elsif address >= 128 then + large_array_dword_3g[address - 128] = data + elsif address >= 64 then + large_array_dword_2g[address - 64] = data + elsif address >= 0 then + large_array_dword_1g[address - 0] = data + end if + elsif ARRAY_SIZE > 320 then + if address >= 320 then + large_array_dword_6f[address - 320] = data + elsif address >= 256 then + large_array_dword_5f[address - 256] = data + elsif address >= 192 then + large_array_dword_4f[address - 192] = data + elsif address >= 128 then + large_array_dword_3f[address - 128] = data + elsif address >= 64 then + large_array_dword_2f[address - 64] = data + elsif address >= 0 then + large_array_dword_1f[address - 0] = data + end if + elsif ARRAY_SIZE > 256 then + if address >= 256 then + large_array_dword_5e[address - 256] = data + elsif address >= 192 then + large_array_dword_4e[address - 192] = data + elsif address >= 128 then + large_array_dword_3e[address - 128] = data + elsif address >= 64 then + large_array_dword_2e[address - 64] = data + elsif address >= 0 then + large_array_dword_1e[address - 0] = data + end if + elsif ARRAY_SIZE > 192 then + if address >= 192 then + large_array_dword_4d[address - 192] = data + elsif address >= 128 then + large_array_dword_3d[address - 128] = data + elsif address >= 64 then + large_array_dword_2d[address - 64] = data + elsif address >= 0 then + large_array_dword_1d[address - 0] = data + end if + elsif ARRAY_SIZE > 128 then + if address >= 128 then + large_array_dword_3c[address - 128] = data + elsif address >= 64 then + large_array_dword_2c[address - 64] = data + elsif address >= 0 then + large_array_dword_1c[address - 0] = data + end if + elsif ARRAY_SIZE > 64 then + if address >= 64 then + large_array_dword_2b[address - 64] = data + elsif address >= 0 then + large_array_dword_1b[address - 0] = data + end if + elsif ARRAY_SIZE > 0 then + if address >= 0 then + large_array_dword_1a[address - 0] = data + end if + end if + end procedure +end if ======================================= --- /dev/null +++ /trunk/sample/18f452_large_array.jal Fri Nov 6 22:38:43 2009 @@ -0,0 +1,89 @@ +-- Title: Large Array Example +-- Author: Matthew Schinkel - borntechi.com, copyright (c) 2009, all rights reserved. +-- Adapted-by: +-- Compiler: >=2.4l +-- +-- This file is part of jallib (http://jallib.googlecode.com) +-- Released under the ZLIB license (http://www.opensource.org/licenses/zlib-license.html) +-- +-- Description: This is an example large array for creating an array that +-- take up more then 256 bytes memory. Tested on 18F devices only. +-- +-- Sources: +-- +-- Notes: +-- Supports byte array with up to 2048 entries +-- Supports word array with up to 1024 entries +-- Supports dword array with up to 512 entries +-- Creates an array named large_array_1 +-- Use "alias new_array_name is large_array_1" to rename the array +-- +-- Example: +-- const dword ARRAY_SIZE = 600 -- choose number of array variables +-- const dword ARRAY_VARIABLE_SIZE = 2 -- choose bytes size of variables +-- include large_array -- include the array library +-- alias test is large_array_1 -- rename/alias the array +-- + +include 18f452 -- target PICmicro + +-- This program assumes a 20 MHz resonator or crystal +-- is connected to pins OSC1 and OSC2. +-- Unspecified configuration bits may cause a different frequency! +pragma target clock 20_000_000 -- oscillator frequency +-- configuration memory settings (fuses) +pragma target OSC HS -- HS crystal or resonator +pragma target WDT disabled -- no watchdog +pragma target LVP disabled -- no Low Voltage Programming +-- +enable_digital_io() -- disable analog I/O (if any) +-- + +-- setup uart for communication +const serial_hw_baudrate = 38400 -- set the baudrate +include serial_hardware +serial_hw_init() + +-- Setup the large array +const dword ARRAY_SIZE = 1024 -- choose number of array variables +const dword ARRAY_VARIABLE_SIZE = 1 -- choose size of variables (byte*1) +include large_array -- include the array library +alias test is large_array_1 -- rename/alias the array to test + +-- send start via serial port +serial_hw_write ("S") +serial_hw_write ("T") +serial_hw_write ("A") +serial_hw_write ("R") +serial_hw_write ("T") + +_usec_delay (1_000_000) -- 1 sec delay + +-- store some values +test[50] = 0x11 +test[651] = 0x22 +test[126] = 0x33 +test[127] = 0x44 +test[256] = 0x55 +test[257] = 0x66 +test[349] = 0x77 +test[517] = 0x88 + +-- read some values +serial_hw_write (test[50]) +serial_hw_write (test[651]) +serial_hw_write (test[126]) +serial_hw_write (test[127]) +serial_hw_write (test[256]) +serial_hw_write (test[257]) +serial_hw_write (test[349]) +serial_hw_write (test[517]) + +_usec_delay (1_000_000) -- 1 sec delay + +-- send end via serial port +serial_hw_write ("E") +serial_hw_write ("N") +serial_hw_write ("D") + + --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jallib?hl=en -~----------~----~----~----~------~----~------~--~---
