NAR 1
Encyclopedia
NAR 1 or just NAR was a theoretical model of a computer created by Faculty of Mathematics of University of Belgrade
University of Belgrade
The University of Belgrade is the oldest and largest university of Serbia.Founded in 1808 as the Belgrade Higher School in revolutionary Serbia, by 1838 it merged with the Kragujevac-based departments into a single university...

 professor Nedeljko Parezanović. It was used for Assembly language
Assembly language
An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices. It implements a symbolic representation of the machine codes and other constants needed to program a given CPU architecture...

 and Computer architecture
Computer architecture
In computer science and engineering, computer architecture is the practical art of selecting and interconnecting hardware components to create computers that meet functional, performance and cost goals and the formal modelling of those systems....

 courses.

Specifications

NAR 1 processor
Central processing unit
The central processing unit is the portion of a computer system that carries out the instructions of a computer program, to perform the basic arithmetical, logical, and input/output operations of the system. The CPU plays a role somewhat analogous to the brain in the computer. The term has been in...

 has a 5-bit
Bit
A bit is the basic unit of information in computing and telecommunications; it is the amount of information stored by a digital device or other physical system that exists in one of two possible distinct states...

 address bus
Address bus
An address bus is a computer bus that is used to specify a physical address. When a processor or DMA-enabled device needs to read or write to a memory location, it specifies that memory location on the address bus...

 (32 byte
Byte
The byte is a unit of digital information in computing and telecommunications that most commonly consists of eight bits. Historically, a byte was the number of bits used to encode a single character of text in a computer and for this reason it is the basic addressable element in many computer...

s of addressable memory) and 8-bit data bus. Machine instructions were single-byte with three most significant bit
Most significant bit
In computing, the most significant bit is the bit position in a binary number having the greatest value...

s specifying the opcode
Opcode
In computer science engineering, an opcode is the portion of a machine language instruction that specifies the operation to be performed. Their specification and format are laid out in the instruction set architecture of the processor in question...

 and 5 least significant bit
Least significant bit
In computing, the least significant bit is the bit position in a binary integer giving the units value, that is, determining whether the number is even or odd. The lsb is sometimes referred to as the right-most bit, due to the convention in positional notation of writing less significant digits...

s the parameter - memory address
Memory address
A digital computer's memory, more specifically main memory, consists of many memory locations, each having a memory address, a number, analogous to a street address, at which computer programs store and retrieve, machine code or data. Most application programs do not directly read and write to...

. A single 8-bit accumulator register
Accumulator (computing)
In a computer's central processing unit , an accumulator is a register in which intermediate arithmetic and logic results are stored. Without a register like an accumulator, it would be necessary to write the result of each calculation to main memory, perhaps only to be read right back again for...

 was available and there were no flags or flag registers
Flag (computing)
In computer programming, flag can refer to one or more bits that are used to store a binary value or code that has an assigned meaning, but can refer to uses of other data types...

. Only absolute addressing mode was available and all others were achieved by self-modifying code
Self-modifying code
In computer science, self-modifying code is code that alters its own instructions while it is executing - usually to reduce the instruction path length and improve performance or simply to reduce otherwise repetitively similar code, thus simplifying maintenance...

.

Even though this is only a theoretical computer the following physical characteristics were given:
  • Memory cycle: 1μs
  • Arithmetic operation (SABF) cycle: 0.9μs (900ns)
  • Control panel facilitates power on and off, memory data entry and readout, instruction counter entry and selection of either program execution mode or control panel mode.

