<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.intellivision.us/index.php?action=history&amp;feed=atom&amp;title=Calling_Conventions</id>
		<title>Calling Conventions - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.intellivision.us/index.php?action=history&amp;feed=atom&amp;title=Calling_Conventions"/>
		<link rel="alternate" type="text/html" href="http://wiki.intellivision.us/index.php?title=Calling_Conventions&amp;action=history"/>
		<updated>2026-05-14T17:30:21Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://wiki.intellivision.us/index.php?title=Calling_Conventions&amp;diff=14770&amp;oldid=prev</id>
		<title>Mr z: Protected &quot;Calling Conventions&quot; ([edit=autoconfirmed] (indefinite) [move=autoconfirmed] (indefinite))</title>
		<link rel="alternate" type="text/html" href="http://wiki.intellivision.us/index.php?title=Calling_Conventions&amp;diff=14770&amp;oldid=prev"/>
				<updated>2010-12-04T08:11:15Z</updated>
		
		<summary type="html">&lt;p&gt;Protected &amp;quot;&lt;a href=&quot;/index.php/Calling_Conventions&quot; title=&quot;Calling Conventions&quot;&gt;Calling Conventions&lt;/a&gt;&amp;quot; ([edit=autoconfirmed] (indefinite) [move=autoconfirmed] (indefinite))&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 08:11, 4 December 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Mr z</name></author>	</entry>

	<entry>
		<id>http://wiki.intellivision.us/index.php?title=Calling_Conventions&amp;diff=1479&amp;oldid=prev</id>
		<title>Mr z at 16:28, 18 January 2005</title>
		<link rel="alternate" type="text/html" href="http://wiki.intellivision.us/index.php?title=Calling_Conventions&amp;diff=1479&amp;oldid=prev"/>
				<updated>2005-01-18T16:28:16Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Programming]]&lt;br /&gt;
&lt;br /&gt;
The Intellivision's [[Executive ROM]] adopted a set of coding conventions that make it easy for software written by different people to interoperate.&lt;br /&gt;
&lt;br /&gt;
The most important convention is the method by which one function invokes another.  Most of the Mattel game software seems to follow the convention below, at least approximately.  SDK-1600 and other contemporary software uses similar conventions.&lt;br /&gt;
&lt;br /&gt;
* Return address is in R5.  This is so common that AS1600 provides these aliases:&lt;br /&gt;
** &amp;quot;CALL&amp;quot; for &amp;quot;JSR R5&amp;quot;&lt;br /&gt;
** &amp;quot;BEGIN&amp;quot; for &amp;quot;MVO@ R5, R6&amp;quot;. &lt;br /&gt;
** &amp;quot;RETURN&amp;quot; for &amp;quot;MVI@ R6, R7&amp;quot;.&lt;br /&gt;
* Non-pointer arguments typically in R0, R1, with results in R2.  (Or, it's sometimes rotated:  inputs in R1, R2, output in R0.)&lt;br /&gt;
* Pointer arguments (especially arrays) start with R4&lt;br /&gt;
* Fixed data blocks sometimes appear immediately after a JSR instruction&lt;br /&gt;
&lt;br /&gt;
The last bullet is probably the most subtle one.  The [[Jump|JSR]] instruction puts its return address in one of R4, R5, or R6.  R4 and R5 are auto-incrementing pointer registers when used with [[Indirect Mode]] accesses.  So, a common idiom developed in the Intellivision world:  If a given function takes a fixed block of data, that block of data can be placed immediately after the JSR instruction.  The function would then read the data, leaving R5 pointing just after the data block.  When it's done, it can then return just after the data.&lt;br /&gt;
&lt;br /&gt;
Games commonly use this technique to draw text on the screen.  [[Executive ROM|EXEC]] based games apparently also use this technique to play songs.  &lt;br /&gt;
&lt;br /&gt;
The example below shows a simple &amp;quot;PRINT&amp;quot; function that prints a string to the display, followed by code which invokes it.  The example isn't optimized.&lt;br /&gt;
&lt;br /&gt;
 PRINT:    ; prints the NUL terminated string after the JSR instruction&lt;br /&gt;
           ; Expects address to display at in first word&lt;br /&gt;
           ; Expects &amp;quot;format word&amp;quot; in next word (this gets ADDed to each character to set colors, etc.)&lt;br /&gt;
           ; Expects string in subsequent words&amp;lt;br/&amp;gt;&lt;br /&gt;
           MVI@    R5, R4    ; get address to display at&lt;br /&gt;
           MVI@    R5, R3    ; get &amp;quot;format word&amp;quot;&lt;br /&gt;
           SUBI    #$20, R3  ; ASCII adjust the format word&amp;lt;br/&amp;gt;&lt;br /&gt;
 loop:     MVI@    R5, R0    ; get a character&lt;br /&gt;
           SLL     R0, 2     ; shift card # into position&lt;br /&gt;
           SLL     R0, 1     ; (See [[STIC]] for information on card format)&lt;br /&gt;
           BEQ     done      ; if character was a NUL, leave.&lt;br /&gt;
           ADDR    R3, R0    ; add in format word.  This adjusts for ASCII to card# offset and sets color.&lt;br /&gt;
           MVO@    R0, R4    ; write it to the screen&lt;br /&gt;
           B       loop      ;&amp;lt;br/&amp;gt;&lt;br /&gt;
 done:     JR      R5        ; return just after the string&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
 EXAMPLE:  JSR     R5, PRINT &lt;br /&gt;
           DECLE   $0200     ; upper left hand corner&lt;br /&gt;
           DECLE   $0007     ; White&lt;br /&gt;
           STRING  &amp;quot;Hello World!&amp;quot;, 0  ; String to print&lt;br /&gt;
           ; the PRINT function returns here.&lt;/div&gt;</summary>
		<author><name>Mr z</name></author>	</entry>

	</feed>