-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assembly syntax for writing programs #13
Comments
Proposal (inspired by MIPS syntax): (Permissions
Syntax for comments: Example without labels ("buffer example"): ; code
mov r1 pc
lea r1 4
subseg r1 4 7
jmp r0
; data
.word 0xA, 0xB, 0
.word 42 Example with labels ("secure counter"): ; initially, PC = (RWX, init, end, init)
; r0 = (unknown) pointer to the context
init:
mov r1 pc ; r1 = (RWX, init, end, init)
lea r1 (data-init) ; r1 = (RWX, init, end, data)
mov r2 r1 ; r2 = (RWX, init, end, data)
lea r2 1 ; r2 = (RWX, init, end, data+1)
store r1 r2 ; mem[data] <- (RWX, init, end, data+1)
lea r1 (code-data) ; r1 = (RWX, init, end, code)
subseg r1 code end ; r1 = (RWX, code, end, code)
restrict r1 E ; r1 = (E, code, end, code)
mov r2 0 ; r2 = 0
jmp r0 ; jump to unknown code: we only give it access
; to an enter capability pointing to ’code’
; when ’code’ gets executed from the E capability,
; PC = (RX, code, end, code)
; r0 = (unknown) return pointer to the continuation
code:
mov r1 PC ; r1 = (RX, code, end, code)
lea r1 (data-code) ; r1 = (RX, code, end, data)
load r1 r1 ; r1 = (RWX, init, end, data+1)
load r2 r1 ; r2 = <counter value>
add r2 r2 1 ; r2 = <counter value> + 1
store r1 r2 ; mem[data+1] <- <counter value> + 1
mov r1 0 ; r1 = 0
jmp r0 ; return to unknown code
data:
.word 0xFFFF ; will be overwritten with (RWX, init, end, data+1), i.e.
; a read-write capability to the counter value
.word 0 ; our private data: the current value of the counter
end: |
Right now we are using Coq as a very weak assembler, and we have no convenient way of e.g. computing labels or offsets.
Links for inspiration (to expand):
The text was updated successfully, but these errors were encountered: