RFC regarding WAM

Posted by Noctis Skytower on Stack Overflow See other posts from Stack Overflow or by Noctis Skytower
Published on 2010-05-24T03:12:14Z Indexed on 2010/05/24 3:21 UTC
Read the original article Hit count: 471

Request For Comment regarding Whitespace's Assembly Mnemonics


What follows in a first generation attempt at creating mnemonics for a whitespace assembly language.

STACK
=====
  push number
  copy
  copy number
  swap
  away
  away number

MATH
====
  add
  sub
  mul
  div
  mod

HEAP
====
  set
  get

FLOW
====
  part label
  call label
  goto label
  zero label
  less label
  back
  exit

I/O
===
  ochr
  oint
  ichr
  iint

In the interest of making improvements to this small and simple instruction set, this is a second attempt.

hold N       Push the number onto the stack        
copy         Duplicate the top item on the stack        
copy N       Copy the nth item on the stack (given by the argument) onto the top of the stack        
swap         Swap the top two items on the stack        
drop         Discard the top item on the stack        
drop N       Slide n items off the stack, keeping the top item        

add          Addition        
sub          Subtraction        
mul          Multiplication        
div          Integer Division        
mod          Modulo        

save         Store        
load         Retrieve        

L:           Mark a location in the program        
call L       Call a subroutine        
goto L       Jump unconditionally to a label        
if=0 L       Jump to a label if the top of the stack is zero        
if<0 L       Jump to a label if the top of the stack is negative        
return       End a subroutine and transfer control back to the caller        
exit         End the program        

print chr    Output the character at the top of the stack        
print int    Output the number at the top of the stack        
input chr    Read a character and place it in the location given by the top of the stack        
input int    Read a number and place it in the location given by the top of the stack        

What do you think of the following revised list for Whitespace's assembly instructions? I'm still thinking outside of the box somewhat and trying to come up with a better mnemonic set than last time. When the previous interpreter was written, it was completed over two contiguous, rushed evenings.

This rewrite deserves significantly more time now that it is the summer. Of course, the next version of Whitespace (0.4) may have its instructions revised even more, but this is just a redesign of what originally was done in a very short amount of time.

Hopefully, the instructions make more sense once someone new to programmings thinks about them.

© Stack Overflow or respective owner

Related posts about python

Related posts about assembly