UserGuide

Here are some of the pages of the User Guide!

ORGAMS 29-07-2016


Quick Start

  • RUN "#BURN" (to install ROMs.)
  • |ORG then ESC, or |O to go directly to the editor.
  • CONTROL-I (Import) Loads a DAMS source file, Maxam (ASCII) or TurboAss (exported to ASCII).
  • CONTROL-1 To assemble.
  • SPACE To return to the editor.
  • CONTROL-4 To cycle through the current errors.
  • CONTROL-S to save. CONTROL-O to open.
  • CONTROL-2 To assemble & run (warning default ENT is &9000).
  • CONTROL-H For online help, available in the editor, monitor, and debugger.

Overview

Like DAMS Orgams breaks down into:

  • Editor (with validation on the fly lines seizures)
  • Monitor (aka "Monogams")
  • Debugger (disassembly, trace step-by-step, etc …)

Orgams is large although heavily crunched it occupies 3 ROMs:

  • ORGAMS.ROM: Base Rom place in any rom position 1 to 15 (or up to 31 with the proper firmware).
  • ORGEXT.ROM: Expansion Rom placed at any rom position 1-127.
  • MONOGAMS.ROM: Monitor placed at any rom position 1-127.

Several banks are being used (decreasingly), basic bank (bkBase) being:

  • C7 with 128k
  • FF with 512k (allows cohabitation with 256k RAM-DISK).

Then bkBase-1 is used for the mirror system / working memory.
The source begins in bkBase-2.

Screenshots of monitor, editor and trace.

Flow between modules

Here, "Exec" represents the assembled program running.

Basic

  • |ORGAMS: opens the monitor and deletes the source code.
  • |ORG, |M: opens the monitor without deleting the source code.
  • |O: opens the editor without deleting the source code.

Monitor

  • ESC: Goto Ed
  • Order 'basic': (Back) Basic.
  • Command 'DEXP' Goto debugger

Ed

  • CTRL-F2: If ok, Goto Exec
  • ESC: Goto Monitor

Exec

  • RET: as RESTORE (but the battery must be valid)
  • RESTORE Restores system and Goto Ed.
  • BRK / rst &30 / call &BE00: Goto Trace

Debugger

  • CONTROL-ESC: Goto Editor to visualized line.
  • ESC: Goto Monitor
  • J: Goto Exec

