Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using opening/closing quotes makes WinMIPS ignore variable declaration #1

Open
facundoq opened this issue Oct 30, 2020 · 2 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@facundoq
Copy link

The following variable declaration is ignored by WinMIPS.

.data
var: .asciiz “Hola”

.code
halt

Replacing “Hola” with "Hola" fixes the issue but an error should be raised instead.

@AndoniZubimendi
Copy link
Owner

It seems that the first-pass compilation step is ignoring directive giving errors, so anything after the .ascii (or .asciiz) directive that is not a double quote will silently fail

In first-pass function, if directive returns something different from 0, it is not an error.

    if (directive(1,ptr,line)) return 0;
    sprintf(txt,"Pasada 1 - Error en linea %d\n",lineptr);
    AfxMessageBox(txt);
    return 1;

In the directive function, not finding the double quote, returns -1, that is is an error. But the above function takes it as no error.

   case 1:     // .asciiz
        if (CODEORDATA==CODE) return FALSE;
        ptr=eatwhite(ptr);
        if (ptr==NULL) return (-1);
        if (*ptr!='"' && *ptr!='\'') return (-1);

The obvious fix seems to be to replace the if of the first-pass function to check for greater than 0, instead of just not 0.

    if (directive(1,ptr,line) > 0) return 0;

When I have some time I will try this fix and test if it does not break anything, as this is very old code and it could trigger other side effects.

@AndoniZubimendi AndoniZubimendi self-assigned this Oct 31, 2020
@facundoq
Copy link
Author

facundoq commented Oct 31, 2020 via email

@AndoniZubimendi AndoniZubimendi added the bug Something isn't working label Nov 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants