<< 2012-3 >>
Department of
Computer Science
 

Introduction

File Name Conventions

Files written in the PREASM language are, by convention, appended with a suffix of .preasm to distinguish them from other file types.

Comments

To provide the programmer with a means of documenting their source code, the PREASM language supports comments. Comments begin with a ; and extend to the end of the line.

Instructions

The instructions for the PREASM language are grouped, for readability, into several types : This instruction set is RISC like with the only slightly non-standard instructions being the altered load and store instructions and the addition of cache partition management instructions. This allows the cache to be visible to the compiler

Load & Store instructions

Memory load and store instructions take a partition parameter that has no effect on non-partitioned cache implementations.
LOADC RDest, Constant
Load the literal value Constant into register RDest.

MOV RDest, RSource
Copy the value in register RSource to register RDest.

LOAD RDest, RAddress, ParNum
Load into register RDest the word from the memory location given in register RAddress. The cache partition ParNum is used to cache this memory access.

LOADIDX RDest, RBase, RAddress, ParNum
Load into register RDest the word from the memory location given as the sum of registers RBase and RAddress. The cache partition ParNum is used to cache this memory access.

STORE RSource, RAddress, ParNum
Store the contents of register RSource in memory at the location given in register RAddress. The cache partition ParNum is used to cache this memory access.

STOREIDX RSource, RBase, RAddress, ParNum
Store the contents of register RSource in memory at the location given as the sum of registers RBase and RAddress. The cache partition ParNum is used to cache this memory access.

Arithmetic & Logic instructions

All arithmetic and logic instructions are register-register based, and can have assumed natural semantics. They are briefly described here for completeness. All comparison operations are on signed values.

Arithmetic Instructions

ADD RDest, RSource1, RSource2
RDest=RSource1+RSource2.

SUB RDest, RSource1, RSource2
RDest=RSource1-RSource2.

MUL RDest, RSource1, RSource2
RDest=RSource1*RSource2.

DIV RDest, RSource1, RSource2
RDest=RSource1/RSource2.

MOD RDest, RSource1, RSource2
RDest=RSource1%RSource2.

LS RDest, RSource1, RSource2
RDest=RSource1<< RSource2.

RS RDest, RSource1, RSource2
RDest=(signed)RSource1>>RSource2.

RSU RDest, RSource1, RSource2
RDest=(unsigned)RSource1>>RSource2.

Logic Instructions

NOT RDest, RSource
RDest=~RSource.

AND RDest, RSource1, RSource2
RDest=RSource1&RSource2.

OR RDest, RSource1, RSource2
RDest=RSource1|RSource2.

XOR RDest, RSource1, RSource2
RDest=RSource1^RSource2.

LT RDest, RSource1, RSource2
RDest=RSource1< RSource2.

GT RDest, RSource1, RSource2
RDest=RSource1>RSource2.

EQ RDest, RSource1, RSource2
RDest=RSource1==RSource2.

Branching & Procedural instructions

Branches are immediate (no pipelining simulation).
JUMP Label
Jump to Label.

JUMPR RTarget
Jump to the address in register RTarget.

JUMPZ RCond, Label
Jump to Label if register RCond contains zero.

JUMPNZ RCond, Label
Jump to Label if register RCond is not zero.

Partitioning instructions

Partition instructions have no effect on non-partitioned cache implementations.
CREPAR ParNum, Size, Stride
Create partition named ParNum, with Size lines, with stride Stride. Size is a power of 2, and the implementable strides are governed by the partitioned cache implementation.

DELPAR ParNum
Delete partition named ParNum. The partition name is now free for reuse.

INVPAR ParNum
Invalidate partition named ParNum. All lines of this partition are invalidated (valid bit set to false).

SETIPAR ParNum
Set the current instruction partition to ParNum. All further accesses to instructions will be routed through this partition.

UPDPAR RSource, RBase, RAddress, ParNum
Update the value in the specified address within partition ParNum with the specified value.

Misc instructions

These are instructions that don't fit in anywhere else.

NOP
Perform no operation.

TRAP
Cause a trap to occur in the operating system layer of the machine.

HALT
A pseduo-instruction which causes the similator to stop.

Directives

To allow slightly more complex assembly support, directives can be used to introduce some structure into .PREASM programs :

.ALIGN

.ALIGN 4 The .ALIGN directive is used to align data and instructions to specific memory addresses, such as cache or page boundaries, so that they are more efficiently organised. The argument to the directive specifies the boundary to align to.

.CONSTANT_SEGMENT and .END_CONSTANT_SEGMENT

.CONSTANT_SEGMENT .... .END_CONSTANT_SEGMENT The .CONSTANT_SEGMENT and .END_CONSTANT_SEGMENT directives are as markers for a block of code that containts constant definitions. These constants could take the form of strings of numbers and are appended to the process image as a constant pool.

.DATA

.DATA 1 By using the .DATA directive, the programmer can reserve space for variable data whose size is known at compile time ie. non dynamically allocated data. This is generally done in the data and constant segments - using the .DATA directive in the instruction segment is not a good idea. The one argument to the directive is the size, in words, of data to allocate space for.

.DATA_SEGMENT and .END_DATA_SEGMENT

.DATA_SEGMENT .... .END_DATA_SEGMENT The .DATA_SEGMENT and .END_DATA_SEGMENT directives are as markers for a block of code that containts data space allocation. This should only contain data related directives and not instruction code although doing so is not prevented.

.DATA_PARTITION and .INSTRUCTION_PARTITION

.DATA_PARTITION dpartition, 2, 1 .INSTRUCTION_PARTITION ipartition, 1, 1 To create symbols for partition names, the .DATA_PARTITION and .INSTRUCTION_PARTITION directives are used to create data and instruction partitions respectivly. Both directives take three arguments which are the symbol name for the partition, the size of the partition, in cache lines, and the stride of the partition, in words.

.MACRO and .END_MACRO

.MACRO name1 .... .END_MACRO .MACRO name2( A, B, C ) .... .END_MACRO name1 name2( 1, 2, 3 ) Yes, macros are supported in both parameterised and non-parameterised forms. When a macro is called, the body is expanded and replaces the macro call with all parameters being textually replaced by passed arguments. Don't get too excited though as they haven't exactly been tested too much.

.INSTRUCTION_SEGMENT and .END_INSTRUCTION_SEGMENT

.INSTRUCTION_SEGMENT .... .END_INSTRUCTION_SEGMENT The .INSTRUCTION_SEGMENT and .END_INSTRUCTION_SEGMENT directives are as markers for a block of code that containts instruction code. This should only contain instructions and not data directives code although doing so is not prevented.

.LABEL

label: Labels are defined by an identifier followed by a colon.

.PUBLIC, .PRIVATE and .EXTERN

.PUBLIC publicLabel .PRIVATE privateLabel .EXTERN externLabel In order to control the scope of symbols and hence allow external linkage to occur, the scope directives are used. All three directives take one argument which is the symbol name on which to operate.

.STRING

.STRING "abcdefg" In a similar way to the .DATA directive, the .STRING directive allocates storage space for a constant string in the constant pool. The string argument to the directive is packed into memory words and appended to the constant pool.
© 1995-2013 University of Bristol  |  Terms and Conditions  |  Use of Cookies
About this Page