How are you going to get a 1,000,000 element array with a PIC?
Not enough RAM.Code:For index_1=0 to Big_number_low HSEROUT [sentence(index_1)] Next
<br>
How are you going to get a 1,000,000 element array with a PIC?
Not enough RAM.Code:For index_1=0 to Big_number_low HSEROUT [sentence(index_1)] Next
<br>
DT
Hi Darrel,
I知 sorry for not presenting the complete picture.
I知 reading a .txt file from a USB media. The first line of this file gives me the total number of records in the file.
I知 reading the records one by one in a big loop:
Read Big_number
For index = 0 to Big_number
Read record
HSEROUT [record}
If index => Big_number then quit
Next
It all works fine if Big_number is limited to word size.
Now the requirement changed for larger number of records so I thought that your trick might apply here.
At the time I did that because I did not know, and I still don稚, to detect EOF.
Trying to read the device over the EOF will freeze the system.
Thank you for your interest.
Nick
That makes things a bit easier ...Code:big_number VAR WORD[2] ; 32-bit variable ASM ;---[load a 32-bit constant into a 32-bit variable]----------------- MOVE?CN macro Cin, Nout MOVE?CW Cin & 0xFFFF, Nout ; Low Word MOVE?CW (Cin >> 16), Nout + 2 ; High Word endm ENDASM ;------------------------------------------------------------------- @ MOVE?CN 1000000, big_number WHILE (big_number[1] > 0) OR (big_number[0] > 0) Read record HSEROUT [record] big_number[0] = big_number[0] - 1 IF big_number[0] = $ffff THEN big_number[1] = big_number[1] - 1 WEND
Last edited by Darrel Taylor; - 25th January 2008 at 09:09. Reason: Changed AND to OR
DT
Thank you Darrel,
I knew it can be done. I just did not know how, and your example turns few lights on in my brain.
I will give it a shot after work, today, and post the results.
Thanks again,
Nick
Hi Darrel,
I have a PBP copy installed on my work computer so I tried your code in a simple program to send out numbers (if I understood you correctly) from Big_number to 0.
I am using:
MCS 2.3.0.0
PBP 2.47
MPASM 5.03
This is the small program I知 trying to compile but I get a warning and an error:
INCLUDE "modedefs.bas"
DEFINE OSC 16
DEFINE LOADER_USED 1
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
DEFINE HSER_BAUD 4800
DEFINE HSER_CLROERR 1
big_number VAR WORD[2] ; 32-bit variable
ADCON1=6
CMCON=7
main:
@ MOVE?CN 1000000, big_number
WHILE (big_number[1] > 0) OR (big_number[0] > 0)
HSEROUT [#big_number[1],#big_number[0]]
big_number[0] = big_number[0] - 1
IF big_number[0] = $ffff THEN big_number[1] = big_number[1] - 1
WEND
pause 5000
goto main
ASM
;---[load a 32-bit constant into a 32-bit variable]-----------------
MOVE?CN macro Cin, Nout
MOVE?CW Cin & 0xFFFF, Nout ; Low Word
MOVE?CW (Cin >> 16), Nout + 2 ; High Word
endm
ENDASM
End
The messages I get are:
Warning[207] c:\big_num.asm 99: Found label after column 1.(MOVE?CN)
Error[108] c:\big_num.asm : Illegal character (1)
Any idea?
Regards,
Nick
Put the macro in the source code BEFORE the actual usage.
INCLUDE "modedefs.bas"
DEFINE OSC 16
DEFINE LOADER_USED 1
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
DEFINE HSER_BAUD 4800
DEFINE HSER_CLROERR 1
big_number VAR WORD[2] ; 32-bit variable
ADCON1=6
CMCON=7
goto main
ASM
;---[load a 32-bit constant into a 32-bit variable]-----------------
MOVE?CN macro Cin, Nout
MOVE?CW Cin & 0xFFFF, Nout ; Low Word
MOVE?CW (Cin >> 16), Nout + 2 ; High Word
endm
ENDASM
main:
@ MOVE?CN 1000000, big_number
WHILE (big_number[1] > 0) OR (big_number[0] > 0)
HSEROUT [#big_number[1],#big_number[0]]
big_number[0] = big_number[0] - 1
IF big_number[0] = $ffff THEN big_number[1] = big_number[1] - 1
WEND
pause 5000
goto main
End
[/code]
Hi Skimask,
I tried that first but I got 12 errors:
Error[113] c:\pbp\pbppicbasic14.lib428 : Symbol not previously defined (big_number).
Should I do any changes in pbppicbasic14.lib?
Thanks,
Nick
Bookmarks