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/reds/reds.bl
shadow
Counts the number of red words in the specified bytecode. Postponed red words
are not counted since they may be result in zero or more dictionary entries.
Besides being a useful tool to keep an eye on dictionary usage, `reds` is also
used as a testing ground for utilizing a "higher level" Blue. This includes
things such as how words are composed and using Blue at runtime as well as
asmtime. More often than not these ideas are tested in `reds` and once proven
are ported back to Blue.
Blocks:
- x86_64/lib/blue/basis.bo
- x86_64/lib/blue/enc.bo
- lib/blue/defs.bo
- x86_64/lib/blue/defs.bo
- x86_64/Linux/lib/defs.bo
- x86_64/lib/blue/kernel.bo
- x86_64/lib/blue/dst.bo
- x86_64/lib/blue/init.bo
- x86_64/lib/blue/cf.bo
- x86_64/lib/blue/ease.bo
- x86_64/Linux/lib/sys.bo
- lib/blue/res.bo
- x86_64/lib/elf/hdr.bo
- lib/blue/magic.bo
- x86_64/lib/blue/basis.bo
- x86_64/lib/blue/kernel.bo
- x86_64/lib/blue/dst.bo
- x86_64/Linux/cmd/reds/kernel.bo
- x86_64/Linux/cmd/reds/ops.bo
- lib/blue/opa.bo
- x86_64/lib/bc/num.bo
- x86_64/Linux/cmd/reds/num.bo
- lib/blue/vars.bo
- x86_64/Linux/cmd/reds/entry.bo
- lib/blue/fin.bo
- 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/Linux/cmd/reds/ops.bo
bn pp? >ds then gw bw mw gn ; rw ++
[top]
lib/blue/opa.bo
opa gw , bw , rw , mw , gn , bn ,
[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/Linux/cmd/reds/num.bo
,num 94 num 0A ,1
[top]
lib/blue/vars.bo
_dict 00000000 _dst 00000000 _src 00000000
[top]
x86_64/Linux/cmd/reds/entry.bo
$* entry !
init srcsz _src stdin read a dup src add srce!
_dst dst! dst dstb! _dict last! org ds! opa ops!
00 next srce?
,num $ $^ - $^ stdout write bye
then
src1>a char? next then
>ds dup dup F7 & swap 07 & ds>3 src>a callop 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]