Programming session example:

  1. Tweaking opcodes via the editor. CONTROL-4 makes it possible to go directly to the reported errors during assembly (CONTROL-1).
  2. Rather than a mere RET, use RESTORE or BRK to quit out of your program.
  3. Save source.
  4. Test by CONTROL-2: it assembles the code and run the program.
  5. The monitor allows to study all memory (except the screen memory this is used by Orgams' display).

Editor

Enter the editor using |O from BASIC, or by pressing ESC in the Monitor.
Leave the editor by either pressing ESC, launching assembly + execution (CTRL 2), or by resetting the CPC.

The current session persists across resets, with the source validity check.

Import

The first thing you want to do is listen 6:33.
The second will be to import your old tatty sources (see "Write a technical manual for Dummies", how to create "user stories").
Via CONTROL-I, Orgams automatically recognizes source from DAMS and other ASCII sources (TurboASS, Maxam or ORGAMS).
The various adjustments will be made automatically for example:

  • 'NbDots EQU &1000' becomes 'nbDots = &1000'
  • 'Defs 100,nbCols%3' becomes 'FILL 100,nbCols MOD 3'

The operation is very slow because much of the pre-assembly and symbol resolution is done at this time.

Possible differences. !!WARNING!!

Modified Arithmetic.

Example:

  • LD A, pal&#ff + 1; (pal and #FF) + 1

Becomes:

  • LD A, pal AND &FF+1; pal and &100

Indeed, as &ff+1 is visually grouped, it is therefore calculated separately.
It must be corrected to either of these:

  • LD A, pal AND &FF + 1; Direction left to right
  • LD A, [pal AND &FF]+1

ORG behavior

When DAMS assemble with A2, each ORG changes the PC ($) but not the storage address ($$). However ORGAMS does
not allow this mode. To reproduce the same action it must be explicitly replaced:

  • (DAMS) ORG dest
  • (ORGAMS) ORG dest, $$

1 parameter DEFS

The 'DEFS size' DAMS is replaced by 'F size', resulting in a syntax error.
Indeed, 'F' is known as 'FILL', but only when followed by two mandatory parameters.
With one parameter, DAMS reserves space without initializing it. There is no equivalent in ORGAMS. We must
therefore explicitly write 'F size, 0' (automatically replaced by 'FILL size, 0').

Checking

In Monogams, use the X command to compare the assembled code with your referral code.

Limitations

  • Editing of lines is limited to 72 characters. If asked why, you will say that you do not know.

Hotkeys

Keyboard shortcuts are described in the online help (press CONTROL-H).
We concentrate here on more sophisticated.

CTRL + C Displays the catalog of the disk.

CTRL + L str (TAB to continue the search)

Go directly to the next label beginning with "str". This is equivalent to the command 'the DAMS, with the following improvements:

  • Insensitive to breakage
  • You can iterate all labels beginning with "str". Just press CTRL-L again then RETURN to move to the next or just press TAB.

CTRL * (TAB to continue the search)

Go to the next occurrence of the label under cursor (reminiscent VI).
If there is no label under cursor, it takes the first label from this position(*). If there is no such label, it takes the closest to the left.

E.g.

fx_dispatch routine call ; CTRL-* will go to next occurrence of 'fx_dispatch' if the cursor is over
                          ; or next occurrence of 'routine' in all other cases.

(*) Why the label to the right? An article published in "Psychological Science in the Public Interest" shows a tendency to focus on the label following the cursor rather than the one preceding it. This effect is amplified if the cursor is an instruction (e.g. 'call'), but reversed when the guinea pig just read a verse from the Koran.

CTRL Enter

Go to the definition of the label under the cursor.
If the latter is itself a definition, then we take the next.
If there is no label under the cursor, same selection mechanism than CONTROL- *

E.g.
[code]
fx_dispatch call display3D ; CTRL-ENTER go to 'display3D' whatever the cursor position
[/code]

To try it is to adopt, as we say in Denmark.

CTRL Return

Back to previous position (after Ctrl Enter). It works on 8 levels.
As I am not dog (*), I give you a mnemonic: "Enter routine", "Return from routine."

(*) Not that dogs be petty, but they seldom write user guides.

CTRL M

Cycle through the last 8 rows changed. Very handy, I find, having wandered in the source to return to where it was.

CTRL P

Paste the last line cut with CTRL-DEL. UNDO serves rustic but also allows you to duplicate a line faster than the blocks. In this case, must be deleted to better re-insert!

CTRL F (Find) (TAB to continue the search)

Text Search.

  • Case insensitive
  • Indifferent to the tabs (unlike TurboAss where you have to enter the exact number of spaces to search mnemonics with operands).
  • By default, exhaustive search.
    • Precede the search string with a space if it is desired to search only at the beginning of words.
    • End the search string with a space if one wishes to look only at the end of words.
    • Surround the search string with spaces if you want exact search for the word alone.
    • In all these cases, the space at the beginning and at the end is not wanted literally, as shown by the following examples.
V Searched / In source -> OR A LD HL,orang LD HL,Cador LD HL,morel + 4
"Or" * * * *
" Or" * *
"Or " * *
" Or " *

Assembler Shortcuts

We reserve CONTROL+number for assembler shortcuts (presumably fewer). This allows:

  1. Expand easier each other without risk of conflict.
  2. From store / used more efficiently (less cognitive interference, to speak like my concierge).

CONTROL-1: Assemble

CONTROL-2: Assemble+jump

CONTROL-4: Go to the next assembly error.

These shortcuts are achievable with one hand, freeing the other to smoke a Cuban.

Program is lunched under DI, standard RAM connection (&C0), SP set to SP C000, with the correct firmware values for AF 'and BC'.

Source

It is pre-assembled.

  • Facilitates the detection of errors when typing.
  • Identification of the label rather than to editing the assembly: essential for super-fast assembly.
  • Much more compact code.
  • Reduces the need for file 'object' (assembled code provided with the information necessary for the relocation and / or to access its routines).
  • There is the possibility to import / export ASCII versions.
  • In the display, imposes breaks (for opcodes / instructions) and Tab. It is also an advantage: uniformity of code without having to format it by hand!

Compiler directives

Org X [,Y]

Or how to generate a Y address of the code to be executed by X.

We distinguish:
* Code pointer (pseudo label $), the address where the code is supposed to run (ie $ almost plays the role of PC)
* Object pointer (pseudo label $$), the address where the code is stored by the assembler.

In the most common scenario, the two coincide, and the ORG X allows to change this address.
Used with two parameters fixed ORG $ and $$ separately.

The following code:

     ORG &1000, &2000
loop JP loop

generate the code 10 C3 00 at &2000.

To change $ only:

byte message "Hello dad!", 0
      ORG &C000, $$
     ; the code is stored after post
toto; this label is &C000

To change $$ only:

     ORG $,&4000

Memory Alignment

To aligncode to a given multiple (typically, multiple of &100), we may copy it to such an address at run-time. This is the poor man's solution. Often, we would like the generated code to be automatically aligned.

There are two alternatives:

   [...]; Some code
   ORG $+&ff AND &ff00
rout01; is XX00

   [...]; Some code
   FILL -$ and &ff,0
rout02; is YY00
   [...]

Limitations / Known bugs

Assembling in 00-3E results in a crash.

BANK n (Warning: DOESN'T WORK YET !)

Directive BANK n re-configures the memory similarly to OUT &7FFF,n.
So,

   BANK &C4
   ORG &3F00
   [...]; &200 bytes of tasty code

generates code both in main RAM and "&C4".

While

   BANK &C2
   ORG &3F00
   [...]

generates code both in banks &C4 and &C5.

Known bug!

The connections &C1 and &C3 are poorly managed.

BYTE and WORD

The BYTE command accepts strings and bytes, possibly mixed:

BYTE 12,"ABC",-1 Encodes 0c 41 42 43 ff

A "BYTE" or "WORD" without a value increments pointers ($ and $$) without writing into memory.
Three possible use-cases:

  • Reuse the current value in memory (eg: setting that you want to keep from one run to another, even in the code re-assembling in between).
  • A purpose of documentation, note that the value does not need to be initialized by the assembler (eg: variable anyway initialized at run-time).
  • Easily define positions in a structure. Eg:
         ld a, (ix + pat_flags) Give ld a, (ix + 2)
         ld e, (ix + pat_value) Give ld e, (ix + 3)
         ld d, (ix + pat_value + 1) Give ld d, (ix + 4)

          ORG 0
pat_pos WORD       ; Do not write anything at 0!
pat_flags BYTE
pat_value WORD

RESTORE

Restore the system, the battery, the oil level before returning to the editor.
Thus, no need to save AF 'and BC', the interrupt vector in &38, etc …

Labels

  • Automatically detects invalid references
  • No limitation in size (the name of labels being stored once, do not hesitate to choose long)
  • Starts with a letter, followed by letters, numbers, or the following characters "_ #"

Digital Expressions

True management sign

A step = -1 does not encode &ff nor &ffff, but indeed -1. Thus, LD A, step*step passes without worries.
Therefore, an error in an overflow indicates a real problem in your program.

Extended Arithmetic

Labels can take the signed 24-bit values. Authorizes for instance:

ram = &40000; yes, 256k

chunksNb = 16;
chunkSize = ram / chunksNb;

Expressions and temporary results can reach 1024 bits.

   ld, ram*ram / &100000000; ok, it's 16

Expressions

  • Warning: No operator precedence!

Sequencing is made only by spaces and square brackets.

  • Examples:
     LD,1+2*3; 9 (+ and * made in order)
     LD,1+2 *3; 9
     LD,1+ 2*3; 7 (2 * 3 form an isolated group, calculated separately before adding 1)
     LD 1+[2*3]; 7 Idem, more classic.
  • Simple rule. Nothing to remember. Visually consistent.

Logical operators and modulo in full (and, xor, or, mod)

Easy to remember.

Repeat

An instruction or a block can be repeated. The advantages are obvious:

  • Compact Plus (to read, write and store)
  • The number of repetitions is controlled by a label.
  • "Defs" on steroids:
     16 ** byte 1,2,3; 1,2,3,1,2,3,1,2,3 ...

For a block repetition, '[' should be on the same line:

; Good
   NbLines ** [
       INC B: OUTI
       INC B: OUTI
       EXX
       OUT (c),e: OUT (c),d: OUT (c),0
       EXX
       ]
; bad
   NbLines **
     [
     INC B: OUTI
     INC B: OUTI
     EXX
     OUT (c),e: OUT (c),d: OUT (c),0
     EXX
     ]

Of course, any label within a block repeated more than once will throw an error (double definition).

Expressions are re-evaluated at each iteration. This facilitates the creation of tables:

             ORG &9000
rampe3 256 ** BYTE ($*3) and &FF ; stores 00 03 06 09 ... FF 02 05 08 ...

Warning!

     4 ** LD A, (DE): INC E; buggy. Only 1 E INC
     4 ** [LD A, (DE): INC E]; OK.

It allows up to 8 levels of nesting. For more, request exemption from the nearest clinic.

Pseudo labels #, ##, ###

The pseudo label # is the index to the containing iteration (include from 0).
The pseudo label ## is the index of the iteration at the next level (when several nested repetition, of course).
Etc.

 2 ** [
 3 ** BYTE &10*## + # ; stores 00 01 02 10 11 12
      ]

Separator ":"

  • Used to group instructions that form a logical operation, and to better include the similarities. Eg:
        LD hl, awesomeness: inc (hl)
        LD hl, brightness : inc (hl)
        LD hl, ovlness    : inc (hl)
  • Less line = better overview on a routine.
  • Essential for coming pseudo-labels.

Conditional assembly

Orgams allows 8 levels of IF ELSE END. To consume without moderation, with moderation.

Breakpoints.

ROM installs to reset a breakpoint routine &BE00, and a jump to &30 in this routine.

Call

Use RST 6 to jump into the monitor in trace mode. Identically, the pseudo BRK instruction (CTRL + SPACE) in the source simply puts RST 6.
Using call &BE00 facilitates conditional stoppages. Eg:

break = &BE00
    [...]
    LD (pattern_pos) ; Must be non-zero
    OR a
    CALL z,break; Investigate!

All registers at the time of the judgment are preserved. The only destructive manipulation is writing two words in the stack:

  1. The return address placed by the RST (or CALL &BE00), necessary to know the current PC.
  2. One PUSH AF necessary to probe IFF (state EI / DI).

In conventional use, this does not disturb the return to the program (like an interrupt). But if SP pointed to a table, it will take account of the corruption of 4 bytes.

Make sure you restore the RAM banks before using BRK!
Example trap:

   LD BC, &7fC2
   OUT (C), C
   [...]
   BRK; Crash !! Jumps to &30 in the wrong bank.

Debugger / disassembler.

There are two types of navigation, with or without execution. Besides, the command 'of the monitor can be understood (D)ebug or (D)isassemble.

Without enforcement, this is a classic disassembly, but with all the flexibility Orgams (kiss your lap):

  • Up and down scrolling (fast with CONTROL)
  • CONTROL-ENTER and RETURN like the editor to explore subroutines (and back!) Without having to enter a single address.

With execution include all the power of a debugger step by step:

  • (S)tep executes an instruction. If there is a call, it enters the subroutine.
  • (N)ext running in fast mode
  • Sometimes you neither want to trace nor execute a routine (eg &BB06). In this case, simply move the pointer to the next instruction, and fingers enable CONTROL-G. This changes PC ($) without executing anything.
  • To avoid having to painstakingly follow the N iterations of a loop, it will place the cursor appropriately, and then build on T or SPACE: the loop will be well executed, but in fast mode.

Limitations:

  • The bit 3 & 5 of the register F are not reproduced correctly.
  • Interruptions are not emulated.

Source/Memory visualization

Orgams try to find source line matching the opcode under cursor '>'. It can fail, rightly or wrongly, thus displaying "source not found". This feature slow down step-by-step trace, mostly in case of failure.
Kindly press CONTROL-V switch to memory dump, to last address selected via 'M' command in monitor. This mode doesn't penalize trace's speed.

Back to source

CONTROL-ESC returns to editor at currently visualized line, contrarily to ESC-ESC which leaves editor cursor untouched.

Back to the program.

Return by pressing J (like 'J'UMP). The state of the Z80 is restored: the point of view of registers it is as if we had called the routine PUSH AF: POP AF: RET. Of course if the program was not traced by step was taken with the current values of registers.
The CRTC registers are restored with the system defaults.

Sauf mention contraire, le contenu de cette page est protégé par la licence Creative Commons Attribution-ShareAlike 3.0 License