tenderlove / fisk Goto Github PK
View Code? Open in Web Editor NEWA pure Ruby assembler
License: Apache License 2.0
A pure Ruby assembler
License: Apache License 2.0
I've written a lot of ruby (>15 years ago) but I've never dealt with building gems... (until now... my first attempt was for fisk). Tried to install fisk but ran into issues, as I did not get the gemspec right and the it did not get installed right. (was able to install all the prerequisites, include capstone dev, etc).
I modified the example so that it should work on Linux, but was not able to try it out...
Fisk would be perfect for a proof of concept prototype new language compiler I'm working on...
I think you need to do register allocation at the control-flow level, not the lexical instruction level.
For example your allocator will allocate this with just two registers, re-using r9
for both reg1
and reg3
, but really reg1
is still alive.
reg1 = 1
reg2 = 1
head:
goto break if reg1 > 100
reg1 = reg1 + reg2
reg3 = 1 # your register allocator thinks reg1 is dead at
# this point, so shares a register with reg3, but
# it's still alive - it's going to be used in the
# next iteration!
reg2 = reg3
goto head
break:
reg1 = fisk.register
fisk.mov reg1, fisk.imm32(1)
reg2 = fisk.register
fisk.mov reg2, fisk.imm32(1)
fisk.put_label(:head)
fisk.cmp reg1, fisk.imm32(100)
fisk.jg(fisk.label(:break))
fisk.add reg1, reg2
reg3 = fisk.register
fisk.mov reg3, fisk.imm32(1)
fisk.mov reg2, reg3
fisk.jmp(fisk.label(:head))
fisk.put_label(:break)
fisk.assign_registers([Fisk::Registers::R9, Fisk::Registers::R10]) # should fail!
I think instructions like set
can only use the 8-bit registers, like sete al
. I don't think Fisk provides access to these? Could it? I'm trying to reduce branches in https://github.com/kddnewton/regular_expression using set
and cmov
.
I'm trying to encode the REP
instruction, e.g. rep movsb
, which, as far as I know, it's a valid x64 instruction.
I've checked the instructions list, but oddly, it's entirely missing, so I'm not sure if this is intentional.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.