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 

x86_64/Linux/cmd/ser/ser.bl

shadow
Serializes Blue bytecode into a simple human readable format.

When Blue bytecode in the main repo is modified, it is serialized twice. Once
via `xxd` and once with `ser`. Since Blue is written in Blue, the `.xxd` files
allow for the `stage0` compiler and bytecode to be deserialized. Then Blue
builds itself. That way you don't have to already have Blue to work on Blue.

The `.ser` files are used as a more human readable way to commit the bytecode
files. Even though they are not wonderful to look at, it does let you see what
changes are being submitted in a given commit. Currently there is no `de`,
that is what `xxd` is used for.

In the main Blue repo, `ser` is run when you build. Deserialization however is
a separate manual step that has to be done using `make de`. This is to prevent
data loss.

The serialization format is prefix based. For chars 0x00 - 0x7F the prefix is
a `.` then the char value. For colors the prefix is the tag byte in hex format
followed by the the number or word and a space.

Blocks:

  1. x86_64/lib/blue/basis.bo
  2. x86_64/lib/blue/enc.bo
  3. lib/blue/defs.bo
  4. x86_64/lib/blue/defs.bo
  5. x86_64/Linux/lib/defs.bo
  6. x86_64/lib/blue/kernel.bo
  7. x86_64/lib/blue/dst.bo
  8. x86_64/lib/blue/init.bo
  9. x86_64/lib/blue/cf.bo
  10. x86_64/lib/blue/ease.bo
  11. x86_64/Linux/lib/sys.bo
  12. lib/blue/res.bo
  13. x86_64/lib/elf/hdr.bo
  14. lib/blue/magic.bo
  15. x86_64/lib/blue/basis.bo
  16. x86_64/lib/blue/kernel.bo
  17. x86_64/lib/blue/dst.bo
  18. x86_64/Linux/cmd/reds/kernel.bo
  19. x86_64/lib/bc/num.bo
  20. x86_64/lib/bc/word.bo
  21. x86_64/Linux/cmd/ser/ops.bo
  22. lib/blue/opa.bo
  23. lib/blue/vars.bo
  24. x86_64/Linux/cmd/ser/entry.bo
  25. lib/blue/fin.bo
  26. lib/elf/fin.res.bo

x86_64/lib/blue/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]

x86_64/lib/blue/enc.bo

rex.b 41 ; rex.w 48 ; rex.wb 49 ; rex.rw 4C ; 
/0 C0 | /r 03 << | 
/0, /0 ,1 /r, /r ,1 /r0, /r /0 ,1 

add 01 /r0, sub 29 /r0, xor 31 /r0, 
mov 89 /r0, mov# B8 | ,1 []mov 89 /r, []mov1 88 /r, 
push 50 | ,1 pop 58 | ,1 
stosq rex.w stosd AB ; stosw AB66 ; stosb AA ; 
syscall 050F ; axchg 90 | ,1 
[top]

lib/blue/defs.bo

dsz 1000 ; dstsz srcsz 2000 ; 
[top]

x86_64/lib/blue/defs.bo

a ds  rax/r8 00 ; b  rcx 01 ; c srce  rdx/r10 02 ; last  rbx 03 ; 
dstb  r12 04 ; ops  r13 05 ; src  rsi 06 ; dst  rdi 07 ; 
[top]

x86_64/Linux/lib/defs.bo

org 00400000 ; stdin 00 ; stdout 01 ; 
sys# a sys1 dst sys2 src sys3 c 
[top]

x86_64/lib/blue/kernel.bo

dup ds> >ds >ds swap ds>2 rex.w b axchg 2>ds >ds rex.w a b mov >ds 

+ ds>2 rex.w a b add >ds - ds>2 rex.w a b sub >ds 
, ds> stosq ; ,4 ds> stosd ; ,2 ds> stosw ; 
! ds>2 rex.w b a []mov ; !4 ds>2 b a []mov ; !1 ds>2 rex.w b a []mov1 ; 
[top]

x86_64/lib/blue/dst.bo

$ rex.w a dst mov >ds $^ rex.rw a dstb mov >ds 
$* $ ~ $^ - 00400000 + $^! rex.wb dstb dst mov ; 
[top]

x86_64/lib/blue/init.bo

