Giter VIP home page Giter VIP logo

Comments (5)

moonheart08 avatar moonheart08 commented on May 14, 2024

For now, I don't think so(?), so the best way would just be to use 0b0000_0000, and just remember which bit is which reg which isn't too hard.

from customasm.

aslak3 avatar aslak3 commented on May 14, 2024

Yes, it's not too bad. Hopefully it'll support this kind of thing soon.

I guess I could feed my assembly through CPP and use some macros.

from customasm.

p-rivero avatar p-rivero commented on May 14, 2024

One way you could do this is by defining the registers as constants and then asking for an integer as the register list.

R0 = 1
R1 = 2
R2 = 4
R3 = 8
R4 = 16
R5 = 32
R6 = 64
R7 = 128

#cpudef "test"
{
    #bits 8
    
    #tokendef REG
    {
        r0 = 1
        r1 = 2
        r2 = 4
        r3 = 8
        r4 = 16
        r5 = 32
        r6 = 64
        r7 = 128
    }
    
    popmulti {register_list: u8}, ( {ea: REG} ) -> 0xABCD @ register_list @ ea[7:0]

}

This way popmulti R0+R1+R3+R4+R5+R6,(r7) becomes 0xABCD7B80.

You can also define the constants in lowercase and it would work fine in most cases, but if you've got an instruction with the same mnemonic and multiple addressing modes (like if both mov r0, r3 and mov r0, 123 are legal) you should keep them uppercase or the assembler will get confused.
Also, if you don't need your instruction to use the + sign and you are willing to be more flexible, you could do stuff like
popmulti ALL_REGS - R3, (r7) (with ALL_REGS = 0xFF) or typing the registers out of order. However, I would recommend using the | sign instead of +, in case you accidentally type a register twice (popmulti R1 + R1, (r7) gets interpreted as R2 since 2+2=4, popmulti R1 | R1, (r7) gets reduced to just R1 since 2|2=2).

from customasm.

aslak3 avatar aslak3 commented on May 14, 2024

That works well, thanks! Much easier then bringing out CPP. Using an or to bring them together seems the sensible approach.

I'm not sure if there's a general solution to this case.

Man, I might have a reason to learn Rust now.

from customasm.

hlorenzi avatar hlorenzi commented on May 14, 2024

I'm closing this since it can be achieve like p-rivero suggested or with recursive rules in newer versions! Feel free to open this issue again if you still need help.

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.