Instruction coding and set

  • SABF (001aaaaa, sr.
    Serbian language
    Serbian is a form of Serbo-Croatian, a South Slavic language, spoken by Serbs in Serbia, Bosnia and Herzegovina, Montenegro, Croatia and neighbouring countries....

     Saberi u Fiksnom zarezu, en.
    English language
    English is a West Germanic language that arose in the Anglo-Saxon kingdoms of England and spread into what was to become south-east Scotland under the influence of the Anglian medieval kingdom of Northumbria...

     Add Fixed point) loads the content of memory location specified by the address parameter, adds it to the current value of the accumulator and stores the result into the accumulator
  • PZAF (010xxxxx, sr.
    Serbian language
    Serbian is a form of Serbo-Croatian, a South Slavic language, spoken by Serbs in Serbia, Bosnia and Herzegovina, Montenegro, Croatia and neighbouring countries....

     Promeni Znak Akumulatora u Fiksnom zarezu, en.
    English language
    English is a West Germanic language that arose in the Anglo-Saxon kingdoms of England and spread into what was to become south-east Scotland under the influence of the Anglian medieval kingdom of Northumbria...

     Change the sign of the accumulator in fixed point) Negates the fixed point (such as integer) value in the accumulator
  • AUM (011aaaaa, sr.
    Serbian language
    Serbian is a form of Serbo-Croatian, a South Slavic language, spoken by Serbs in Serbia, Bosnia and Herzegovina, Montenegro, Croatia and neighbouring countries....

     Akumulator U Memoriju, en.
    English language
    English is a West Germanic language that arose in the Anglo-Saxon kingdoms of England and spread into what was to become south-east Scotland under the influence of the Anglian medieval kingdom of Northumbria...

     Accumulator Into Memory) stores the content of the accumulator into memory location specified by the address parameter
  • MUA (100aaaaa, sr.
    Serbian language
    Serbian is a form of Serbo-Croatian, a South Slavic language, spoken by Serbs in Serbia, Bosnia and Herzegovina, Montenegro, Croatia and neighbouring countries....

     Memorija U Akumulator, en.
    English language
    English is a West Germanic language that arose in the Anglo-Saxon kingdoms of England and spread into what was to become south-east Scotland under the influence of the Anglian medieval kingdom of Northumbria...

     Memory Into Accumulator) loads the content of memory location specified by the address parameter into the accumulator
  • NES (101aaaaa, sr.
    Serbian language
    Serbian is a form of Serbo-Croatian, a South Slavic language, spoken by Serbs in Serbia, Bosnia and Herzegovina, Montenegro, Croatia and neighbouring countries....

     Negativni Skok, en.
    English language
    English is a West Germanic language that arose in the Anglo-Saxon kingdoms of England and spread into what was to become south-east Scotland under the influence of the Anglian medieval kingdom of Northumbria...

     Negative Jump) performs a conditional jump
    Branch (computer science)
    A branch is sequence of code in a computer program which is conditionally executed depending on whether the flow of control is altered or not . The term can be used when referring to programs in high level languages as well as program written in machine code or assembly language...

     to the address specified by the parameter if the current value of the accumulator is negative
  • ZAR (110xxxxx, sr.
    Serbian language
    Serbian is a form of Serbo-Croatian, a South Slavic language, spoken by Serbs in Serbia, Bosnia and Herzegovina, Montenegro, Croatia and neighbouring countries....

     Zaustavi Računar, en.
    English language
    English is a West Germanic language that arose in the Anglo-Saxon kingdoms of England and spread into what was to become south-east Scotland under the influence of the Anglian medieval kingdom of Northumbria...

     Stop the Computer) stops any further processing.


Two more instructions were not specified but were commonly present in simulators and took instruction codes 000aaaaa and 111aaaaa:
  • BES (sr.
    Serbian language
    Serbian is a form of Serbo-Croatian, a South Slavic language, spoken by Serbs in Serbia, Bosnia and Herzegovina, Montenegro, Croatia and neighbouring countries....

     Bezuslovni Skok, en.
    English language
    English is a West Germanic language that arose in the Anglo-Saxon kingdoms of England and spread into what was to become south-east Scotland under the influence of the Anglian medieval kingdom of Northumbria...

     Unconditional Jump) performs an unconditional jump to the address specified by the parameter
  • NUS (sr.
    Serbian language
    Serbian is a form of Serbo-Croatian, a South Slavic language, spoken by Serbs in Serbia, Bosnia and Herzegovina, Montenegro, Croatia and neighbouring countries....

     Nula-Skok, en.
    English language
    English is a West Germanic language that arose in the Anglo-Saxon kingdoms of England and spread into what was to become south-east Scotland under the influence of the Anglian medieval kingdom of Northumbria...

     Zero Jump) performs a conditional jump
    Branch (computer science)
    A branch is sequence of code in a computer program which is conditionally executed depending on whether the flow of control is altered or not . The term can be used when referring to programs in high level languages as well as program written in machine code or assembly language...

     to the address specified by the parameter if the current value of the accumulator is zero

Example programs

A sample program that sums up an array of 8-bit integers:


00: 0 ; input: 0 or value 22, output: result
01..21: 0,0,0... ; input: values 1..21
22: MUA 0 ; Start of program; Load accumulator from address 0
23: SABF 1 ; Add value from address 1 to accumulator
24: AUM 0 ; Store accumulator to address 0
25: MUA 23 ; Load instruction at address 23 (SABF)
26: SABF 31 ; Add value from address 31 (+1) to accumulator
27: AUM 23 ; Store accumulator to address 23 (modifies SABF instruction)
28: SABF 30 ; Add value from address 30 to accumulator
29: NES 22 ; Jump back to 22 if accumulator value is negative
30: ZAR 10 ; Stop the computer. Argument makes this byte have the value of -(SABF 22) = -54.
31: 1 ; Value to add to address in each iteration


Above program adds up to 22 8-bit values if executed from address 22:
  • Values 1-21 stored at locations 1-21
  • Value 22 stored at location 0, instead of the constant 0 and will be replaced by the result


NAR 1 programs are commonly self-modifying. Unlike in some other architectures, this is not a 'trick'. As memory can not be addressed by a register, the only way to dynamically manipulate memoory data is to modify memory manipulation instructions. Above example also contains a typical trick to save memory - instruction (at address 30) is reused as data by another instruction (at address 28).

