Anjana said:
can anyone illustrate a program to read and print a number without
using standard library functions??
For suitable definitions of "read" and "print", this highly unportable,
untested program might fit the bill:
#define MK_FP(seg, off) (((seg) << 4) + off)
#define NUMLOCK 0x20
#define NUMLOCK_BIT 5
#define CAPSLOCK 0x40
#define CAPSLOCK_BIT 6
#define SCROLLLOCK 0x10
#define SCROLLLOCK_BIT 4
#define LOCKS_SEG 0x0040
#define LOCKS_OFF 0x0017
#define SCREEN_SEG 0xB800
#define SCREEN_OFF 0x0000
int main(void) {
int x;
{ /* read number */
unsigned char locks = *((unsigned char*)MK_FP(LOCKS_SEG, LOCKS_OFF));
x = (locks & SCROLLLOCK) >> SCROLLLOCK_BIT;
x += (locks & CAPSLOCK) >> CAPSLOCK_BIT;
x += (locks & NUMLOCK) >> NUMLOCK_BIT;
}
{ /* print number */
unsigned char * screen = (unsigned char *)MK_FP(SCREEN_SEG, SCREEN_OFF);
*screen = x + '0';
*(screen + 1) = 31; /* white on blue */
}
return 0;
}