-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fog conditionals are now complete! Both conditional and unconditional…
… jumps now work. FetchByte was leaving garbage in the upper bytes of the result 64-bit word. Fixed some comments. Fixed the indexing used by FetchByte, which was indexing by 8s instead of by 1s. Disassembler now handles the added instructions.
- Loading branch information
1 parent
2c760bc
commit 9b804d7
Showing
28 changed files
with
186 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/Mist.package/FogX64FetchByteNode.class/instance/assignOutputVariableAvoiding..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
x64-compiling-pass1 | |||
assignOutputVariableAvoiding: siblingClobbered | |||
"Because I clobber my output's generationLocation before consuming my inputs (to clear the upper bytes), | |||
I must avoid my children's consumptionLocations" | |||
|
|||
| allClobbered | | |||
allClobbered := siblingClobbered copy. | |||
children do: [ :childVar | allClobbered add: childVar consumptionLocation ]. | |||
super assignOutputVariableAvoiding: allClobbered |
4 changes: 3 additions & 1 deletion
4
packages/Mist.package/FogX64FetchByteNode.class/instance/emitOpTo..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,9 +1,11 @@ | |||
x64-compiling-pass2 | x64-compiling-pass2 | ||
emitOpTo: codeStream | emitOpTo: codeStream | ||
"Base and index must be in registers, result must be in a register." | "Base and index must be in registers, result must be in a register. | ||
Must clear the destination register first, or the high-order bits could be anything." | |||
|
|
||
| baseLoc indexLoc destLoc | | | baseLoc indexLoc destLoc | | ||
baseLoc := self base consumptionLocation. | baseLoc := self base consumptionLocation. | ||
indexLoc := self index consumptionLocation. | indexLoc := self index consumptionLocation. | ||
destLoc := parent generationLocation. | destLoc := parent generationLocation. | ||
codeStream movIntConstant: 0 to: destLoc. "Better to xor with self here." | |||
codeStream movByteFromAddressIn: baseLoc plusIndexIn: indexLoc toRegister: destLoc | codeStream movByteFromAddressIn: baseLoc plusIndexIn: indexLoc toRegister: destLoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/Mist.package/FogX64Node.class/instance/addOwnClobberedTo..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,6 +1,6 @@ | |||
x64-compiling-pass1 | x64-compiling-pass1 | ||
addOwnClobberedTo: aClobberedSet | addOwnClobberedTo: aClobberedSet | ||
|
|
||
"If my own execution uses or clobbers any locations other than my own input and output variables, or the scratch registers rax, rbx, and r11,, add those to the given clobbered set. Must add any scratch registers that I *might* use." | "If my own execution uses or clobbers any locations other than my own input and output variables, other than the scratch registers rax, rbx, and r11, add those to the given clobbered set." | ||
|
|
||
"Many nodes do not clobber anything" | "Many nodes do not clobber anything" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/Mist.package/X64DisassemblerDisp32Operand.class/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
A X64DisassemblerDisp32Operand is a 32-bit RIP-relative signed displacement, not associated with a SIB byte. | |||
In 64-bit mode (the only mode used by Mist) this appears in only JMP and Jcc instructions. | |||
|
|||
Instance Variables: | |||
bytesSoFar <Integer> How many of the four displacement bytes have been received so far | |||
displacementValue <Integer> The accumulated value. This will be unsigned until the last byte is received, at which point it may be discovered that it should be negative and adjusted. |
9 changes: 9 additions & 0 deletions
9
packages/Mist.package/X64DisassemblerDisp32Operand.class/instance/dispByte..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
instruction byte handling | |||
dispByte: byte | |||
"Displacement bytes are little-endian, so each byte received is of greater significance than all received so far." | |||
|
|||
displacementValue := displacementValue + (byte bitShift: bytesSoFar * 8). | |||
bytesSoFar := bytesSoFar + 1. | |||
"If we've received the last byte, we can now convert value from unsigned to signed." | |||
(bytesSoFar = 4 and: [ displacementValue > 16r7FFFFFFF ]) | |||
ifTrue: [ displacementValue := displacementValue - 16r100000000 ] |
5 changes: 5 additions & 0 deletions
5
packages/Mist.package/X64DisassemblerDisp32Operand.class/instance/informDisplacement.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
private | |||
informDisplacement | |||
"I am an operand that involves a non-SIB displacement, so let my instruction know how many displacement bytes to expect." | |||
|
|||
instruction displacementSize: 4 |
6 changes: 6 additions & 0 deletions
6
packages/Mist.package/X64DisassemblerDisp32Operand.class/instance/informModRM.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
private | |||
informModRM | |||
"If this operand requires a ModRM byte, tell my instruction. | |||
JMP and Jcc don't, so do nothing." | |||
|
|||
|
3 changes: 3 additions & 0 deletions
3
packages/Mist.package/X64DisassemblerDisp32Operand.class/instance/initialize.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
initialize-release | |||
initialize | |||
bytesSoFar := displacementValue := 0 |
6 changes: 6 additions & 0 deletions
6
packages/Mist.package/X64DisassemblerDisp32Operand.class/instance/printOn..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
printing | |||
printOn: stream | |||
| targetAddress | | |||
targetAddress := instruction nextInstructionAddress + displacementValue. | |||
stream nextPutAll: '0x'. | |||
targetAddress printOn: stream base: 16 |
9 changes: 9 additions & 0 deletions
9
packages/Mist.package/X64DisassemblerDisp32Operand.class/methodProperties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
{ | |||
"class" : { | |||
}, | |||
"instance" : { | |||
"dispByte:" : "MartinMcClure 9/29/2012 10:52", | |||
"informDisplacement" : "MartinMcClure 9/29/2012 10:57", | |||
"informModRM" : "MartinMcClure 9/29/2012 10:48", | |||
"initialize" : "MartinMcClure 9/29/2012 10:35", | |||
"printOn:" : "MartinMcClure 9/29/2012 10:44" } } |
15 changes: 15 additions & 0 deletions
15
packages/Mist.package/X64DisassemblerDisp32Operand.class/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,15 @@ | |||
{ | |||
"category" : "Mist", | |||
"classinstvars" : [ | |||
], | |||
"classvars" : [ | |||
], | |||
"commentStamp" : "MartinMcClure 9/29/2012 10:34", | |||
"instvars" : [ | |||
"bytesSoFar", | |||
"displacementValue" ], | |||
"name" : "X64DisassemblerDisp32Operand", | |||
"pools" : [ | |||
], | |||
"super" : "X64DisassemblerOperand", | |||
"type" : "normal" } |
6 changes: 6 additions & 0 deletions
6
packages/Mist.package/X64DisassemblerInstruction.class/instance/Jz.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
address modes sent by perform: | |||
Jz | |||
"Op mode Jz, RIP-relative 32-bit displacement. | |||
Mist doesn't use the 16-bit version of Jz, so we only deal with the 32-bit one here." | |||
|
|||
operands add: (X64DisassemblerDisp32Operand forInstruction: self) |
6 changes: 6 additions & 0 deletions
6
packages/Mist.package/X64DisassemblerInstruction.class/instance/nextInstructionAddress.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
accessing | |||
nextInstructionAddress | |||
"Warning: This message will not give the correct answer until all bytes for the instruction have been processed. | |||
It is intended to be used during the instruction printing phase." | |||
|
|||
^ startAddress + bytes size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/Mist.package/X64DisassemblerOperand.class/instance/informDisplacement.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
private | |||
informDisplacement | |||
"If I am a pure displacement operand, let my instruction know how many displacement bytes to expect. | |||
Default is to not be an displacement operand, overridden in displacement subclass, so do nothing here." |
3 changes: 2 additions & 1 deletion
3
packages/Mist.package/X64DisassemblerOperand.class/methodProperties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.