Start Keil tools (Keil uVision2)

Project | New Project... | name for your project

Select Generic, 8031

File | New (to create new source code file)

File | Save As, then specify .c extension
(when you do this first, then color-coding becomes enabled
when you type your C code)

Enter your C file

Editing Tips: right-click in editor window to
open the "Go to Line" window... comes in handy when debugging;
use Ctrl-] to go to matching brace

Project | Options for 'Target 1'

Select Output tab

Enable "Create HEX file" option

Expand "Target 1" hierarchy in files window on left side
(click the + symbol)

Right-click "Source Group 1" and select "Add Files to Group"

Select your .c file and click "Add", then click "Close"
(expand the hierarchy for "Source Group 1" and ensure that
your .c file is listed)

Select Project | Build target (or press F7)