[gambit-list] How access arbitrary memory addresses (r/w)?

Bradley Lucier lucier at math.purdue.edu
Thu Aug 9 20:17:42 EDT 2012


I don't know what you want to do, but this code:

(declare (standard-bindings)
	
(extended-bindings)
	
(not interrupts-enabled)
	
(not safe))

(define (u8transfer in out)
  (do ((i (fx- (u8vector-length in) 1)  (fx- i 1)))
      ((fx< i 0))
    (u8vector-set! out i (u8vector-ref in i))))

expands to

[Bradley-Luciers-MacBook-Pro:~/Downloads] lucier% gsc -cc-options "-save-temps" -keep-c -expansion fxtest.scm
Expansion:

(define u8transfer
  (lambda (in out)
    (letrec ((do-temp.0
              (lambda (in out i)
                (if ('#<procedure #2 ##fx<> i 0)
                    #!void
                    (let ((begin-temp.1 ('#<procedure #3 ##u8vector-set!> out i ('#<procedure #4 ##u8vector-ref> in i))))
                      (do-temp.0 in out ('#<procedure #5 ##fx-> i 1)))))))
      (let ((i ('#<procedure #5 ##fx-> ('#<procedure #6 ##u8vector-length> in) 1)))
        (if ('#<procedure #2 ##fx<> i 0)
            #!void
            (let ((begin-temp.1 ('#<procedure #3 ##u8vector-set!> out i ('#<procedure #4 ##u8vector-ref> in i))))
              (do-temp.0 in out ('#<procedure #5 ##fx-> i 1))))))))

and the inner loop is

L14:
        movq    %rdx, %rax
        sarq    $2, %rax
        subq    $4, %rdx
        movzbl  7(%rsi,%rax), %ecx
        leaq    0(,%rcx,4), %r8
        movb    %cl, 7(%r9,%rax)
        jns     L14

which seems to have about 1 extra instruction (I don't know what the load effective address is doing there).

Brad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20120809/9be9e7a4/attachment.htm>


More information about the Gambit-list mailing list