If initial accumulator value can be controlled from the control pane, a 23rd value can be stored in it. Above program has to be only slightly modified - instruction SABF 1 at address 23 has to be changed to SABF 0 and the program should be executed from that address (23) and not from 22.

Other tricks included the use of the changes of the sign after instruction is modified, as shown in the following example:


00..21: 0,0,0... ; input values 22 to 1
22: 0 ; input: 0 or value 23, output: result
23: MUA 21 ; start of program; Load (next) value
24: SABF 22 ; Add subtotal at 22 to accumulator
25: AUM 22 ; Store new subtotal to 22
26: MUA 23 ; Load instruction 23 into accumulator
27: SABF 31 ; Decrement instruction by 1
28: AUM 23 ; Update instruction
29: NES 23 ; Repeat if the instruction is still negative
30: ZAR ; Otherwise, stop the computer
31: -1 ; Constant needed for instruction at 27


Here the instruction "MUA 21" at address 23 has the binary value 10010101, which is -107 decimal when treated like signed integer in two's complement
Two's complement
The two's complement of a binary number is defined as the value obtained by subtracting the number from a large power of two...

. Instructions at addresses 26, 27 and 28 decrement this value by 1 in each iteration. This will modify the 5 least significant bits specifying the address and will not touch the three bits indicating the instruction until that instruction becomes MUA 0 (10000000 binary = -128 decimal, negative). Once this is decremented by one it becomes 01111111 (+127 decimal) which is no longer negative and will cause the jump-if-negative instruction at 29 to pass, proceeding to "stop the computer" at 30.

Similarly to above, this program can add between 22 and 24 values, depending on whether address 22 can be used for both input and output and whether initial value of the accumulator can be used as input (the program should then be executed from address 24 and instruction at 23 should be MUA 22).

If particular implementation stops the computer if it encounters an unknown opcode or it implements additional unconditional jump instruction with opcode "111aaaaa", then such behaviour can be used as follows:


00..22: 0,0,0... ; input values 23 to 1
23: 0 ; input: 0 or value 24, output: result
24: MUA 22 ; start of program; Load (next) value
25: SABF 23 ; Add subtotal at 23 to accumulator
26: AUM 23 ; Store new subtotal to 23
27: MUA 24 ; Load instruction 24 into accumulator
28: SABF 31 ; Decrement instruction by 1
29: AUM 24 ; Update instruction
30: NES 24 ; Repeat if the instruction is still negative
31: -1 ; BES 31 or invalid instruction & constant for instruction at 28


Above, the value of "-1" found at address 31 can either be treated as invalid instruction causing the computer to stop or as unconditional jump (BES 31) to the same address, resulting in infinite loop that does not affect the result (control panel can be used to display it).

Finally, depending on whether it is decided that a computer will stop program execution if it reaches the end of memory (address 31, will not roll back to address 0), above program can be reorganized to take one value more by eliminating the need for "stop the computer" instruction altogether, as follows:


00..22: 0,0,0... ; input values 23 to 1
23: 0 ; input: 0 or value 24, output: result
24: -1 ; Constant needed for instruction at 29
25: MUA 22 ; start of program; Load (next) value
26: SABF 23 ; Add subtotal at 23 to accumulator
27: AUM 23 ; Store new subtotal to 23
28: MUA 25 ; Load instruction 25 into accumulator
29: SABF 24 ; Decrement instruction by 1
30: AUM 25 ; Update instruction
31: NES 25 ; Repeat if the instruction is still negative
------------- end of memory

Trivia

  • Word "nar" means Pomegranate
    Pomegranate
    The pomegranate , Punica granatum, is a fruit-bearing deciduous shrub or small tree growing between five and eight meters tall.Native to the area of modern day Iran, the pomegranate has been cultivated in the Caucasus since ancient times. From there it spread to Asian areas such as the Caucasus as...

     in Serbian language
    Serbian language
    Serbian is a form of Serbo-Croatian, a South Slavic language, spoken by Serbs in Serbia, Bosnia and Herzegovina, Montenegro, Croatia and neighbouring countries....

  • Many NAR 1 simulators were created. One was named "Šljiva" (en.
    English language
    English is a West Germanic language that arose in the Anglo-Saxon kingdoms of England and spread into what was to become south-east Scotland under the influence of the Anglian medieval kingdom of Northumbria...

     plum
    Plum
    A plum or gage is a stone fruit tree in the genus Prunus, subgenus Prunus. The subgenus is distinguished from other subgenera in the shoots having a terminal bud and solitary side buds , the flowers in groups of one to five together on short stems, and the fruit having a groove running down one...

    ) as that fruit grows in Serbia
    Serbia
    Serbia , officially the Republic of Serbia , is a landlocked country located at the crossroads of Central and Southeast Europe, covering the southern part of the Carpathian basin and the central part of the Balkans...

    , while "nar" does not.
  • One of frequently given taks was to create a program that adds as many numbers as possible, having those numbers stored in 32-byte memory along with the program.
  • Some assembly language protocols are derived from the NAR1 khulil code
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK