PKP
VS1000 P
ROGRAMMER
’
S
G
UIDE
VSMPG
COM speed 115200
Waiting for a connection to the board...
Caused interrupt
Chip version "1000"
Stack pointer 0x19e0, bpTable 0x7c0f
User program entry address 0x7398
hello.bin: includes optional header, 4 sections, 441 symbols
Section 1: code
page:0 start:80 size:1 relocs:1 fixed
Section 2: const_x
page:1 start:8096 size:14 relocs:0
Section 3: main
page:0 start:81 size:14 relocs:2
Section 4: VS_stdiolib page:0 start:95 size:50 relocs:13
>
Next the executing address is set to be 0x0050 (statically linked loading vector for main())
by command
g 0x50
and executed by command
e
. On the screen it should look like:
> g 0x50
> e
Hello, World!
This final stage can be automated by writing the commands
g 0x50
and
e
to file
e.cmd
and calling the emulator with the command line
vs3emu -chip vs1000 -s 115200 -l hello.bin e.cmd
The emulator can be exited by pressing Ctrl-C.
7.1.4
Note
If your board has boot code in the Nand Flash, the Nand Flash boot code runs after
main() exits.
7.1.5
Input and Output
This example uses the vs3emu interface to handle C standard I/O (
stdin, stdout
).
With it it’s possible to write messages to the user and read input from the PC keyboard.
Also it’s possible to open, read and write files in the PC. The library contains the ele-
mentary functions necessary for input and output. In this example, the library function
puts()
, which outputs a line of text and a linefeed to
stdout
, was used.
Since the memory capacity of the chip is limited, the more advanced and memory con-
suming input/output functions such as printf should not be used. When you need to print
out values of variables, it’s recomended to use a smaller special function for it. As an
example, here is a small function that outputs the value of a 16-bit unsigned integer as
a hexadecimal value:
Rev. 0.20
2011-10-04
Page