Advertisement
Treyzania

RapidASM draft docs 2015-08-11@1657

Aug 11th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. RapidASM Scratch Documentation Draft
  2.  
  3. NOTES...
  4. Compiles into assembly, making C/C++ header files as necessary.
  5. Stack managed automagically, as would in C. SI, SP, and related registers are normally unaccessable.
  6. Instructions that have suffixes depending on data side have suffixed applied based on the context, but
  7. can be defined manually.
  8.  
  9. SUBROUTINE DECLARATIONS... !!! NEEDS WORK !!!
  10. sub<$name $cType> { /* $name impl */ }
  11. sub<$name($reg1=$arg1 /* etc. */) $cType> { /* $name impl */ }
  12. sub($conv)<$name $cType> { /* $name impl */ }
  13. sub($conv)<$name($reg1=$arg1 /* etc. */) $cType> { /* $name impl */ }
  14.  
  15. For $name is sub name, $cType is return type in the header, $conv, is the calling convention, $reg# is argument
  16. #'s register's name, and $arg# is the name of argument # in the header.
  17.  
  18. OPERATIONS...
  19. Set value of register: `eax = 42`, `eax = [42h]`
  20. Move register values: `eax -> ebx`, `ebx <- eax`, etc. (Adapts to size of reg.)
  21. Instruction: `:hlt`, `:HLT`, etc.
  22. Exchange registers: `eax <-> abx`
  23. Subroutine call: `~foo`
  24. Number literals: `10` (10), `10h` (16), `10o` (8), `10b` (2)
  25.  
  26. STRUCTURE...
  27. Comment:
  28. // yadda yadda yadda
  29. /* inline yadda */
  30. Subroutine example (using cdecl convention):
  31.  
  32. sub<foo(ax=bar bx=baz) int> {
  33. // foo impl
  34. }
  35. Generates .h as(?):
  36. int _cdecl foo(int bar, int baz);
  37.  
  38. sub(stdcall, etc.)<bar(r12=bob) boolean> {
  39. // bar impl
  40. }
  41. Generates .h as(?):
  42. boolean _stdcall bar(long bob)
  43.  
  44. Other file(s):
  45. include {
  46. <file1.?>
  47. <file2.?>
  48. <file3.?>
  49. ...
  50. }
  51.  
  52. Branching (if statements) example, for $exp is a boolean expression:
  53. if($exp) ~foo
  54. if($exp) rax -> rbx
  55.  
  56. Simple loops (checked at beginning), for $exp is a boolean expression:
  57. while($exp) {
  58. // looped content
  59. }
  60. May become...
  61. jnz ($exp result)
  62. // looped content
  63. jmp (jnz instruction)
  64.  
  65. Simple loops (checked at end), for $exp is a boolean expression:
  66. do {
  67. // looped content
  68. } while($exp)
  69. May become...
  70. // looped content
  71. jnz ($exp result), (beginning of content)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement