Fixed the detection of where to start and stop segments.
This commit is contained in:
@@ -107,14 +107,6 @@ int IsSegmentStart (unsigned Addr)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int HaveSegmentChange (unsigned Addr)
|
|
||||||
/* Return true if the segment change attributes are set for the given address */
|
|
||||||
{
|
|
||||||
return (GetAttr (Addr) & (atSegmentStart | atSegmentEnd)) != 0x0000;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned GetGranularity (attr_t Style)
|
unsigned GetGranularity (attr_t Style)
|
||||||
/* Get the granularity for the given style */
|
/* Get the granularity for the given style */
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -100,9 +100,6 @@ int IsSegmentEnd (unsigned Addr);
|
|||||||
int IsSegmentStart (unsigned Addr);
|
int IsSegmentStart (unsigned Addr);
|
||||||
/* Return true if a segment starts at the given address */
|
/* Return true if a segment starts at the given address */
|
||||||
|
|
||||||
int HaveSegmentChange (unsigned Addr);
|
|
||||||
/* Return true if the segment change attributes are set for the given address */
|
|
||||||
|
|
||||||
unsigned GetGranularity (attr_t Style);
|
unsigned GetGranularity (attr_t Style);
|
||||||
/* Get the granularity for the given style */
|
/* Get the granularity for the given style */
|
||||||
|
|
||||||
|
|||||||
@@ -348,6 +348,8 @@ static void OptVersion (const char* Opt attribute ((unused)),
|
|||||||
static void OneOpcode (unsigned RemainingBytes)
|
static void OneOpcode (unsigned RemainingBytes)
|
||||||
/* Disassemble one opcode */
|
/* Disassemble one opcode */
|
||||||
{
|
{
|
||||||
|
unsigned I;
|
||||||
|
|
||||||
/* Get the opcode from the current address */
|
/* Get the opcode from the current address */
|
||||||
unsigned char OPC = GetCodeByte (PC);
|
unsigned char OPC = GetCodeByte (PC);
|
||||||
|
|
||||||
@@ -380,7 +382,8 @@ static void OneOpcode (unsigned RemainingBytes)
|
|||||||
** - ...if we have enough bytes remaining for the code at this address.
|
** - ...if we have enough bytes remaining for the code at this address.
|
||||||
** - ...if the current instruction is valid for the given CPU.
|
** - ...if the current instruction is valid for the given CPU.
|
||||||
** - ...if there is no label somewhere between the instruction bytes.
|
** - ...if there is no label somewhere between the instruction bytes.
|
||||||
** If any of those conditions is false, switch to data mode.
|
** - ...if there is no segment change between the instruction bytes.
|
||||||
|
** If any one of those conditions is false, switch to data mode.
|
||||||
*/
|
*/
|
||||||
if (Style == atDefault) {
|
if (Style == atDefault) {
|
||||||
if (D->Size > RemainingBytes) {
|
if (D->Size > RemainingBytes) {
|
||||||
@@ -390,16 +393,15 @@ static void OneOpcode (unsigned RemainingBytes)
|
|||||||
Style = atIllegal;
|
Style = atIllegal;
|
||||||
MarkAddr (PC, Style);
|
MarkAddr (PC, Style);
|
||||||
} else {
|
} else {
|
||||||
unsigned I;
|
for (I = PC + D->Size; --I > PC; ) {
|
||||||
for (I = 1; I < D->Size; ++I) {
|
if (HaveLabel (I) || IsSegmentStart (I)) {
|
||||||
if (HaveLabel (PC+I)) {
|
|
||||||
Style = atIllegal;
|
Style = atIllegal;
|
||||||
MarkAddr (PC, Style);
|
MarkAddr (PC, Style);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (I = 1; I < D->Size - 1u; ++I) {
|
for (I = 0; I < D->Size - 1u; ++I) {
|
||||||
if (HaveSegmentChange (PC+I)) {
|
if (IsSegmentEnd (PC + I)) {
|
||||||
Style = atIllegal;
|
Style = atIllegal;
|
||||||
MarkAddr (PC, Style);
|
MarkAddr (PC, Style);
|
||||||
break;
|
break;
|
||||||
@@ -422,7 +424,6 @@ static void OneOpcode (unsigned RemainingBytes)
|
|||||||
*/
|
*/
|
||||||
if (D->Size <= RemainingBytes) {
|
if (D->Size <= RemainingBytes) {
|
||||||
/* Output labels within the next insn */
|
/* Output labels within the next insn */
|
||||||
unsigned I;
|
|
||||||
for (I = 1; I < D->Size; ++I) {
|
for (I = 1; I < D->Size; ++I) {
|
||||||
ForwardLabel (I);
|
ForwardLabel (I);
|
||||||
}
|
}
|
||||||
@@ -469,11 +470,16 @@ static void OneOpcode (unsigned RemainingBytes)
|
|||||||
DataByteLine (1);
|
DataByteLine (1);
|
||||||
++PC;
|
++PC;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsSegmentEnd (PC - 1)) {
|
/* Change back to the default CODE segment if
|
||||||
EndSegment ();
|
** a named segment stops at the current address.
|
||||||
|
*/
|
||||||
|
for (I = D->Size; I >= 1; --I) {
|
||||||
|
if (IsSegmentEnd (PC - I)) {
|
||||||
|
EndSegment ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user