diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-05-24 19:31:20 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-05-24 19:31:20 -0700 |
| commit | db39fec4b6acdef6e9e03a69d2727a2ae4bcb5ba (patch) | |
| tree | f92fd135838e1c3c4cabbd59bdb713726614c1ba /amd64.e | |
| parent | fa77a37199208fa207202e62f409e1371c5f03f3 (diff) | |
added a program, hex.e, which will be the bootstrap strategy
also added some instructions it needed Force-Push: yes Change-Id: Ia35280e2696167eb0662a5c3a9dc47840438da56
Diffstat (limited to 'amd64.e')
| -rw-r--r-- | amd64.e | 66 |
1 files changed, 59 insertions, 7 deletions
diff --git a/amd64.e b/amd64.e index 4b4a2bd..2060a3d 100644 --- a/amd64.e +++ b/amd64.e @@ -762,7 +762,9 @@ s" :cc-greater" keyword 3roll rex-w 0x03 pack8 3unroll reg64 swap addressing-indirect-reg64 ; -~ (output point, source register, target register -- output point) +~ TODO needs description of argument order considerations +~ +~ (output point, immediate value, target register -- output point) : add-reg64-imm8 3roll rex-w 0x83 pack8 swap 0 swap addressing-reg64 swap pack8 ; @@ -777,7 +779,10 @@ s" :cc-greater" keyword 3roll rex-w 0x2B pack8 3unroll swap reg64 swap addressing-indirect-reg64 ; -~ (output point, source register, target register -- output point) +~ TODO this convention is unlike other arithmetic operations. See the note +~ on cmp-reg64-imm8, pick one to go with, and document it. +~ +~ (output point, immediate value, target register -- output point) : sub-reg64-imm8 3roll rex-w 0x83 pack8 swap 5 swap addressing-reg64 swap pack8 ; @@ -853,6 +858,30 @@ s" :cc-greater" keyword swap rex-w 0xF7 pack8 swap 2 swap addressing-reg64 ; +~ (output point, bit count, target register -- output point) +: rol-reg64-imm8 + 3roll rex-w 0xC1 pack8 swap + 0 swap addressing-reg64 + swap pack8 ; + +~ (output point, bit count, target register -- output point) +: rol-reg8-imm8 + 3roll 0xC0 pack8 swap + 0 swap addressing-reg8 + swap pack8 ; + +~ (output point, bit count, target register -- output point) +: ror-reg64-imm8 + 3roll rex-w 0xC1 swap + 1 swap addressing-reg64 + swap pack8 ; + +~ (output point, bit count, target register -- output point) +: ror-reg8-imm8 + 3roll 0xC0 pack8 swap + 1 swap addressing-reg64 + swap pack8 ; + ~ Control flow instructions ~ ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -865,13 +894,22 @@ s" :cc-greater" keyword 3roll rex-w 0x3B pack8 3unroll reg64 swap addressing-reg64 ; -~ (output point, left register, right value -- output point) +~ The parameter order here is weird, so take note. In a comparison between +~ a register and an immediate value, it makes sense to think of the register +~ as the target... but instead we opt to be consistent with the other cmp +~ instructions, which in turn are consistent with the sub instructions, in +~ which we put the left operand first because subtraction is not commutative. +~ TODO wrong, backwards, other choice +~ +~ TODO the immediate arithmetic instructions are all documented wrong +~ +~ (output point, immediate value, target register -- output point) : cmp-reg64-imm8 3roll rex-w 0x83 pack8 - ~ (left register, right value, output point) - 3roll 7 swap addressing-reg64 - ~ ( output point, right value) - pack8 ; + ~ (immediate value, register, output point) + swap 7 swap addressing-reg64 + ~ ( output point, immediate value) + swap pack8 ; ~ Pretend to bitwise-and left with right, and set the flags the same way as ~ if we actually had. @@ -917,3 +955,17 @@ s" :cc-greater" keyword swap 0xE9 pack8 swap pack32 ; +~ TODO This is technically a "near" call; the name doesn't capture that. +~ Should it? +~ +~ (output point, address offset value -- output point) +: call-rel-imm32 + swap 0xE8 pack8 + swap pack32 ; + +~ TODO This is a "near" return. +~ +~ (output point) +: ret + 0xC3 pack8 ; + |