Comments (5)
I has sent some code privately. I think that something about ".include" it has involved in this bug.
from asmsx.
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.
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.
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.
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.
from asmsx.
Related Issues (20)
- Documentation. Itemize system-variables that do not have a standard name. HOT 2
- Make Conditional Assembly compatible with other cross-assemblers HOT 5
- [BUG] Including file without ending newline breaks
- [BUG] Why this behaviour? PepeIssue [DIRECTIVES ORDER] diferent results, best persona HOT 1
- END statement missing HOT 3
- [BUG] Code processed despite IF condition is not met HOT 1
- [BUG] Segmentation fault when no permission to write files
- Add filename to the error reporting in the preprocessors HOT 1
- Add warning for unused parameters in macro HOT 2
- Rework how local labels work HOT 2
- asmsx variables are unsigned short int type HOT 3
- No problems HOT 2
- Document Macros HOT 2
- Add ARMv6h cross-compilation HOT 6
- MEGAROM and ORG directive Just Won't Splice HOT 3
- Local label semantics HOT 6
- Symbol file with Emulicious format (CDB) HOT 5
- Conditional assembly does not evade tag definitions HOT 2
- Directive .FILENAME does not work
- last binary windows version does not work at all HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asmsx.