1 / 15

Riistvarapõhine programmeerimine

Riistvarapõhine programmeerimine. Labor 6 C programmi optimeerimine. Programmi optimeerimine. Kompilaatoriga optimeerimine C koodi optimeerimine Assembleri lisamine Assembleri moodulid In-line assembler. Kompilaatoriga optimeerimine. SDCC manuaal

tamyra
Télécharger la présentation

Riistvarapõhine programmeerimine

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Riistvarapõhine programmeerimine Labor 6 C programmi optimeerimine

  2. Programmi optimeerimine • Kompilaatoriga optimeerimine • C koodi optimeerimine • Assembleri lisamine • Assembleri moodulid • In-line assembler ID218 Riistvaralähedane programmeerimine

  3. Kompilaatoriga optimeerimine SDCC manuaal http://sdcc.sourceforge.net/doc/sdccman.html/node52.html • [--opt-code-speed] The compiler will optimize code generation towards fast code, possibly at the expense of code size. • [--opt-code-size] The compiler will optimize code generation towards compact code, possibly at the expense of code speed ID218 Riistvaralähedane programmeerimine

  4. C optimeerimine, Muutuja • Muutuja valik • Char 1b • Int 2b • Signed char -128 +127 • Unsigned char 0 +255 Näidis led61.c; led63.c, ~100 B ID218 Riistvaralähedane programmeerimine

  5. C optimeerimine, tsükkel • Tsükkel, tüübi valik • FOR • IF • WHILE • DO … WHILE ID218 Riistvaralähedane programmeerimine

  6. C optimeerimine, FOR tsükkel for ( i=0; i<100; i++) { . . . } for ( i=100; i==0; i--) ID218 Riistvaralähedane programmeerimine

  7. C optimeerimine, IF tsükkel counter++; if (counter > 100) { counter = 0; } i = 0; if( ++i == 100 ) { i = 0; } ID218 Riistvaralähedane programmeerimine

  8. C optimeerimine, WHILE tsükkel i = 0; while (i <100) { . . . i++; } ID218 Riistvaralähedane programmeerimine

  9. C optimeerimine, DO … WHILE i = 0; do { . . . i++; } while ( i == 99 ) ; ID218 Riistvaralähedane programmeerimine

  10. C optimeerimine, tingimus • Tsükkel, tingimuse valik • If (sec == 60 ) • If (sec =< 60 ) • If (sec < 61 ) • If (sec > 60 ) ID218 Riistvaralähedane programmeerimine

  11. Assembleri moodul, lcd_driver.c, C /*#define LCD_USE_FAST_ASM*/ void lcd_command(unsigned char cmd) { lcd_busy(); lcd_command_wr = cmd; } ID218 Riistvaralähedane programmeerimine

  12. Assembleri moodul, lcd_driver.c, Assembler #define LCD_USE_FAST_ASM void lcd_command(unsigned char cmd) - b _lcd_command: mov dptr, #0x8002 00001$: movx a, @dptr jb acc.7, 00001$ mov a, b mov dptr, #0x8000 movx @dptr, a 00101$: ret ID218 Riistvaralähedane programmeerimine

  13. Assembleri moodul, tulemused • Lcd_driver.c - C • 7 funktsiooni • led61.ihx - 5 587 Bytes • Lcd_driver.c - ass • 6 funktsiooni • Led61.ihx - 5 469 Bytes ID218 Riistvaralähedane programmeerimine

  14. Inline assembler, led64.c for ( j=0; j<10000; j++) { LED = i; } _asm mov dptr,#0xA000 . . . . . . . sjmp 00001$ 00002$: _endasm; ID218 Riistvaralähedane programmeerimine

  15. Ülesanded • Optimeerida näidisprogramm led 65.c • Optimeerimise võimalused • Taimeri katkestus, 1 s (kohustuslik) • Sobiva muutujatüübi valik • Sobiva Tsükklitüübi valik • Sobiva lõpetamisetingimuse valik • Üleliigsed read välja • Valida vähemalt 3 võimalust ID218 Riistvaralähedane programmeerimine

More Related