Blue v7 Legend
word: compile call jmp execute call jmp addr label asmtime runtime
num: write 00 push 00
postpone: call jmp call jmp label asmtime runtime 00 00
example/x86_64/true2.bl
shadow
This version of `/bin/true` is more illustrative of a typical Blue program.
It is formed from several blocks which start a progression of using green
numbers to jit machine code, then using those words to build other higher
level words, which are often used as macros or run at `asmtime`.
By the time we get to `true2.bo`, which is the application specific file, the
blue `bye` executes at `asmtime` and results in the assembly of:
xor edi, edi
mov eax, 60
syscall
The `fin.bo` from the elf lib takes the size from the start of the output to
the end, and writes that into the `elfbsz` and `elfmsz` fields. In this case
the magenta word pushes the `asmtime` address of the word, which allows it to
be set like a variable.
Blocks:
- lib/blue/x86_64/basis.bo
- lib/blue/x86_64/enc.bo
- lib/blue/x86_64/regs.bo
- lib/blue/x86_64/kernel.bo
- lib/blue/x86_64/linux.bo
- lib/elf/hdr.bo
- example/x86_64/true2.bo
- lib/elf/fin.bo
lib/blue/x86_64/basis.bo
shadow
`basis` defines the words needed to begin encoding x86_64 machine code. After
this file we escape the need to hand jit words with only green numbers.
The machine code here is tightly coupled to the registers used by Blue v7.
; C3 C3 >ds 49 0089 08C08349 ; ds>2 08E88349 49 088B ds> 08E88349 49 008B ;
| ds>2 48 C809 >ds << ds>2 48 E0D3 >ds ,1 ds> AA ;
[top]
lib/blue/x86_64/enc.bo
rex.w 48 ; rex.wb 49 ; rex.rw 4C ;
/0 C0 | /r 03 << |
/0, /0 ,1 /r, /r ,1 /r0, /r /0 ,1
inc FF /0, sub 29 /r0, xor 31 /r0,
mov 89 /r0, mov# B8 | ,1 []mov 89 /r,
syscall 050F ;
[top]
lib/blue/x86_64/regs.bo
a eax 00 ; b rcx 01 ; rdx 02 ; dstb r12 04 ; rsi 06 ; dst edi 07 ;
[top]
lib/blue/x86_64/kernel.bo
- ds>2 rex.w a b sub >ds
! ds>2 rex.w b a []mov >ds
dup ds> >ds >ds
$ rex.w a dst mov >ds
$^ rex.rw a dstb mov >ds $^! rex.wb dstb dst mov ;
[top]
lib/blue/x86_64/linux.bo
bye edi dup xor exit eax mov# 0000003C syscall ;
write edi dup dup xor inc rex.w rdx rsi sub eax edi mov syscall ;
[top]
lib/elf/hdr.bo
elfhdrs $^!
03010102464C457F 0000000000000000
00000001003E0002 entry 0000000000400078
0000000000000040 0000000000000000
0038004000000000 0000000000400001
0000000700000001 0000000000000000
0000000000400000 0000000000400000
elfbsz 0000000000000000 elfmsz 0000000000000000
0000000000001000
[top]
example/x86_64/true2.bo
bye
[top]
lib/elf/fin.bo
$ $^ - dup elfbsz ! elfmsz !
[top]