Giter VIP home page Giter VIP logo

Comments (5)

hlorenzi avatar hlorenzi commented on May 31, 2024 1

I forgot to mention there's an undocumented #labelalign directive, which might come in handy here? When you specify it, the assembler will automatically align every global label you define. So for example:

#bits 8
#labelalign 32

#ruledef
{
    hlt => 0x33
}

hello:
    #d "Hello"

code:
    hlt

This would be interpreted as if there was an #align 32 directive right before each of hello: and code:, so code will actually start at address 0x8. (Non-global labels are not affected, though.)

Does this help the issue everyone is having here? I should add it to the documentation. 😅

from customasm.

hlorenzi avatar hlorenzi commented on May 31, 2024

That's a good idea! I hadn't even realized that would be a problem.

Any possibility that the user would want this (broken) behavior instead?

from customasm.

TChapman500 avatar TChapman500 commented on May 31, 2024

I don't believe that there would be any reason for anyone to want this type of behavior.

from customasm.

parasyte avatar parasyte commented on May 31, 2024

For ISAs with a minimum addressable data size that is not 8-bits, this suggestion sounds reasonable. I have found that #bits is usually not the right tool, however.

I am working with MIPS at the moment, where all instructions are 32 bits wide. But the minimum addressable data size is 8 bits. For this architecture, #bits 32 is incorrect. That said, I would still like a way, in general, to pad some data types (like strings) up to a specific alignment. Currently, I have to do this manually:

hello:
#align 32
#d "Hello, world!\0"

version:
#align 32
#d "Version: 1.0.0\0"

It is also still useful to not align after strings, in cases where you want to tightly pack the data.

It's easy to forget to include an alignment directive following data types with sizes that are not divisible by the minimum instruction width. For that reason, I think adding a new directive to specify instruction width (not data width) will be useful, but I don't think even that solves this particular case (which involves data).

Maybe a new directive to both align and output data is needed? Or an extension to the #d directive which adds a padding parameter?

from customasm.

parasyte avatar parasyte commented on May 31, 2024

I believe that addresses the specific issue I brought up in this thread. It looks like the label alignment can be temporarily made smaller for packing structs, also.

from customasm.

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.