
(REF): MC68HC12:An Intro S/W and H/W Interfacing, Han-Way Huang, THOMSON/Delmar Learning, 2003, chap 5.//FILE: gcd2.c #include <stdio.h> #include <putchar_dp256.c> int gcd(int a, int b); void main (void) { int x, y, result; x = 3600; y = 1500; result = gcd(x, y); printf("The gcd of %d and %d is %d\n", x, y, result); return; } int gcd(int a, int b) { int i, temp; if (a > b) { temp = a; a = b; b = temp; } if (a == b) return a; if (a == 1) return 1; temp = 1; for (i = 2; i <= a; i++) { if (((a % i) == 0) && ((b % i) == 0)) temp = i; } return temp; }
Start ICC12, click "Project" menu to drop down, select "Options".

Setup the include & library path,

Check language and select output format,

Select "9S12DP256 12K RAM mode" for DRAGON 12 as target. We only illustrate EVB mode of D-Bug12 monitor.


Result,


Edit and repeat above until no errors,

Open the terminal,

Click "Open Com Port" button,

Click "Browse" button for "gcd2.s19", "Open" it.

Connect RS232 cable between PC and DRAGON 12. Power-up the board. Press RESET on DRAGON 12, type LOAD, enter "gcd2.s19", hit RETURN on PC keyboard. Type G 1000 to execute.
