Skip to content

Instantly share code, notes, and snippets.

(with-open-file (stream "LOCAL:>Desktop.jpeg" :element-type '(unsigned-byte 8))
(sys.int::gc)
(mezzano.profiler:with-profiling (:path "profile.log" :thread t :buffer-size (* 1024 1024) :repeat 10)
(file-position stream 0)
(jpeg:decode-stream stream :cached-source-p t))
nil)
$ cat test.s
test:
ret
$ as test.s
$ objdump -d a.out
a.out: file format elf64-x86-64
Disassembly of section .text:
(defun read-bpb-structure (array)
(let ((bytspersec (ub16ref/le array 11))
(secperclus (aref array 13))
(numfats (aref array 16)))
(check-bytspersec bytspersec)
(check-secperclus secperclus bytspersec)
(assert (<= numfats 1))
(make-bpb :bs_jmpboot (logior (ash (aref array 2) 16)
(ash (aref array 1) 8)
(aref array 0)) ;; from byte 0 3bytes <--
(define-llvm-function |G_DoReborn| ((|playernum.0| ) :need-frame-pointer nil)
(let ((|%14| 0)
(|gep_array.15| 0)
(|gep.16| 0)
(|mo.17| 0)
(|%18| 0)
(|gep_int1.19| 0)
(|gep2.20| 0)
(|player.21| 0)
(|%22| 0)
void mymethod(T foo) {
if(numeric_limits<T>::is_signed) {
a();
} else {
b();
}
}
becomes something like:
(let ((home #p"LOCAL:>"))
;; Construct a pathname with the same host as the homedir
;; then merge together to produce the full path on the right host.
;; Without this, the resulting pathname will take on the host
;; of *default-pathname-defaults*, which may differ from homedir's host.
(merge-pathnames (make-pathname :host (pathname-host home)
:directory '(:relative "tmp"))
home))
;; reading
(let ((result (make-array (* sector-size n-sectors) :element-type '(unsigned-byte 8)))
(temp-buf (make-array sector-size :element-type '(unsigned-byte 8) :area :wired)))
(dotimes (i n-sectors)
(read-disk disk (+ start-sector i) 1 temp-buf)
(replace result temp-buf :start1 (* i sector-size)))
result)
;; writing
(let ((temp-buf (make-array sector-size :element-type '(unsigned-byte 8) :area :wired)))
Welcome to the VirtualBox Debugger!
Current VM is 6ace2000, CPU #0
VBoxDbg> rt
info: Verbose register info.
VBoxDbg> r
rax=000000000081cac0 rbx=0000000000000400 rcx=0000000000000000 rdx=0000000000000000
rsi=0000000038530bc0 rdi=0000000000000002 r8 =0000000000400009 r9 =000000000081caf9
r10=0000000000406799 r11=000000000199dc49 r12=0000000000400009 r13=000000000041c079
r14=0000000000000000 r15=0000000000000000 iopl=0 nv up ei pl nz na pe nc
rip=000000000041c00e rsp=000020000121ff70 rbp=000020000121ff70
$ cat test.s
b foo
b foo
b foo
b foo
foo:
b foo
b foo
b foo
b foo
;; Getting the input to perform-target-lap-generation:
(let ((fn (mezzano.compiler.backend.ast-convert:convert
(sys.c::compile-lambda-1 '(lambda ()))))
(target (sys.c::canonicalize-target :x86-64)))
(mezzano.compiler.backend::compile-backend-function-1 fn target)
(mezzano.compiler.backend.register-allocator::allocate-registers fn target)
(mezzano.compiler.backend::print-function fn))
;; =>
#<MEZZANO.COMPILER.BACKEND:BACKEND-FUNCTION {100F707853}>
(:ARGUMENT-SETUP #<MEZZANO.COMPILER.BACKEND:VIRTUAL-REGISTER :FREF :VALUE {100F707F93}> :RBX #<MEZZANO.COMPILER.BACKEND:VIRTUAL-REGISTER :COUNT :VALUE {100F707FF3}> NIL NIL NIL)