znyk Temat założony przez niniejszego użytkownika |
[C++](Codeblocks) przypisanie wartosci zmiennej z rej pod adres » 2018-02-02 08:27:13 Witam Mam kłopot z kodem c++ napisanym w borland 4.5 z wstawkami asemblerowymi, chciałem go uruchomić w codeblocks 17.12, żeby program odpalał się po Windows 10.Dużo błędów poprawiałem, ale jeszcze zostały.Codeblocks wywala takie błedy: undefined reference to `a' undefined reference to `a1' undefined reference to `b1' undefined reference to `c1' Kod:
#include <dos.h> #include <conio.h> #include <stdio.h> #include <iostream> #include <graphics.h> #include <stdlib.h> #include <stdio.h>
int x, y, z; bool stan[ 4 ]; int znak;
void wyswietl_kursor() { asm ( "mov %ax,0x0001;" "int $0x33;" ); }
void ukryj_kursor() { asm ( "mov %ax,0x0002;" "int $0x33;" ); }
void paleta_szarosc() { setrgbpalette( 1, 0, 0, 0 ); setrgbpalette( 2, 15, 15, 15 ); setrgbpalette( 3, 25, 25, 25 ); setrgbpalette( 4, 35, 35, 35 ); setrgbpalette( 5, 45, 45, 45 ); setrgbpalette( 6, 63, 63, 63 ); setbkcolor( 4 ); }
void ramka( int x1, int y1, int x2, int y2 ) { setcolor( 2 ); line( x1, y1, x2, y1 ); line( x2, y1, x2, y2 ); line( x2, y2, x1, y2 ); line( x1, y2, x1, y1 ); setcolor( 5 ); line( x1 - 1, y1 - 1, x2 - 1, y1 - 1 ); line( x2 - 1, y1 + 1, x2 - 1, y2 - 1 ); line( x2 - 1, y2 - 1, x1 - 1, y2 - 1 ); line( x1 - 1, y2 - 1, x1 - 1, y1 - 1 ); }
void klawisz_wycisniety( int x1, int y1, int x2, int y2 ) { ukryj_kursor(); setcolor( 5 ); line( x1, y1, x2, y1 ); line( x1, y2, x1, y1 ); setcolor( 2 ); line( x2, y2, x1, y2 ); line( x2, y1, x2, y2 ); wyswietl_kursor(); }
void klawisz_wcisniety( int x1, int y1, int x2, int y2 ) { ukryj_kursor(); setcolor( 2 ); line( x1, y1, x2, y1 ); line( x1, y2, x1, y1 ); setcolor( 5 ); line( x2, y2, x1, y2 ); line( x2, y1, x2, y2 ); wyswietl_kursor(); }
void mysz()
{ int a; asm ( "mov %ax,0x000;" "int $0x33;" "mov a,%ax" ); if( a == 1 ) printf( "Mysz wykryta...OK" ); else { printf( "Sorry!!! Nie masz zainstalowanej myszy!" ); exit; } }
void stan_myszy( int * b, int * c, int * a ) { int a1, b1, c1; asm( "mov %ax,0x0003;" "int $0x33;" "mov a1,%bx;" "mov b1,%cx;" "mov c1,%dx;" ); * a = a1; * b = b1; * c = c1; }
void klawisz( int x1, int y1, int x2, int y2, bool * stan ) { int x, y, z; stan_myszy( & x, & y, & z ); if( * stan == false ) { if(( x > x1 ) &&( x < x2 ) &&( y > y1 ) &&( y < y2 ) &&( z == 1 ) ) { klawisz_wycisniety( x1, y1, x2, y2 ); * stan = true; delay( 300 ); }; } else { if(( x > x1 ) &&( x < x2 ) &&( y > y1 ) &&( y < y2 ) &&( z == 1 ) ) { klawisz_wcisniety( x1, y1, x2, y2 ); * stan = false; delay( 300 ); }; }; };
void clear_obszar() { ukryj_kursor(); setcolor( 5 ); line( 116, 16, 116, 221 ); line( 116, 221, 16, 221 ); line( 16, 221, 16, 466 ); line( 16, 466, 626, 466 ); line( 626, 466, 626, 56 ); line( 626, 56, 441, 56 ); line( 441, 56, 441, 16 ); line( 441, 16, 116, 16 ); setfillstyle( 0, 0 ); floodfill( 120, 20, 5 ); setcolor( 1 ); line( 115, 15, 115, 220 ); line( 115, 220, 15, 220 ); line( 15, 220, 15, 465 ); line( 15, 465, 625, 465 ); line( 625, 465, 625, 55 ); line( 625, 55, 440, 55 ); line( 440, 55, 440, 15 ); line( 440, 15, 115, 15 ); setcolor( 5 ); line( 116, 16, 116, 221 ); line( 116, 221, 16, 221 ); line( 16, 221, 16, 466 ); line( 16, 466, 626, 466 ); line( 626, 466, 626, 56 ); line( 626, 56, 441, 56 ); line( 441, 56, 441, 16 ); line( 441, 16, 116, 16 ); wyswietl_kursor(); };
void schemat_n( int x, int y ) { setcolor( 14 ); rectangle( x, y, x + 50, y + 80 ); setcolor( 11 ); circle( x + 25, y + 25, 20 ); setcolor( 9 ); line( x, y + 50, x + 50, y + 50 ); line( x, y + 50, x + 25, y + 80 ); line( x + 50, y + 50, x + 25, y + 80 ); }
void siec() { ukryj_kursor(); setcolor( 1 ); outtextxy( 185, 30, "SCHEMAT SIECI NEURONOWEJ" ); setcolor( 2 ); outtextxy( 120, 60, "zastosowano konwencje ze schematu neuronu" ); outtextxy( 250, 100, "WEJSCIA" ); outtextxy( 133, 175, "warstwy" ); outtextxy( 125, 185, "wejsciowe" ); outtextxy( 75, 285, "wagi" ); line( 225, 110, 225, 145 ); line( 325, 110, 325, 145 ); schemat_n( 200, 150 ); schemat_n( 300, 150 ); schemat_n( 150, 250 ); schemat_n( 250, 250 ); schemat_n( 350, 250 ); schemat_n( 250, 350 ); setcolor( 2 ); line( 275, 435, 275, 450 ); outtextxy( 250, 450, "WYJSCIE" ); outtextxy( 450, 275, "warstwa" ); outtextxy( 455, 285, "ukryta" ); outtextxy( 350, 375, "warstwa" ); outtextxy( 340, 385, "wyjsciowa" ); setcolor( 2 ); line( 175, 250, 225, 230 ); line( 275, 250, 225, 230 ); line( 375, 250, 225, 230 ); line( 175, 250, 325, 230 ); line( 275, 250, 325, 230 ); line( 375, 250, 325, 230 ); line( 275, 350, 175, 330 ); line( 275, 350, 275, 330 ); line( 275, 350, 375, 330 ); wyswietl_kursor(); delay( 300 ); znak = 0; z = 0; do { stan_myszy( & x, & y, & z ); if( kbhit() ) znak = getch(); if(( x > 7 ) &&( y > 60 ) &&( x < 97 ) &&( y < 100 ) &&( z == 1 ) ) znak = 27; } while( znak != 27 ); clear_obszar(); klawisz_wycisniety( 7, 60, 97, 100 ); delay( 300 ); }
void neuron() { setcolor( 1 ); outtextxy( 120, 30, "NEURON - BUDOWA I DZIALANIE" ); setcolor( 2 ); outtextxy( 120, 60, "Schemat Neuronu zostal opracowany przez McCullocha i Pittsa" ); outtextxy( 120, 70, "w 1943 roku i oparty zostal na budowie komorki nerwowej," ); setcolor( 14 ); rectangle( 200, 200, 410, 320 ); setcolor( 2 ); rectangle( 220, 220, 240, 300 ); rectangle( 220, 240, 240, 260 ); rectangle( 220, 260, 240, 280 ); line( 180, 230, 215, 230 ); line( 180, 250, 215, 250 ); line( 180, 270, 215, 270 ); line( 180, 290, 215, 290 ); outtextxy( 163, 228, "X1" ); outtextxy( 163, 248, "X2" ); outtextxy( 163, 268, "X3" ); outtextxy( 163, 288, "X4" ); outtextxy( 140, 300, "wejscia" ); outtextxy( 150, 180, "wagi polaczen" ); line( 228, 193, 228, 215 ); outtextxy( 224, 228, "W1" ); outtextxy( 224, 248, "W2" ); outtextxy( 224, 268, "W3" ); outtextxy( 224, 288, "W4" ); line( 245, 230, 280, 250 ); line( 245, 250, 280, 255 ); line( 245, 270, 280, 265 ); line( 245, 290, 280, 270 ); outtextxy( 295, 257, "SUMA" ); circle( 310, 260, 20 ); outtextxy( 338, 251, "S" ); line( 330, 260, 350, 260 ); line( 360, 245, 360, 275 ); line( 360, 245, 390, 260 ); line( 360, 275, 390, 260 ); outtextxy( 360, 257, "f(s)" ); line( 370, 248, 380, 190 ); outtextxy( 280, 180, "funkcja aktywacji neuronu" ); line( 400, 260, 450, 260 ); outtextxy( 455, 257, "x" ); outtextxy( 435, 300, "wyjscie" ); outtextxy( 170, 330, "schemat budowy pojedynczego neuronu" ); outtextxy( 45, 355, "Do wejsc doprowadzane sa sygnaly dochodzace z neuronow warstwy" ); outtextxy( 30, 365, "poprzedniej. Kazdy sygnal mnozony jest przez odpowiadajaca mu wartosc" ); outtextxy( 30, 375, "liczbowa zwana waga. Wplywa ona na percepcje danego sygnalu wejsciowego" ); outtextxy( 30, 385, "i jego udzial w tworzeniu sygnalu wyjsciowego przez neuron." ); outtextxy( 45, 395, "Waga moze byc pobudzajaca (dodatnia) lub opuzniajaca (ujemna),jezeli" ); outtextxy( 30, 405, "nie ma polaczenia miedzy neuronami to waga jest rowna zero. Zsumowanie" ); outtextxy( 30, 415, "iloczyny sygnalow i wag stanowia argument funkcji aktywacji neuronu." ); delay( 300 ); znak = 0; z = 0; do { stan_myszy( & x, & y, & z ); if( kbhit() ) znak = getch(); if(( x > 7 ) &&( y > 10 ) &&( x < 97 ) &&( y < 50 ) &&( z == 1 ) ) znak = 27; } while( znak != 27 ); clear_obszar(); klawisz_wycisniety( 7, 10, 97, 50 ); delay( 300 ); }
void pomoc() { setcolor( 1 ); outtextxy( 120, 30, "POMOC - Program Sieci Neuronowe" ); setcolor( 2 ); outtextxy( 120, 60, "Program sieci neuronowe, jest interaktywna prezentacja" ); outtextxy( 120, 70, "zagadnien zwiazanych z sieciami neuronowymi" ); outtextxy( 120, 80, "Pozwala na zapoznanie sie z podstawami budowy neuronu" ); outtextxy( 120, 90, "jak i caloscia sieci neuronowych." ); outtextxy( 120, 110, "Poszczegolne zagadnienia sa omawiane w sekcjach programu" ); setcolor( 1 ); outtextxy( 120, 130, "SEKCJA I - NEURON " ); setcolor( 1 ); outtextxy( 120, 150, "SEKCJA II - SIECI " ); znak = 0; z = 0; do { stan_myszy( & x, & y, & z ); if( kbhit() ) znak = getch(); if(( x > 452 ) &&( y > 7 ) &&( x < 541 ) &&( y < 43 ) &&( z == 1 ) ) znak = 27; } while( znak != 27 ); clear_obszar(); klawisz_wycisniety( 452, 7, 541, 43 ); delay( 300 ); }
int main() { int gdriver, gmode; mysz(); gdriver = DETECT; initgraph( & gdriver, & gmode, "C:\\Program Files (x86)\\CodeBlocks\\MinGW\\Include\\" ); wyswietl_kursor(); paleta_szarosc(); setcolor( 1 ); line( 115, 15, 115, 220 ); line( 115, 220, 15, 465 ); line( 15, 220, 15, 465 ); line( 625, 465, 625, 55 ); line( 625, 55, 440, 55 ); line( 440, 55, 440, 15 ); line( 440, 15, 115, 15 ); setcolor( 5 ); line( 116, 16, 116, 221 ); line( 116, 221, 16, 221 ); line( 16, 221, 16, 466 ); line( 16, 466, 626, 466 ); line( 626, 466, 626, 56 ); line( 626, 56, 441, 56 ); line( 441, 56, 441, 16 ); line( 441, 16, 116, 16 ); klawisz_wycisniety( 3, 3, 637, 477 ); klawisz_wcisniety( 5, 5, 100, 205 ); klawisz_wycisniety( 7, 10, 97, 50 ); klawisz_wycisniety( 7, 60, 97, 100 ); klawisz_wycisniety( 7, 110, 97, 150 ); klawisz_wycisniety( 7, 160, 97, 200 ); bool ster[ 2 ]; klawisz_wcisniety( 450, 5, 635, 45 ); klawisz_wycisniety( 452, 7, 541, 43 ); klawisz_wycisniety( 543, 7, 633, 43 ); setcolor( 1 ); outtextxy( 475, 22, "POMOC" ); outtextxy( 575, 22, "EXIT" ); outtextxy( 215, 19, "PRACA DYPLOMOWA" ); outtextxy( 125, 36, "PREZENTACJA BUDOWY SIECI NEURONOWYCH" ); ster[ 1 ] = false; outtextxy( 28, 28, "NEURON" ); outtextxy( 32, 78, "SIEC" ); do { stan_myszy( & x, & y, & z ); if(( x > 452 ) &&( y > 7 ) &&( x < 541 ) &&( y < 43 ) &&( z == 1 ) ) { klawisz_wcisniety( 452, 7, 541, 43 ); delay( 300 ); clear_obszar(); pomoc(); } if(( x > 7 ) &&( y > 10 ) &&( x < 97 ) &&( y < 50 ) &&( z == 1 ) ) { klawisz_wcisniety( 7, 10, 97, 50 ); delay( 300 ); clear_obszar(); neuron(); } if(( x > 7 ) &&( y > 60 ) &&( x < 97 ) &&( y < 100 ) &&( z == 1 ) ) { klawisz_wcisniety( 7, 60, 97, 100 ); delay( 300 ); clear_obszar(); siec(); } klawisz( 7, 110, 97, 150, & stan[ 2 ] ); klawisz( 7, 160, 97, 200, & stan[ 3 ] ); klawisz( 452, 7, 541, 43, & stan[ 0 ] ); klawisz( 543, 7, 633, 43, & stan[ 1 ] ); } while( !( kbhit() ) &&( !stan[ 1 ] ) ); closegraph(); };
|