-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
89 lines (73 loc) · 2.24 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "predef.h"
#include <stdio.h>
#include <ctype.h>
#include <startnet.h>
#include <autoupdate.h>
#include <NetworkDebug.h>
extern "C" {
void UserMain(void * pd);
}
extern "C" {
void AssemblyProgram(); /*Subroutine for student coding*/
void cr(); /*Subroutine for carriage return and line feed*/
int getstring(); /*Subroutine to get numerical value from keyboard*/
void value(int P1); /*Subroutine to print decimal value to monitor*/
}
/*****************************************************
A Subroutine that prints a decimal number to the monitor
Input = decimal number on stack
Output = nothing
*****************************************************/
void value(int P1)
{
iprintf( "\%d", P1);
}
/*****************************************************
A Subroutine that generates a carriage return and linefeed
Input = nothing
Output = nothing
*****************************************************/
void cr()
{
iprintf( "\r\n");
}
/*****************************************************
A Subroutine that gets a numerical value from the keyboard
Input = nothing
Output = numberical value in register D0
This subroutine includes buffer check by clearing the buffer
if a wrong input is given and prompts the user to re-enter
a valid number
*****************************************************/
int number;
int getstring()
{
int r;
repeat: r = scanf("%d", &number );
/*******************************************
* clears the buffer if a wrong input is given
*********************************************/
if (r==0)
{ getchar();
iprintf("\n");
iprintf("Not a number entered, please enter valid number \n");
goto repeat;
}
return number;
}
/**************************************************************/
const char * AppName="bubblesortB";
void UserMain(void * pd) {
InitializeStack();
OSChangePrio(MAIN_PRIO);
EnableAutoUpdate();
#ifdef _DEBUG
InitializeNetworkGDB_and_Wait();
#endif
OSTimeDly(100); /*Time delay for debugging purposes */
iprintf("Application started\n");
while (1) {
AssemblyProgram(); /*the main program for students to code*/
OSTimeDly(20); /*delay program*/
}
}