Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Data General Nova
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Assembly language examples== ===Hello world program=== This is a minimal programming example in Nova assembly language. It is designed to run under [[Data General RDOS|RDOS]] and prints the string β[[Hello world program|Hello, world.]]β on the console. <syntaxhighlight lang="nasm"> ; a "hello, world" program for Nova running RDOS ; uses PCHAR system call .titl hello .nrel .ent start start: dochar: lda 0,@pmsg ; load ac0 with next character, mov# 0,0,snr ; test ac0; skip if nonzero (don't load result) jmp done .systm .pchar ; print first jmp er ; skipped if OK movs 0,0 ; swap bytes .systm .pchar ; print second jmp er ; skipped if OK isz pmsg ; point to next character jmp dochar ; go around again done: .systm ; normal exit .rtn er: .systm ; error exit .ertn halt pmsg: .+1 ; pointer to first character of string ; note bytes are packed right-to-left by default ; <15><12> denotes a CR LF pair. .txt /Hello, world.<15><12>/ 0 ; flag word to end string .end start </syntaxhighlight> ===16-bit multiplication=== Basic models of the Nova came without built-in hardware multiply and divide capability, to keep prices competitive. The following routine multiplies two 16-bit words to produce a 16-bit word result (overflow is ignored). It demonstrates combined use of ALU op, shift, and test (skip). Note that when this routine is called by <code>jsr</code>, AC3 holds the [[return address]]. This is used by the return instruction <code>jmp 0,3</code>. An idiomatic way to clear an accumulator is <code>sub 0,0</code>. Other single instructions can be arranged to load a specific set of useful constants (e.g. -2, -1, or +1). <syntaxhighlight lang="nasm"> mpy: ; multiply AC0 <- AC1 * AC2, by Toby Thain sub 0,0 ; clear result mbit: movzr 1,1,szc ; shift multiplier, test lsb add 2,0 ; 1: add multiplicand movzl 2,2,szr ; shift and test for zero jmp mbit ; not zero, do another bit jmp 0,3 ; return </syntaxhighlight> ===Binary print accumulator=== The following routine prints the value of AC1 as a 16-digit [[binary number]], on the RDOS console. It reveals further quirks of the Nova instruction set. For instance, there is no instruction to load an arbitrary "immediate" value into an accumulator (although memory reference instructions do encode such a value to form an effective address). Accumulators must generally be loaded from initialized memory locations (e.g. <code>n16</code>). Other contemporary machines such as the [[PDP-11]], and practically all modern architectures, allow for immediate loads, although many such as [[ARM architecture family|ARM]] restrict the range of values that can be loaded immediately. Because the RDOS <code>.systm</code> call macro implements a <code>jsr</code>, AC3 is overwritten by the return address for the <code>.pchar</code> function. Therefore, a temporary location is needed to preserve the return address of the caller of this function. For a recursive or otherwise re-entrant routine, a stack, hardware if available, software if not, must be used instead. The return instruction becomes <code>jmp @ retrn</code> which exploits the Nova's indirect addressing mode to load the return PC. The constant definitions at the end show two assembler features: the assembler radix is [[octal]] by default (<code>20</code> = sixteen), and character constants could be encoded as e.g. <code>"0</code>. <syntaxhighlight lang="nasm"> pbin: ; print AC1 on console as 16 binary digits, by Toby Thain sta 3,retrn ; save return addr lda 2,n16 ; set up bit counter loop: lda 0,chr0 ; load ASCII '0' movzl 1,1,szc ; get next bit in carry inc 0,0 ; bump to '1' .systm .pchar ; AC0-2 preserved jmp err ; if error inc 2,2,szr ; bump counter jmp loop ; loop again if not zero lda 0,spc ; output a space .systm .pchar jmp err ; if error jmp @retrn spc: " ;that's a space chr0: "0 n16: -20 retrn: 0 </syntaxhighlight>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Data General Nova
(section)
Add topic