File: debugdevice.txt

package info (click to toggle)
openmsx 0.5.1-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,976 kB
  • ctags: 10,295
  • sloc: cpp: 63,525; xml: 37,105; sh: 1,403; python: 681; tcl: 207; makefile: 64
file content (147 lines) | stat: -rw-r--r-- 3,990 bytes parent folder | download
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
This document describes how the debugdevice, built in openMSX, can be used to
the advantage of an MSX programmer. 

1) Enable the device

a) easy method: use extension

The easiest way to enable the debugdevice is to start openMSX with the
debugdevice extension. To do this, simply add -ext debugdevice to the
openMSX-commandline.

b) less easy method: modify machine configuration

Another way to make the device work is to add it to the hardwareconfig.xml from
the machine that is used. If, for example, the device has to be used on the
Philips NMS 8250, the following lines can be added to the hardwareconfig.xml
file in the share/machines/Philips_NMS_8250 directory.

<device id="DebugDevice"> <type>DebugDevice</type> 
  <parameter> filename="~/debugout.txt"></parameter>
</device>

The third line, <parameter> ..., is optional and can contain any filename you
like.

2) The output ports

Controlling the device is done from within an MSX program. For this purpose, the
output ports 0x2E and 0x2F are used. Below the meaning of these ports are
described:

Port 0x2E: Mode set register 
bit 6-7 unused 
bit 4-5 output mode (0 = OFF, 1 = single byte, 2 = multi byte) 
bit 0-3 parameters for mode 1 (see below) 
bit 0-1 parameters for mode 2 (see below)

Parameters for mode 1 (singe byte mode):
bit 0 hexadecimal mode on/off 
bit 1 binary mode on/off
bit 2 decimal mode on/off
bit 3 ascii mode on/off

Parameters for mode 2 (multibyte mode):
bit 0-1 mode (0 = hex, 1 = binary, 2 = decimal, 3 = ascii mode)

3) Description of mode 1

In mode 1, any write to port 0x2E will result in output. This way, the
programmer can see if a specific address is reached by adding a single OUT to
the code. The output depends on the parameters set with the mode register. Each
bit represents a specific format, and by turning the bits on and off, the
programmer can decide which formats should be used.

example:

LD  A,65
OUT ($2f),A

will lead to 

41h 01000001b 065 'A' EmuTime:087a09c75a  (when all bits are on, modereg = 0x1f)

41h 065 'A' EmuTime: 087a09c75a (when de binary bit is off, modereg = 0x1d)

41h EmuTime: 087a09c75a (when only the hexbit is on, modereg = 0x11)

and so on.

The EmuTime part is a special number that keeps track of the openMSX emulation.
The larger this number is, the later the event took place. This is a great way
to find out in what order things are called. 

If the character to print is a special character, like carriage return,
linefeed, beep or tab, the character between the ' ' will be a dot (.) and the
normal character is 'displayed' at the very and of the line, so it won't mess up
the layout of the whole line.

4) Description of mode 2

In mode 2, writing to 0x2E does not output any text. All bytes written to this
register are stored in a buffer and only when the mode register is set again the
output is shown. Unlike mode 1, the data in this mode is always shown in one
mode only. It's either in hexmode, binary mode, decimal mode or ascii mode, but
never a combination. Also the EmuTime bit is left out.

example:

LD  A,xx
OUT ($2e),A
LD  A,$41
OUT ($2f),A
OUT ($2f),A
OUT ($2f),A
LD  A,xx
OUT ($2e),A	<--- at this point the output appears

if we substitude $20 for xx, we get:

41h 41h 41h

and if we substitute $22 for xx, we get:

065 065 065 

The extra zero is added to keep this equally aligned.  Finally, if we want ascii
output, all we need to do is change xx for $23:

AAA

In this special case, the space inbetween de data is left out. Any special
character like carriage return, linefeed, beep or tab will be printed as can be
espected.

5) Controlling the output

The openMSX console can be used to control the output of the device. This is
done by a normal setting type. Refer to commands.txt how to use the settings.
This setting can contain the following:

stdout 			  output goes to standard output 
stderr  		  output goes to standard error
any other filename	  output goes to the file with that filename