ds! rex.b ds mov# ,4 dst! 8B 253C ,4 dstb! rex.wb dstb swap mov 
last! 8B 251C ,4 ops! rex.b ops mov# ,4 
srce! rex.wb srce swap mov 
[top]

x86_64/lib/blue/cf.bo

_1 $ stosb then dup $ swap - 01 - swap !1 
char? 80A8 75 _1 flag? 7410C1F6 _1 pp? 7408C1F6 _1 
srce? rex.rw D639 7C _1 
[top]

x86_64/lib/blue/ease.bo

callop 41 00D554FF ; =0 dup xor 
src>a AD48 ; src1>a a =0 AC ; 
[top]

x86_64/Linux/lib/sys.bo

bye a =0 exit sys1 a mov sys# mov# 0000003C syscall 
read sys1 mov# ,4 8B 2534 ,4 sys3 mov# ,4 sys# =0 syscall 
write sys1 mov# ,4 ds> sys2 a mov ds> sys3 a mov sys# mov# 00000001 syscall 
[top]

lib/blue/res.bo

resmsz dsz dstsz + srcsz + 
[top]

x86_64/lib/elf/hdr.bo

elfhdrs $^! 
	03010102464C457F 	0000000000000000 
	00000001003E0002 entry 	0000000000400078 
	0000000000000040 	0000000000000000 
	0038004000000000 	0000000000400001 
	0000000700000001 	0000000000000000 
	0000000000400000 	0000000000400000 
elfbsz 	0000000000000000 elfmsz 0000000000000000 
	0000000000001000 
[top]

lib/blue/magic.bo

0000000765756C62 
[top]

x86_64/lib/blue/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]

x86_64/lib/blue/kernel.bo

dup ds> >ds >ds swap ds>2 rex.w b axchg 2>ds >ds rex.w a b mov >ds 

+ ds>2 rex.w a b add >ds - ds>2 rex.w a b sub >ds 
, ds> stosq ; ,4 ds> stosd ; ,2 ds> stosw ; 
! ds>2 rex.w b a []mov ; !4 ds>2 b a []mov ; !1 ds>2 rex.w b a []mov1 ; 
[top]

x86_64/lib/blue/dst.bo

$ rex.w a dst mov >ds $^ rex.rw a dstb mov >ds 
$* $ ~ $^ - 00400000 + $^! rex.wb dstb dst mov ; 
[top]

x86_64/Linux/cmd/reds/kernel.bo

++ ds> rex.w C0FF >ds -- ds> rex.w C8FF >ds 
& ds>2 rex.w C821 >ds >> ds>2 rex.w E8D3 >ds 
rol ds>2 rex.w C0D3 >ds ror ds>2 rex.w C8D3 >ds 
hexl? 093C 7E _1 
0? C084 75 _1 
ds>3 ds> rex.w C289 ds>2 
[top]

x86_64/lib/bc/num.bo

num  bytes 70 & 04 >> ++  nibs 01 << 
rorb dup ds> a push 02 << ror a pop >ds 
nib swap 04 rol dup 0F & hexl? 07 + then 
30 + ,1 swap -- 0? ds>2 then nib 
[top]

x86_64/lib/bc/word.bo

word 0? ; then >ds dup ,1 08 >> ds> word 
[top]

x86_64/Linux/cmd/ser/ops.bo

gw bw rw mw word bn pp? >ds then gn 2>ds num 
[top]

lib/blue/opa.bo

opa gw , bw , rw , mw , gn , bn , 
[top]

lib/blue/vars.bo

_dict 00000000 _dst 00000000 _src 00000000 
[top]

x86_64/Linux/cmd/ser/entry.bo

$* entry ! 
init srcsz _src stdin read a dup src add srce! 
_dst dst! dst dstb! _dict last! org ds! opa ops! 

next srce? 
	$ $^ - $^ stdout write bye 
then src1>a 
char? >ds 08 << 2E | ,2 next then 
>ds dup 00 num 
dup dup F7 & swap 07 & ds>3 
src>a callop 20 ,1 next 
[top]

lib/blue/fin.bo

$* dup _dict !4 dsz + dup _dst !4 dstsz + _src !4 
[top]

lib/elf/fin.res.bo

$ $^ - dup elfbsz ! resmsz + elfmsz ! 
[top]

Blue, v7