1,079
edits
m (Linkify reference to section) |
m (Fix asm syntax highlighting) |
||
Line 56: | Line 56: | ||
Certain instructions (in particular, branching ones) take relative addresses as a parameter. The actual address is calculated based on the instruction after the branching instruction itself. In this example, the <tt>bnt</tt> instruction, if the branch is made, jumps over the <tt>ldi</tt> instruction. | Certain instructions (in particular, branching ones) take relative addresses as a parameter. The actual address is calculated based on the instruction after the branching instruction itself. In this example, the <tt>bnt</tt> instruction, if the branch is made, jumps over the <tt>ldi</tt> instruction. | ||
<syntax type=" | <syntax type="asm"> | ||
eq? | eq? | ||
bnt +2 | bnt +2 | ||
Line 71: | Line 71: | ||
In every call instruction, a value is included which determines the size of the parameter list, as an offset into the stack. This value discounts the list size pushed by the SCI code. For instance, consider this example from real SCI code: | In every call instruction, a value is included which determines the size of the parameter list, as an offset into the stack. This value discounts the list size pushed by the SCI code. For instance, consider this example from real SCI code: | ||
<syntax type=" | <syntax type="asm"> | ||
pushi 3 ; three parameters passed | pushi 3 ; three parameters passed | ||
pushi 4 ; the screen flag | pushi 4 ; the screen flag | ||
Line 431: | Line 431: | ||
:Send looks up the supplied selector(s) in the object pointed to by the accumulator. If the selector is a variable selector, it is read (to the accumulator) if it was sent for with zero parameters. If a parameter was supplied, this selector is set to that parameter. Method selectors are called with the specified parameters. | :Send looks up the supplied selector(s) in the object pointed to by the accumulator. If the selector is a variable selector, it is read (to the accumulator) if it was sent for with zero parameters. If a parameter was supplied, this selector is set to that parameter. Method selectors are called with the specified parameters. | ||
:The selector(s) and parameters are retreived from the stack frame. Send first looks up the selector ID at the bottom of the frame, then retreives the number of parameters, and, eventually, the parameters themselves. This algorithm is iterated until all of the stack frame has been "used up". Example: | :The selector(s) and parameters are retreived from the stack frame. Send first looks up the selector ID at the bottom of the frame, then retreives the number of parameters, and, eventually, the parameters themselves. This algorithm is iterated until all of the stack frame has been "used up". Example: | ||
<syntax type=" | <syntax type="asm"> | ||
; This is an example for usage of the SCI send operation | ; This is an example for usage of the SCI send operation | ||
pushi x ; push the selector ID of x | pushi x ; push the selector ID of x |
edits