Search   
Home  Print View  

 

Programmer's Manual

Branch Content

Set

Syntax:

#set VAR = VALUE

The set directive is used to assign a value to a variable. If the variable didn't exist, it is created at that time. VALUE can be either a symbol, an expression, another variable or even the same variable (which doesn't sound too much useful but it is legal anyways).

Once a variable is created, it can be used in instructions in place of the operand, as illustrated in the following example.

#define    BUFF_TAPE_1    = 0x4000
#define    BUFF_TAPE_2    = 0x4100

; Call subroutine passing argument in variable:
#set  @_buff = BUFF_TAPE_1
call READ_TAPE

; Call subroutine again passing a different argument in the same variable:
#set  @_buf  = BUFF_TAPE_2
call READ_TAPE


;
; -- SUBROUTINE --
;
:READ_TAPE
      ; Variable used as operand:
      ld   e, @_buff

Symbols and variables can not share names; failure to observe this will result in errors reported by the assembler. To overcome this limitation, naming conventions must be employed. We suggest to write symbols with uppercases and variables, written with lowercases, to start with the '@' character as illustrated in the previous example.

The need for variables comes from the lack of macros in H1ASM. In fact, you can "encapsulate" reusable generic code into separate source files, then #include it in your "client code" passing arguments through variables. Here is an example:

#set  @_quick_sort_buff       = BUFF_ADDR
#set  @_quick_sort_buff_size  = BUFF_SIZE_VAR

; The included code does the job. It uses the above variables:
#include /home/armando/src/h1_lib/quick_sort.asm

Homebuilt CPUs WebRing

JavaScript by Qirien Dhaela

Join the ring?

David Brooks, the designer of the Simplex-III homebrew computer, has founded the Homebuilt CPUs Web Ring. To join, drop David a line, mentioning your page's URL. He will then add it to the list.
You will need to copy this code fragment into your page.

Project start date: May 13 of 2009