Giter VIP home page Giter VIP logo

Comments (12)

uxmal avatar uxmal commented on August 17, 2024

I prefer the syntax

[[reko::register("D0",0,8)]]
[[reko::register("A1")]]
[[reko::stack]]

using namespaces to qualify the attribute and avoiding having to parse a string "0:8" when looking at byte slices.

It seems to me that specifying a byte slice (0,8) is redundant in

[[reko_partial_location(reg_D0,"0:8")]] BYTE SetTaskPri(...

since the function declaration already specifies the return type. Agree?

I should be able to write an implementation of this in a couple of days. Just want to make sure that we're in agreement on what the syntax is.

from reko.

nemerle avatar nemerle commented on August 17, 2024

As for syntax - yes, I realize that parametrization for other machines/environments will be much easier if register names are not hard-coded into attributes 😄

As for redundant slice..

  • It's from auto-transformed code - might actually be redundant
  • unlikely The function actually preserves the higher bits of D0 ?

when the support for this kind of attributes is 'in' we might steal boomerang's idea of allowing specifying full stack locations and have something like:

[[reko:memory("SP",-4)]]

from reko.

nemerle avatar nemerle commented on August 17, 2024

I've started implementing this on c2xml_attributes branch

from reko.

uxmal avatar uxmal commented on August 17, 2024

The token register is a reserved keyword in C/C++. Please switch to reg.

from reko.

nemerle avatar nemerle commented on August 17, 2024

Replaced 'register' with 'reg' in 52b3751

from reko.

uxmal avatar uxmal commented on August 17, 2024

I just checked in the C parser portion, following quite closely the C++11 spec section 7.6. In particular, the spec indicates that between [[reko::reg( and )]], any list of balanced tokens is allowed. This means that the new class CAttribute contains a list of tokens, and it is the job of the compiler/reko to interpret those tokens correctly. Right now, the interpretation is easy:
[[reko::reg( <StringConstant> )]] for register declarations
[[reko::mem( <StringConstant> <Comma> (<Minus>) <Integer> )]] for memory declarations

from reko.

uxmal avatar uxmal commented on August 17, 2024

Feature implemented in master. Now all we have to do is make reko recognize the services as A6-based. That's a different issue . Please verify that you can build and run any tests you think appropriate, then close.

from reko.

nemerle avatar nemerle commented on August 17, 2024

Awesome 😄

I've fixed a few problems in the exec_functions header, but there is one feature missing -> handling the bit selection in reg attribute.

  • I could remove the bit selection from the header, but that will remove some of the data decompilation might find useful ?
  • Or I might extended attr handling to preserve the bit-range in Register_v1 class ?

from reko.

uxmal avatar uxmal commented on August 17, 2024

Leave the bits in the file; the current implementation of [[reko::reg]] will just ignore them. Bit slice handling is should be handled generically by ApplicationBuilder.

Reko has an internal issue, which is the representation of data in registers which may be smaller than the register size itself. On the x86 we are lucky because the processor has aliases for the smaller pieces of the register (rax, eax, ax, al) but many other architectures like m68k and PowerPC don't. I expect I will have to take a look at ApplicationBuilder and its related classes to see what can be done.

In the meantime, can we consider this issue resolved? Attributes can now be specified, and we can add more, like [[noreturn]], which is a standard attribute that indicates that procedures don't return (think exit(int n)).

from reko.

nemerle avatar nemerle commented on August 17, 2024

This fails

void f([[reko::reg("D0",0,4)]] int intNum);

with:

System.FormatException: [[reko::reg]] attribute expects a register name.

since GetArgumentKindFromAttributes

if (attr.Tokens.Count != 1 || attr.Tokens[0].Type != CTokenType.StringLiteral)
    throw new FormatException("[[reko::reg]] attribute expects a register name.");
kind = new Register_v1 { Name = (string)attr.Tokens[0].Value };

from reko.

uxmal avatar uxmal commented on August 17, 2024

Fixed now.

from reko.

nemerle avatar nemerle commented on August 17, 2024

The file is parsed correctly now

from reko.

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.