3 # This file is Copyright 2009, 2010 Dean Hall.
5 # This file is part of the Python-on-a-Chip program.
6 # Python-on-a-Chip is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
9 # Python-on-a-Chip is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
13 # is seen in the file COPYING in this directory.
16 PyMite Object Descriptor Decoder
17 ================================
19 Decodes an object descriptor value into its bit fields.
23 # @copybrief pmOldDecoder
25 ## @package pmOldDecoder
26 # @brief PyMite Object Descriptor Decoder
28 # Decodes an object descriptor value into its bit fields.
35 ./pmOdDecoder.py odvalue
60 0x14,0x15,0x16,0x17,0x18,
70 def od_decode(odvalue
):
73 "size": (odvalue
& 0x001F) * 4,
74 "type": TYPES
[(odvalue
& 0x3E00) >> 9],
75 "mark": (odvalue
& 0x4000) >> 14,
76 "free": (odvalue
& 0x8000) >> 15,
81 if s
.startswith("0x"):
87 odvalues
= sys
.argv
[1:]
88 odvalues
= map(to_int
, odvalues
)
89 ods
= map(od_decode
, odvalues
)
91 print("%d (0x%04x): %s[%d], f=%d, m=%d"
92 % (od
['val'], od
['val'], od
['type'], od
['size'], od
['free'], od
['mark']))
95 if __name__
== "__main__":