Comments (7)
If you want to learn the instructions, you can see my latest changes.
Keep in mind that some variables like PiecesThem, PiecesPawn, ect. are in registers already. The full list is in the beginning of the EvalThreats macro. I will give you the operations of some of the instructions here.
xor a, b ; same as a = a^b;
and a, b ; same as a = a&b;
or a, b ; same as a = a|b;
andn a, b, c ; same as a = (~b) & c, uses a macro for cpu without this instruction, see BasicMacros.asm
from asmfish.
mov r8, PiecesThem
mov r9, PiecesPawn
and r9, r8 ;r9 = pos.pieces(Them, PAWN)
xor r8, r9 ;r8 = (pos.pieces(Them) ^ pos.pieces(Them, PAWN))
mov r9, qword[.ei.attackedBy+8*(8*Them+Pawn)]
andn r10, qword[.ei.attackedBy2+8*Us], qword[.ei.attackedBy2+8*Them]
or r9, r10 ; r9 = stronglyProtected
and r8, r9
; r8 = defended
andn r9, r9, PiecesThem ; r9 = ~stronglyProtected & pos.pieces(Them)
and r9, AttackedByUs ; r9 = ~stronglyProtected & pos.pieces(Them) & ei.attackedBy[Us][ALL_PIECES]
; r9 = weak
or r8, r9
; r8 = defended | weak
I tried per your explanations which are clear enough and without looking at your code. Afraid to test it though, not to blow my computer.
from asmfish.
Ah, don't be afraid of blowing up your computer. Your computer runs the program like it runs any other program. The worst you can get here is probably a segfault, which will be unhandled and thus passed to the os. There are several ways you can lock up your system:
- set the program to real time priority and start a lot of threads that get stuck in an infinite loop
- allocate a ton of memory and then start to fill it up
I think you will see there is no danger of that in this section of code.
from asmfish.
Ok, I'll "try this at home" and then try to find my errors.
from asmfish.
So your code will assemble on popcnt and base versions (and be correct!) but it will not assemble on bmi2 version. This is due to the andn macro.
line:
andn r10, qword[.ei.attackedBy2+8*Us], qword[.ei.attackedBy2+8*Them]
andn is defined as a macro in line 295 of Basic macros.asm
This means that the preprocessor is going to either of these things
when CPU_HAS_BMI1=0
mov r10, qword[.ei.attackedBy2+8*Us]
not r10
and r10, qword[.ei.attackedBy2+8*Them]
when CPU_HAS_BMI1=1
andn r10, qword[.ei.attackedBy2+8*Us], qword[.ei.attackedBy2+8*Them]
This last instruction is not encodable because only the last argument is allowed to be a memory reference.
http://www.felixcloutier.com/x86/ANDN.html
Before you start wishing that that it were possible to encode two memory references into a single instruction, keep in mind that the cpu actually has to decode all these instructions. That is, if you believe the power consumption myth.
https://www.usenix.org/system/files/conference/cooldc16/cooldc16-paper-hirki.pdf
from asmfish.
Thanks for the detailed explanation and reference. Wow, I almost did it !
from asmfish.
mov r8, PiecesThem
mov r9, PiecesPawn
and r9, r8 ;r9 = pos.pieces(Them, PAWN)
xor r8, r9 ;r8 = (pos.pieces(Them) ^ pos.pieces(Them, PAWN))
mov r9, qword[.ei.attackedBy+8*(8*Them+Pawn)]
mov r10, qword[.ei.attackedBy2+8*Us]
andn r10, r10, qword[.ei.attackedBy2+8*Them]
or r9, r10 ; r9 = stronglyProtected
and r8, r9
; r8 = defended
andn r9, r9, PiecesThem ; r9 = ~stronglyProtected & pos.pieces(Them)
and r9, AttackedByUs ; r9 = ~stronglyProtected & pos.pieces(Them) & ei.attackedBy[Us][ALL_PIECES]
; r9 = weak
or r8, r9
; r8 = defended | weak
This should work then (I am away from my 64 bit to try it)
from asmfish.
Related Issues (20)
- General Updates/Questions HOT 82
- armFish: Implementation of the arctan function HOT 1
- Action Items
- Cannot find FASMG to make a compile HOT 6
- what is bmi1 & bmi2 (question) HOT 5
- how to use big large pages file (question)
- Flat assembler g
- BMI1 better then BMI2 HOT 7
- Question: does project is dead? HOT 2
- Latest asmFish versions and progress update HOT 9
- Lc0 beat SF decisively at two tournaments HOT 2
- Update: Commit migration in progress. HOT 2
- Android binary (armFish) HOT 1
- Syzygy 7men support HOT 3
- question asmfish support the Nalimov format ?? HOT 1
- crashes on computers with more than 1 processor groups HOT 27
- brain2polyglot HOT 1
- Is it possible to embed assembly in official Stockfish's C++ code? HOT 3
- How is asmFish doing these days? HOT 5
- Memory usage
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asmfish.