Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ jobs:
clang --version
gcc --version

- name: Cache Racket packages
uses: actions/cache@v4
with:
path: |
~/.racket
~/.cache/racket
~/.local/share/racket
~/Library/Caches/Racket
key: racket-${{ matrix.racket-variant }}-${{ matrix.racket-version }}-${{ matrix.os }}

- name: Install a86 package
run: |
raco pkg install --no-docs ../a86/
Expand Down
3 changes: 2 additions & 1 deletion a86/info.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
(define deps (list "base" "rackunit" "redex-lib" "redex-gui-lib"))
(define scribblings '(("scribblings/a86.scrbl")))
(define test-omit-paths '("scribblings/"
"test/expressions.rkt"))
"test/expressions.rkt"
"test/sections.rkt"))
(define pre-install-collection "check-x86.rkt")
33 changes: 14 additions & 19 deletions a86/printer.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
[asm-string (-> (listof instruction?) string?)] ; deprecated
[asm-display (-> (listof instruction?) any)])

(define current-os
(make-parameter (system-type 'os)))

(define current-shared?
(make-parameter #f))

(module* private #f
(provide current-shared?))
(provide current-shared?)
(provide current-os))

;; Asm -> String
(define (asm-string a)
Expand All @@ -26,29 +30,20 @@

;; Label -> String
;; prefix with _ for Mac
(define label-symbol->string
(match (system-type 'os)
(define (label-symbol->string s)
(match (current-os)
['macosx
(λ (s)
(string-append "_" (symbol->string s)))]
(string-append "\"_" (symbol->string s) "\"")]
[_
(λ (s)
(symbol->string s))]))
(string-append "\"" (symbol->string s) "\"")]))

;(if (and (current-shared?) (memq s (current-extern-labels)))
; hack for ELF64 shared libraries in service of
; calling external functions in asm-interp
;(string-append "$" (symbol->string s) " wrt ..plt")
;(symbol->string s)))]))

(define extern-label-decl-symbol->string
(match (system-type 'os)
['macosx
(λ (s)
(string-append "_" (symbol->string s)))]
[_
(λ (s)
(symbol->string s))]))
(define extern-label-decl-symbol->string label-symbol->string)

;; Instruction -> String
(define (common-instruction->string i)
Expand Down Expand Up @@ -187,12 +182,12 @@
(string-append "(" (exp->string e1) " " (symbol->string o) " " (exp->string e2) ")")]))

(define (text-section n)
(match (system-type 'os)
['macosx (format ".section __TEXT,~a\n\t.p2align 4" n)]
(match (current-os)
['macosx (format ".section __TEXT,~a" n)]
[_ (format ".section ~a,\"ax\",@progbits\n\t.p2align 4" n)]))

(define (data-section n)
(match (system-type 'os)
(match (current-os)
['macosx (format ".section __DATA,~a\n\t.p2align 3" n)]
[_ (format ".section ~a,\"aw\",@progbits\n\t.p2align 3" n)]))

Expand All @@ -207,7 +202,7 @@
[(Global ($ l)) (string-append tab ".global " (label-symbol->string l))]
[(Label ($ l)) (string-append (label-symbol->string l) ":")]
[(Align n)
(match (system-type 'os)
(match (current-os)
['macosx (string-append ".p2align "
(number->string
(let loop ([i 0] [n n])
Expand Down
Loading