Code Monkey home page Code Monkey logo

Comments (5)

jamque avatar jamque commented on September 17, 2024 1

I has sent some code privately. I think that something about ".include" it has involved in this bug.

from asmsx.

Fubukimaru avatar Fubukimaru commented on September 17, 2024

I have tried to reproduce this but I couldn't manage to do it. Maybe we're missing something.

test.asm:

aaa equ 20
.ds 3*aa
asmsx test.asm                                                                   
-------------------------------------------------------------------------------                
 asMSX v.0.19.3. MSX cross-assembler. Eduardo A. Robsy Petrus [01/11/2020]                     
-------------------------------------------------------------------------------                
Parsing file test.asm                                                                          
Expanding system macros                                                                        
Assembling source file test.asm                                                                
Assembling labels, calls and jumps                                                             
test.asm, line 2: undefined identifier

Could you provide me with a minimal code that reproduces the behaviour you're getting?

Thanks for reporting!

from asmsx.

Fubukimaru avatar Fubukimaru commented on September 17, 2024

Hello!

I have found where the issue lies but I have to think how to fix it.

The issue is located in PSEUDO_DS (.ds treatment). Here we add to the PC the result from value_16bits (which lies in $2). That result comes from a chain value_16bits -> value -> IDENTIFICATOR.

PSEUDO_DS value_16bits
	{
		if (conditional[conditional_level])
		{
			if (start_address > PC)
				start_address = PC;
                        fprintf(stderr, "PC: %i ePC: %i\n", PC, ePC);
			PC += $2;
			ePC += $2;
                        fprintf(stderr, "PC: %i ePC: %i\n", PC, ePC);
			if (PC > 0xffff)
				error_message(1, fname_src, lines);           // <----- Memory overflow error is reported here
		}
	}

The value returned for IDENTIFICATOR comes from the following function:

int read_label(char *name)
{
    if (verbose >= 2) 
    {
        fprintf(stderr,"Reading label: %s - on pass %u\n", name, pass);
    }

    // Search the label
	int i;
    
    // Find the label and return its value if found.
    i = search_label(id_list, name, 0, total_global);
    if (verbose >= 2) 
    {
        fprintf(stderr, "- Label index in vector: %i\n", i);
    }
    if (i != -1) return id_list[i].value;
    

    // If label not found and we're in the first pass, we leave it for the
    // second pass
	if ((pass == 1) && (i == -1))
		return ePC;

    // Else, ERROR
	error_message(12, fname_src, lines);
	exit(0);	/* error_message() never returns; add exit() to stop compiler warnings about bad return value , fname_src, lines*/
}

In particular:

    // If label not found and we're in the first pass, we leave it for the
    // second pass
	if ((pass == 1) && (i == -1))
		return ePC;

When the label is not found and we're in the first pass, we return the ePC, which at that point is ePC == PC.

In the case of the small example it doesn't crash because the PC is not moved past 0xFFFF.

Before processing .ds:
PC: 16 ePC: 16

After processing .ds:
PC: 64 ePC: 64

So it's reserving 48 bytes for that.

In the case of the code (sorry, it's private :)) you have sent me

It crashes here:

if (PC > 0xffff)
    error_message(1, fname_src, lines);           // <----- Memory overflow error is reported here

As we get the following:
Before => PC: 51768 ePC: 51768
After => PC: 103536 ePC: 103536

So PC > 0xFFFF.

I have to understand why returning ePC when the tags are not found in the first pass is a valid value and in which parts of the processing is this used.

To do:

  • Find where IDENTIFICATOR is used and see how the result is used
  • Understand why ePC is returned (Contact Robsy just in case he remembers)

My guess is that we should ignore it on the first pass (therefore PC = PC or PC = ePC and not add it).

Let's keep on rolling :)
https://www.youtube.com/watch?v=bV-hSgL1R74

from asmsx.

Fubukimaru avatar Fubukimaru commented on September 17, 2024

We cannot return another value, lets say, 0 because it crashes all the tests.

What I have done to short this out is to prevent PSEUDO_DS to throw this error when we're in the first pass.

from asmsx.

Fubukimaru avatar Fubukimaru commented on September 17, 2024

I have added a safety clause. When the tag is not found and there is an overflow, we subtract it so the PC and ePC dont' fly away. Should be ok as this is finally checked on the second pass.

d6f1cd7

from asmsx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.