cmsc430 / cmsc430.github.io

CMSC 430 Design and Implementation of Programming Languages
https://cmsc430.github.io/
45 stars 33 forks source link

`prog` should check that entry label is `Global` #138

Closed dvanhorn closed 1 year ago

dvanhorn commented 1 year ago

asm-interp calls the first label in the given instructions, but if that label is not declared as Global you get a bad error message from the ffi:

#lang racket
(require a86)
(asm-interp
 (prog
  (Mov 'rax 3)
  (Call 'done)
  (Ret)
  (Label 'done)
  (Mov 'rax 0)
  (Ret)))
ffi-obj: could not find export from foreign library
name: done
library: /var/tmp/nasm16878285301687828530715.so
system error: /var/tmp/nasm16878285301687828530715.so: undefined symbol: done 

This is usually the result of forgetting to have an entry point.

The prog function should check that the first label is declared as Global and provide some guidance if not.