AndersG
Super Member
- Total Posts : 241
- Reward points : 0
- Joined: 2008/08/05 04:51:24
- Location: 0
- Status: offline
Another "generates no code"
But I fail to see why, ie total_bytes is a local DWORD. nbytes (UINT) is updated by f_read and that is then added to total_bytes total_bytes = 0;
for(i=0;i<chunks;i++) // Read maximum 256 bytes { if(i==(chunks-1) && tail == 0) gpib_flags = gpib_flags | FLAGS_EOI; // EOI on, on last block if there is no tail
rc=f_read(&File[Unit],gpib_tx_buff,256,&nbytes);
#if SDEBUG >= 1 xprintf("\r\n%02X%02X 1:Read rtn %X, %d read ", TMR1H, TMR1L, rc, nbytes); #endif if(rc != 0) { SS80Disk[Unit].Errors = SS80Disk[Unit].Errors | SS80_ERR_SEEK; SS80_error_return(); // return one byte and return rc2; // bail out if seek fails } //Time(); sendgpib(nbytes); total_bytes = total_bytes + nbytes; SS80Disk[Unit].Vector = SS80Disk[Unit].Vector + 0x100L; #if SDEBUG >= 1 xprintf("\r%02X%02X Vector %ld (%lX) ", TMR1H, TMR1L, SS80Disk[Unit].Vector, SS80Disk[Unit].Vector); #endif }
|
AndersG
Super Member
- Total Posts : 241
- Reward points : 0
- Joined: 2008/08/05 04:51:24
- Location: 0
- Status: offline
Re: Another "generates no code"
2020/11/30 04:29:50
(permalink)
Here is another, says that total_bytes and RC are not used. But they are sendgpib is int sendgpib (int len); f_read is FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); // Do a buffered read of the current sector // void amigo_cmd_buffered_read() { DWORD total_bytes; FRESULT rc; UINT nbytes; UINT sbytes; // Follows after 0x680x05, Send 256 bytes. EOI only if error #if SDEBUG >= 1 xprintf("\r\nAM:Buff rd c/h/s: %d/%d/%d s:%ld ", AmigoDisk[Unit].cyl, AmigoDisk[Unit].head, AmigoDisk[Unit].sector, (DWORD)AmigoDisk[Unit].cyl*16L*2L + (DWORD)AmigoDisk[Unit].head *16L + (DWORD)AmigoDisk[Unit].sector ); #endif // DISK_LED = 1; DisablePP(); total_bytes = 0; rc=f_read(&File[Unit],gpib_tx_buff,256,&nbytes); #if SDEBUG >= 1 xprintf("\r\nRead rtn %X, %d bytes read", rc, nbytes); #endif //trigger(1); gpib_flags = gpib_flags & ~FLAGS_EOI; sbytes=sendgpib(nbytes); total_bytes = total_bytes + sbytes; #if SDEBUG >= 1 xprintf("\r\n %ld bytes sent", total_bytes); #endif dsj = 0; DISK_LED = 0; EnablePP(); }
|
ric
Super Member
- Total Posts : 29435
- Reward points : 0
- Joined: 2003/11/07 12:41:26
- Location: Australia, Melbourne
- Status: offline
Re: Another "generates no code"
2020/11/30 04:49:34
(permalink)
AndersG But I fail to see why, ie total_bytes is a local DWORD. nbytes (UINT) is updated by f_read and that is then added to total_bytes ... Nothing in that code ever uses the value of "total_bytes", so why should it bother maintaining it? If the only use for a variable is to examine it in a debugger WATCH window, then you must add a "volatile" qualifier to it to stop the compiler discarding it altogether.
post edited by ric - 2020/11/30 04:50:46
To get a useful answer, always state which PIC you are using!
|
ric
Super Member
- Total Posts : 29435
- Reward points : 0
- Joined: 2003/11/07 12:41:26
- Location: Australia, Melbourne
- Status: offline
Re: Another "generates no code"
2020/11/30 04:58:51
(permalink)
AndersG Here is another, says that total_bytes and RC are not used. ... The only code using that value is inside "#if SDEBUG >= 1" You don't show the #define for SDEBUG, or mention what value it is.
To get a useful answer, always state which PIC you are using!
|
AndersG
Super Member
- Total Posts : 241
- Reward points : 0
- Joined: 2008/08/05 04:51:24
- Location: 0
- Status: offline
Re: Another "generates no code"
2020/11/30 04:59:28
(permalink)
Thanks! That was it. Yes it is only used for debugging. I never thought the compiler was that smart :) I will make it volatile Sorry SDEBUG is a define I have to enable debugging output over serial.
post edited by AndersG - 2020/11/30 05:01:48
|
ric
Super Member
- Total Posts : 29435
- Reward points : 0
- Joined: 2003/11/07 12:41:26
- Location: Australia, Melbourne
- Status: offline
Re: Another "generates no code"
2020/11/30 05:04:08
(permalink)
AndersG ... Sorry SDEBUG is a define I have to enable debugging output over serial.
That's obvious, but if you don't define it (or if it's less than 1) then the code inside the #if is discarded, so the variable becomes unused, and will be discarded.
To get a useful answer, always state which PIC you are using!
|
AndersG
Super Member
- Total Posts : 241
- Reward points : 0
- Joined: 2008/08/05 04:51:24
- Location: 0
- Status: offline
Re: Another "generates no code"
2020/11/30 08:13:30
(permalink)
Yes. You are so right. Did not think that far.
|