Contents

No$gba
Installation
Debugging

Tech Info
Here are programming specs for the GBA hardware, I've been trying to keep it both as short as possible, and as complete as possible...
GBA Reference
CPU Reference

Homepage & Contact
http://www.work.de/nocash/gba.htm - no$gba homepage
http://www.work.de/nocash/address.htm - my mailing address
for registered users, my email address is found in the no$gba about box.
otherwise my email address will be eventually found on the gba webpage, depending on the amount of incoming garbage; mail from programmers only, please.

Constructive feedback, suggestions, and bug reports would be very welcome.

Protection of the cutdown version and full version
The No$gba Protection


 Debugging

Hotkeys in Debug Mode
Breakpoints
Profiling & Performance Monitoring
Debug Messages
Symbolic Debug Info
The A22i Assembler
XED Editor


 Hotkeys in Debug Mode

Most debug functions are available via hotkeys and via mouse accessable popup boxes. The popup boxes generally also show the corresponding hotkey.

 Cursor             (*) Move around
 Cursor Right           Follow (in codewin: map window to jump/call dest adr)
 Cursor Right           Follow (in stckwin: map codewin to return adr)
 Cursor Left            Undo follow (if nothing to undo: goto program counter)
 Page Up/Down       (*) Move around
 Home               (*) Goto Start or to 0000
 End                (*) Goto End or to IO-Area (FF40 codewin, FF10 datawin)
 Ret                (*) Center/Uncenter current line in code window
 Shift+Cursor           Change Active Window (Code,Data,Stck,Regs)
 Shift+Cursor       (*) Toggle between Hex- and Ascii-input in data window
 Tab                (*) Toggle Standard and Symbolic Display in code window
 Tab                (*) Toggle Lower Window (Data or Break/Watch)
 Ctrl-B                 Enter Breakpoint Address, Condition
 Ctrl-N                 Find Next Breakpoint
 Ctrl-G                 Goto Address (prompts for address) (does not affect pc)
 Ctrl-E             (*) Toggle Warnings on/off
 Ctrl-O                 OS Shell (calls DOS, type 'exit' to come back)
 Ctrl-I                 Inspect (Define Watchpoint address)
 Ctrl-R                 Reload Cartridge
 Ctrl-S                 Search (see below! this works a bit strange)
 Ctrl-C                 Continue Search
 Ctrl-V            (**) Toggle Screen Size 25/50 lines (DOS version only)
 Ctrl-D                 Toggle Datazone (see below)
 Ctrl-A/T/X         (*) Add/Toggle/Remove Machine (up to 12 gameboys at 1 time)
 Ctrl-L/W               Load/Save Snapshot (RAM, CPU-state and ROM-cartname)
 Ctrl-Left/Right    (*) Decrease/Increase start address of window by one byte
 <..>                   Assemble into Memory (input box appears on 1st char)
 F1                     Help
 F2                     Toggle Breakpoint at cursor
 F3                     Trace with calls executed
 F4                     Run to Cursor
 F5                     VRAM Viewer (last accessed screen, TAB toggles)
 F6                     Jump to Cursor (sets programcounter (pc) and rombank)
 F7                     Trace (Execute one instruction)
 F8                     Run until current sub-routine returns
 F9                     Run (until breakpoint or user break)
 F10                    Hardware Info Screen (splits in 50 lines DOS mode)
 F11                    Setup Screen (last accessed setup window)
 F12                    Cartridge Menu (last accessed, filename or files.lst)
 Scroll Lock            Toggle Datacur follows Codecur (or 16bit reg) on/off
 Keypad "*"             Reset and Run
 Keypad "-"         (*) Continue Run (same as F9)
 ESC                (*) Popup File Menu or close current window/menu
 Alt-<..>           (*) Popup Menus (eg. Alt-F for File Menu)
 Alt-A                  Animate (Repeated trace until key pressed)
 ALT-B                  Place Bookmark
 ALT-E                  Edit File
 Alt-X                  Exit No$gba
 Right Mouse Button (*) DOS: Continue Run (same as F9), Windows: Context Menu
 Left Mouse Button  (*) Select Window, Place Cursor, Toggle Breakpoint or
                         CPU-flag, Open Popup Menu, Click Option, etc.

The functions that are marked by (*) are not shown in the popup menues of the menu bar. Vice versa, not all functions can be accessed through hotkeys, so to be able to access all functions you must use both hotkeys and menu bars.

See also:
Hotkeys in Emulation Mode


 Hotkeys in Emulation Mode

The default keyboard controls for player #1 and player #2 are
  Up        Q          Cursor-Up
  Down      A          Cursor-Down
  Left      O          Cursor-Left
  Right     P          Cursor-Right
  Button A  Space      Keypad-"0"
  Button B  Tab        Keypad-"."
  Select    Left-Ctrl  Keypad-"3"
  Start     Enter      Keypad-Enter
  Button L  Left-Alt   L
  Button R  Right-Alt  R
In single player mode, both control sets control the same gameboy.

The keyboard controls for player #1..#12 can be redefined in setup.
Note: The keyboard box in the DOS version wraps to the next page (for the next player) when you move the cursor out of the box with the cursor keys.

The other hotkeys during running emulation are:
  Alt+X                Exit No$gba
  Esc                  Back to debugger
  keypad"-" or ^pause  Back to debugger
  keypad"*"            Reset (Restart Game)
  keypad"/" or pause   Pause (Context Menu)
  keypad"+"            Whoosh. Run at max speed as long as key hold down.
  Shift+F1..F5         Toggle Video Layers BG0..3,OBJ on/off
  F1..F4               Toggle Sound Channel 1..4 on/off
  F5..F6               Toggle Sound FIFO A..B on/off
  F7                   Quickload Snapshot (as 7 looks like L)
  F8                   Quicksave Snapshot (as 8 looks like S)
  F11                  Setup (Options)
  F12                  Cartridge menu
  both mouse buttons   Back to debugger
  left mouse button    Pause (menu) (under windows: right mouse button)
  other button(s)      Joypad emulation (fire/activate)
  mouse move           Joypad emulation (activated by first button click)

See Also:
Hotkeys in Debug Mode


 Breakpoints

Normal Breaks (F2-key)
Normal breakpoints are set (or removed) by moving the code-window cursor onto the desired opcode, and then pushing the F2-key. Up to 50 breakpoints can be defined.

Run-to-Cursor (F4-key)
Hitting F4-key directly starts emulation, and stops when reaching the code window cursor. The break address is not memorized, ie. it is used only once.

Local Conditional Breakpoints
Press Ctrl-B and define the break by entering "address, condition". The emulator will stop when the program counter reaches the address, and when the condition is true. The "$" symbol represents the current cursor address of code window. Examples:
  $, r0<>0           --> break at cursor position if r0 is non-zero
  $, r0 & 2          --> break at cursor position if bit 1 of r0 is set
  $, r0 !& 2         --> break at cursor position if bit 1 of r0 is zero
  8001234, [r1]=r2   --> break at 8001234 if r1 points at a value equal to r2
  wrchr              --> break at wrchr (always, no condition, same as F2-key)
  wrchr, r0=0d       --> break at wrchr if r0 contains 0dh
  $, [4000006] > A0  --> break at cursor if VCOUNT is greater than 0A0h
  $, r4 <= r5        --> break at cursor if r4 is less or equal than r5
  $, [r4] <> [r5]    --> break at cursor if r4 points at other value than r5
  mainloop, ..5      --> break every 5th time that pc gets to mainloop (timer)
The conditions are verified BEFORE the instruction is executed.
  Operators:              Operands:          Timer Identifier:
  ==  =   <   >   &       n   [nn]  r        ..
  !=  <>  <=  >=  !&      nn  [rr]  rr
Operators == and != are pseudonyms for = and <>

Global Conditional Breakpoints
Global breaks are working exactly as above local breaks, except that the condition is verfied after <each> executed opcode. In the Ctrl+B window, enter a condition (without specifying a address). Examples:
  r0 = 0            --> break whenever register r0 becomes zero
  [4000006]>20      --> break whenever VCOUNT becomes greater than 20h
The emulator stops only when a condition changes from false to true, ie. it does not permanently break after each opcode if the condition stays true for a while.

Global Memory Write Breaks
This break-family allows to capture writes to specific memory addresses, or memory areas. Membreaks are defined by pressing Ctrl+B, and then entering conditions such like:
  [02000100]!             ;stops on any byte/halfword/word write to [2000100h]
  [02000100]?             ;stops only when writing new/changed data
  [06000000..06003fff]!   ;stops on any write to first 16Kbytes of VRAM
  [02000000..02003fff]?   ;stops only when writing new/changed data
Appending an exclamation mark ("!") will capture ALL writes, appending a question mark ("?") captures only writes that are changing the memory content (ie. the new data must be different as old data).

The Break Window
The lower left window of the debug screen is shared for Data and Breakpoints, use TAB-key in this window to switch between Data and Break windows. The Break window lists all defined breakpoints, DEL-key can be used to delete a selected breakpoint. When pressing ENTER on a local breakpoint, the code window will be moved to the break address, this works also for bookmarks (that are non-functional 'dummy' breaks, defined by ALT+B in code window).

Source Code Breakpoints
The opcode MOV R11,R11 may be used as source code breakpoint (in both THUMB and ARM state). These breaks are working much like normal F2-key breakpoints, except that they may be defined directly in source code by inserting the above opcode. Because the opcode is not changing any registers or flags there will be no conflicts when testing the binary on real hardware.
Note: Source breaks work only if you have enabled them in no$gba setup. To remove a specific source break, move the code-window cursor onto it, and hit the DEL-key (or enter NOP in the online assembler).


 Profiling & Performance Monitoring

No$gba includes a couple of features for performance monitoring, allowing to write faster or smoother code, to free up more CPU time for additional effects, or simply to reduce the battery power consumption.

Profiling Features
Clock Cycle Comments
Cycle Counters

Related Specifications...
CPU Instruction Cycle Times
Memory Map
System Control
LCD Dimensions and Timings
BIOS Halt Functions


 Clock Cycle Comments

The normal execution time for one GBA opcode ranges between 1 and 100 (!) clock cycles, or more. Unfortunately, opcode execution time depends on various of circumstances (bus widths, waitstates, etc.), which is making it rather difficult to count cycles by hand, or just to a get feeling for efficient GBA code.

The no$gba Clock Cycle Comments feature displays the execution time for each opcode in disassembler window. Four different view modes (selectable in setup) are available:

Short Formula, and Detailed Formula
Short Formula: Displays the Non-sequential, Sequential, and Internal cycles (eg. 2N+3S+1I). Detailed Formula: Splits the N and S cycles into code and data access (eg. 1N+1S+1ND+2SD+1I, N/S for code, ND/SD for data).

Cycles, and Cycles & Sum
Cycles: Displays the number of clock cycles (by resolving the above formula - recursing operand size, opcode and data addresses, and current waitstate configuration). Cycles & Sum: Additionally displays the sum of all opcodes on screen in a second column (to use that feature, simply scroll the first line of interest to topmost screen position).

Even though these features are making it much easier to count cycles, there are still some restrictions which should be kept in mind:

Data access (load/store opcodes) - Important
Cycles are resolved by current register settings. For example, the execution time for "LDR Rd,[Rb]" could be resolved correctly only if Rb is currently pointing to the same memory area as when executing that opcode (that is valid if the program counter points to the opcode, for stack accesses by r13 register it'd be usually always valid).

Prefetch
Game-Pak Prefetch isn't yet understood or supported. If it is enabled in WAITCNT register, access to cartridge ROM may take up less cycles as displayed in clock cycle comments.

Conditional Opcodes
Conditional opcodes are always assumed to be true (unless if the program counter points to the opcode, in that case the actual execution time is displayed, ie. 1S if the condition is false).

Sums
The Cycles & Sums features simply adds one execution time to another, useful for fragments of code, but of course not aware of loops or skips.

Jumps
Execution time for branch opcodes is incorrectly displayed by using local waitstates for local code area (rather than target area). However, intersegment jumps (from one memory area to another) are typically consisting of a call-return combination (ie. the overall execution time would be correct, but the execution times of the call and return opcodes would be exchanged).

VRAM Waitstates
VRAM Waitstates are not displayed (the real hardware would occasionally add 1 cycle for accesses to video memory).


 Cycle Counters

Execution Time value in Statusbar
No$gba displays the clock cycles difference between start and stop time in status bar when the emulation gets stopped. For example, hitting F3-key to execute a "BL draw_frame" opcode would display the execution time of the "draw_frame" procedure.
Note: That would also include any interrupts or DMAs which may have been occured while executing that procedure.

User Counter
The user counter (located in Timers page of I/O map window) is incremented during emulation execution and tracing, the counter can be easily reset to zero by pushing the reset button which is displayed next to it.

Debug Message Counters
The Debug Message feature includes some special operands (%totalclks%, %lastclks%) which allow to write cycle counts to debug message window (or into log file). See Debug Messages chapter for details.

CPU Load Indicator
The "Power Gauge" (the red-green bar in debug window) displays the used CPU time (assuming that the unused CPU time is properly spend in Halt or IntrWait state, which reduces battery power consumption on real hardware). The higher it gets, the more CPU time is used.
By default, CPU load is re-calculated once per frame (60Hz), this rate can be changed in "Other" setup options (useful to prevent flickering with game engines that update the picture only once every two or three frames).
Note: The same information is also displayed as decimal value, in steps of 0.1%, in the Timers page of the I/O map window.

NB. Cycle counters are 32bit values and will overflow (restart at zero) after 4G cycles (256 seconds), which is probably more than enough in most cases.


 Debug Messages

Debug Messages can be defined in source code. When the emulator 'executes' a message opcode, the message text will be output to the debug message window and/or to file DEBUGMSG.TXT (as selected in XCEPT setup). Debug Messages will not disturb execution on real hardware (the branch opcode just skips the data definition, wastes a few clock cycles though).

The message definition format (in THUMB or ARM mode) is as follows:
   mov  r12,r12          ;first ID
   b    @@continue       ;branch opcode that skips the message data
   dcw  6464h            ;second ID (ascii 'dd')
   dcw  0                ;reserved for flags
   dcb  'Hello'          ;user defined ascii data (max length 120 bytes)
   dcb  0                ;ending zero (normally not required, see below)
  .align 4               ;align following code (use align 2 in thumb mode)
  @@continue:
The text field is terminated by a zero byte or by the branch destination. The zero byte must be separately defined ONLY if your assemblers doesn't zero-pad alignment space.

The ascii string may contain parameters, defined as %param%.
  r0,r1,r2,...,r15  show register content (displayed as 32bit Hex number)
  sp,lr,pc          alias for r13,r14,r15
  scanline          show current scanline number
  frame             show total number of frames since coldboot
  totalclks         show total number of clock cycles since coldboot
  lastclks          show number of cycles since previous lastclks (or zeroclks)
  zeroclks          resets the 'lastclks' counter

In the no$gba built-in A22i assembler, messages may be defined as:
  .msg 'Hello'
  .msg 'Source Addr = %r0% ; Dest Addr = %r1% ; Length = %r2%'
  .msg 'Stack Pointer = %SP%'
  .msg 'Decompression time: %lastclks% cycles'
Messages could be defined as macros when using other assemblers. The %parameters% are stored in ascii format as-is. The assembler/macro does NOT need to interprete and/or adjust the parameters!


 Symbolic Debug Info

If debug info (.SYM or .ELF files) has been loaded, labels will be displayed in disassembled code. And input boxes will recognize labels (eg. for Ctrl+G). TAB in code window toggles symbolic display on and off. Moving the code windows cursor onto a line with a symbol displays the value that hides behind the symbol in the upper left corner of the screen (DOS) or in the status bar (Windows).
Also, if source-level debug info is present, no$gba allows the user to view his/her source code in 'stacked' view mode, ie. disassembled opcodes shown below of each source line, this would be important for HLL programs.

.ELF Files
Elf files are binaries, generated by many ARM assemblers and compilers (eg. Nintendo Tools, GNU tools). The files are containing the program (binary executable), and optionally also a symbol table & further debug information (usually in Dwarf2 format, and if present, typically containing source-level debug info).
Current no$gba version supports loading the binary (game), and the symbol table (similiar content as .SYM files, but without additional code+data info), and the source-level debug information.

There seem to be different interpretations of how to store a binary inside of ELF files - as far as I know no$gba is compatible with all of these 'standards'.

.SYM Files
When not using ELF files, symbolic Information may be stored in file <cartname>.SYM in the same directory than <cartname>.GBA. The A22i assembler produces ready-for-use SYM files. When using another assembler, you may convert any debug information into .SYM format.

.SYM Symbolic Information File Format:
  ;no$gba symbolic information table example
  08000000 .arm
  080000C0 start
  08000124 mainloop
  080001EC .thumb
  080001EC init_video
  08000210 .arm
  08000210 irq_handler
  08000228 jumplist
  08000228 .dbl:0010
  08000414 text_array
  08000414 .asc:0017
  0800042B .asc:000F
  0800043A .asc:0012
  06000000 vram_base
  ;...

All symbols have to be declared as EIGHT-character string nnnnnnnn (hexadecimal memory address, not case sensitive), followed by at least one space or TAB and then followed by the symbol name (the name may contain any characters except spaces and control codes, names are case-sensitive).

.SYM Additional Code and Data Information
Aside from labels, the file may also contain information about 16bit or 32bt program code areas, and about data zones. This info is stored in the same format as normal labels, but by using the following reserved "labels":
  .arm          ;following code is in 32bit/ARM format
  .thumb        ;following code is in 16bit/THUMB format
  .byt:NNNN     ;next NNNN bytes are 8bit data (dcb lines)
  .wrd:NNNN     ;next NNNN bytes are 16bit data (dcw lines)
  .dbl:NNNN     ;next NNNN bytes are 32bit data (dcd lines)
  .asc:NNNN     ;next NNNN bytes are ascii data (quoted dcb lines)
  .pool         ;dummy label (indicates that following is literal pool)
The entries may be mixed with normal label definitions, NNNN is a hexadecimal value, it is always counted in BYTES (even when defining 16/32 bit data fields).

There is no need to sort the entries in any way. Empty lines are allowed. Lines starting with ";" are ignored as comments. Lines are terminated by LF or CRLF or EOF or filesize. The file is terminated by EOF or filesize.


 Installation

Required Hardware
Miminum requirement would be a 32bit CPU (eg. 80386SX and up). No$gba has been programmed on a 66MHz 80486DX2, smaller games (eg. simple 2D games, text output) are working relative smoothly at 100% speed on that computer. Larger games (eg. 3D games, plasma demos) may require a CPU speed of up to 400..500MHz.
Emulation performance mainly depends on whether (and how much) the game is using the low power Halt/IntrWait GBA bios functions in idle mode, or not.

Installing No$gba
Just copy the executable to harddisk, preferably into a new/blank folder, below text will refer to this folder as the 'No$gba' folder, you may use any other name though. The program will automatically create some subdirecties. For example, the Slot directory is the suggested location for rom-images.
You will eventually also need some additional files - see below!

Installing Updates
Just overwrite the old executable by the newer version. The setup file from the older version may be used, any unrecognized options will be set to the default value.

Uninstalling No$gba
The program does not infect the windows registry. If you wish to uninstall it just delete the 'No$gba' folder and all sub-directories.
Of course excluding any important files which you may have stored in these directories and which you may want to keep (ie. source code, binaries, game positions, and/or your registration key).

Optional Files

GBA.ROM
When using any BIOS functions in your program, then you will need a copy of the original GBA BIOS (file GBA.ROM, or alternately NO$GBA.ROM, saved in the No$gba folder).
The Xboo tool on the no$gba webpage includes a function for downloading the BIOS from GBA to file (by simple cable connection). Be careful when downloading the BIOS from internet, there seems to be a very popular BIOS version in the net (possible a very old prototype version), this file is not compatible with distributed GBA models - no$gba outputs a warning message if using an incorrect or patched BIOS version.
No$gba includes a small built-in BIOS which is used if the GBA.ROM file is not found. It supports IRQs and SWIs 2-5 (Halt/IntrWait), all other BIOS functions aren't actually required (eg. you may use your own division procedure rather than the BIOS Div function).

PKUNZIP.EXE and/or ARJ.EXE
These decompression programs are required when loading ARJ or ZIP compressed cartridges. The programs must be stored in a directory which is part of your 'Path' (ie. a directory which is automatically searched by the operating system, if you do not understand this, try using your C:\Windows folder). Alternately, decompress the files by hand before loading them.


 The No$gba Protection

Hello to the no$gba protection
Below describes how the protection stuff works...

The protection of the public cutdown/freeware version
This version is (was) made for hobby programmers, I've tried to keep the program as functional as possible (for small games only, but with complete debugging features), and to make it useless for crackers & gamers:
  1) Cartridge/ROM emulation program code is missing in both versions.
  2) Sound emulation program code missing in color version.
  3) Color emulation program code missing in sound version.
Any attempts to upgrade the public cutdown/freeware version into a fully functional (or only parts of more functional) version will result in discontinuing the free public version completely and forever.
(That situation has become true. See you good bye.)

The protection of the professional full/commercial version
This is for developers/companies only. Yes, it is commercial. Yes, I call myself nocash. Bet what? I need some money like everybody else. No, I don't care for luxories.
  1) The program is shipped in form of an encrypted data file.
  2) The data file is completely useless without decryption program.
  3) The decrypter translates the data file into exe file.
  4) The program will not work without registration key file.
  5) The key contains user name, user number, checksum etc.
  6) The key also contains emulation-data that is used by the program.
  7) The user name/number are stored at various locations in executable.
  8) That is parts of as clean ascii, but mostly encrypted text/numbers.
  9) The fullversion costs $X000 US, it is not available to gamers.
  10) That provides that only a few people will get hold of it.
  11) A password is required to install the program on a new computer.
If a fullversion and/or registration key and/or decryption program should leak from a company into public, that company will not receive any further updates.

The freeware version is (was) actually used and appreciated by some hobby coders, if you crack & kill the program, some gamers will maybe kiss your ass, the more serious user won't.


 XED Editor

XED About
XED Hotkeys
XED Assembler/Debugger Interface
XED Commandline based standalone version
XED Copyright & Homepage


 XED About

  "For normal word processing, as used by university students
  for example, it would be suitable to buy an older 1GHz computer."
     - Public Wisdom

Suitable or not, nocash fucks those intellectuals and all their Gigahertz.
Text editing works at 4MHz, no matter what everybody else thinks.

About XED
XED is a text editor, the executable is fast and small, and it includes comfortable editing functions. It is both intended for standard .TXT files (or any other ASCII files, such like .ASM for assembler source code). Also, the line-wrapping support (.XED files) can be used for authoring stories, specifications, etc. Most of the features are much the same as for other text editors, some special functions are pointed out below:

Block Selection
XED supports good old quality block mechanisms, allowing to copy/move the selection directly to cursor position by Ctrl+K,C/V hotkeys (without needing to use paste). For data exchange with other programs or text files, the block can be directly written to (or loaded from) file by Ctrl+K,R/W. And, mainstream copy/cut/paste functions are supported as well, by Ctrl+Ins, Shift+Del, Shift+Ins.
Note: The block remains selected even when typing text, and it won't get deleted when touching Del-key.

Condensed Display Mode
Condensed mode is activated by "F6,C" key combination. In this mode, only lines beginning with colon ":", or (for assembler source code files) with semicolon-colon ";:", for example:
  :Chapter IV - Showdown at Snadra Peak
  ;:---Sound Engine---
Normal block functions can be used in this mode to Move, Copy, or Delete whole 'chapter(s)'. Cursor keys can be used to move the cursor to a specific chapter. Pushing Enter or Escape terminates condensed mode.

Column Block Mode
Column mode is activated by "Ctrl+K,N" key combination. In this mode, the block selection appears as a rectangular area, allowing to deal with tables & columns in text files by using copy/delete, indent/unindent block functions.
Typing "Ctrl+K,N" again will return to normal block mode (in which any lines between begin/end of the block will be selected at full length).

Blank Space
Unlike most other editors, XED allows to move the cursor to any screen location, including at horizontal positions after the end of the current line. Entering space characters at such locations advances the cursor position, but does not actually store space characters in the file.
When typing text, spaces are automatically inserted between line-end and cursor position. Respectively, ending spaces are automatically deleted (eg. assume that the line contains "Hello !", deleting "!" will also remove the space character, internally).
That is of course all happening behind your back, you won't have to care about it - but you can be sure that there'll be no hidden spaces filling up disk space.

Tabulation Marks / TAB-Key
The TAB Key advances the cursor to the next higher tabulation location (usually in steps of eight columns, counted from leftmost screen border), and the appropriate number of spaces is inserted into the file if necessary.
In overwrite mode (de-/activated by INS Key), the TAB Key simply advances the cursor without actually inserting spaces (and without overwriting existing text by spaces).

Tabulation Marks / CHR(9)
When enabled in setup (default), TAB marks are automatically expanded into appropriate number of spaces (ie. towards next "8-column" position) when loading a file.
The file is normally saved by using raw SPC characters, without any TABs. Optionally, it can be saved by using "best-fill" SPCs and TABs (disabled by default), that feature may conflict with third party tools (assemblers, compilers, etc). In order to reduce the risk of such problems, best-fill is suppressed in quoted lines (by using ' or " or <> quotation marks, eg. db 'Hello !').

Line Wrapping
Line wrapping is enabled/disabled by "F5+W" key combination. Wrapping is automatically enabled when loading a file with extension ".XED".
In the file, wrapped lines are using CR characters as soft linebreaks, paragraphs are terminated by normal CR,LF characters. Normal
Note: It'd be recommended to convert .XED files into 'standard' formats such like .TXT or .HTM before releasing them, but preferably NOT into disliked bloated file formats such like .PDF or .DOC.

Word Processing
Aside from the above line-wrapping support, no other 'word processing' features are included, the program provides normal 'type writer' functions, not more, not less. In particular, any overload such like bold or colored text, big and small fonts, bitmaps and different fonts are disliked.


 XED Hotkeys

XED recognizes both CP/M Wordstar hotkeys (also used by Borland PC compilers), and Norton editor hotkeys (NU.EXE). The "Ctrl+X,Y" style hotkeys are wordstar based, particulary including good block functions. The F4,X and Alt/Ctrl+X type hotkeys are norton based, particulary very useful for forwards/backwards searching.

Standard Cursor Keys
  Up         Move line up
  Down       Move line down
  Left       Move character left
  Right      Move character right
  Pgup       Scroll page up / to top of screen
  Pgdn       Scroll page down / to bottom of screen
  Ctrl+Pgup  Go to start of file (or Ctrl+Home)
  Ctrl+Pgdn  Go to end of file (or Ctrl+End)
  Home       Go to start of line
  End        Go to end of line
  Ctrl+Left  Move word left
  Ctrl+Right Move word right
  Ins        Toggle Insert/Overwrite mode
  Del        Delete char below cursor
  Backspace  Delete char left of cursor
  Tab        Move to next tabulation mark
  Enter      New line/paragraph end
  Esc        Quit (or Alt+X, F3+Q, Ctrl+K+D, Ctrl+K+Q, Ctrl+K+X)
Note: Pgup/Pgdn are moving the cursor to top/bottom of screen, page scrolling takes place only if the cursor was already at that location.

Editor Keys
  Ctrl+Y     Delete line (or Alt+K)
  Alt+L      Delete to line end (or Ctrl+Q,Y)
  Alt+V      Caseflip to line end
  Ctrl+V     Caseflip from line beginning

Norton Search/Replace Functions
  Alt+F      Norton - search/replace, forwards
  Ctrl+F     Norton - search/replace, backwards
  Alt+C      Norton - continue search/replace, forwards
  Ctrl+C     Norton - continue search/replace, backwards
Search: Type "Alt/Ctrl+F, String, Enter".
Search+replace: "Type Alt/Ctrl+F, String1, Alt+F, String2, Enter".
Non-case sensitive: Terminate by Escape instead of Enter.

Wordstar Search/Replace Functions
  Ctrl+Q,F   Wordstar - search
  Ctrl+Q,A   Wordstar - replace
  Ctrl+L     Wordstar - continue search/replace
Search options: B=Backwards, G=Global, N=No query,
U=non-casesensitive, W=whole words only, n=n times.

Disk Commands
  F3,E       Save+exit
  F3,S       Save (or Ctrl+K,S)
  F3,N       Edit new file
  F3,A       Append a file
See also: Block commands (read/write block).

Block Selection
  Shift+Cursor  Select block begin..end
  Ctrl+K,B   Set block begin (or F4,S)
  Ctrl+K,K   Set block end   (or F4,S)
  Ctrl+K,H   Remove/hide block markers (or F4,R)
  F4,L       Mark line including ending CRLF (or Ctrl+K,L)
  F4,E       Mark line excluding ending CRLF
  Ctrl+K,T   Mark word
  Ctrl+K,N   Toggle normal/column blocktype

Clipboard Commands
  Shift+Ins  Paste from Clipboard
  Shift+Del  Cut to Clipboard
  Ctrl+Ins   Copy to Clipboard
  Ctrl+Del   Delete Block

Block Commands
  Ctrl+K,C   Copy block (or F4,C)
  Ctrl+K,V   Move block (or F4,M)
  Ctrl+K,Y   Delete block (or F4,D)
  Ctrl+K,P   Print block  (or F7,B)
  Ctrl+Q,B   Find block begin (or F4,F)
  Ctrl+Q,K   Find block end   (or F4,F)
  Ctrl+K,R   Read block from disk towards cursor location
  Ctrl+K,W   Write block to disk
  Ctrl+K,U   Unindent block (delete one space at begin of each line)
  Ctrl+K,I   Indent block (insert one space at begin of each line)
  F5,F       Format block (with actual x-wrap size) (or ;Ctrl+B)
  F8,A       Add values within column-block

Setup Commands
  F11        Setup menu (or F8,S)
  F5,S       Save editor configuration
  F5,L       Set line len for word wrap (or Ctrl+O,R)
  F5,W       Wordwrap on/off (or Ctrl+O,W) (*)
  F5,I       Auto indent on/off (or Ctrl+O,I)
  F5,T       Set tab display spacing
(*) Wrapped lines will be terminated by CR, paragraphs by CRLF.

Other
  F1         Help
  F2         Status (displays info about file & currently selected block)
  F8,M       Make best fill tabs
  F8,T       Translate all tabs to spaces
  SrcLock    Freeze cursor when typing text ("useful" for backwards writing)
  Ctrl+O,C   Center current line
  Ctrl+K,#   Set marker (#=0..9)
  Ctrl+Q,#   Move to marker (#=0..9)
  Ctrl+Q,P   Move to previous pos
  F6,C       Condensed display mode on/off (*)
  Ctrl+G     Go to line nnnn (or F6,G) (or commandline switch /l:nnnn)
(*) only lines starting with ':' or ';:' will be displayed. cursor and block commands can be used (e.g. to copy a text-sequence by just marking it's headline)

Hex-Edit Keys (Binary Files)
This mode is activated by /b commandline switch, allowing to view and modify binary files. Aside from normal cursor keys, the following hotkeys are used:
  Tab        Toggle between HEX and ASC mode (or Shift+Left/Right)
  Ctrl+Arrow Step left/right one full byte (instead one single HEX digit)
  Ctrl+G     Goto hex-address
  Ctrl+K,S   Save file (as usually)

Printer Commands
  F7,P       Print file
  F7,B       Print block (or Ctrl+K,P)
  F7,E       Eject page
  F7,S       Set page size
More printer options can be found in setup. Printing was working well (at least with my own printer) in older XED versions, but it is probably badly bugged (at least untested) for years now.


 XED Assembler/Debugger Interface

Nocash Debuggers
The XED editor provides simple but very useful interaction with the various nocash debuggers/emulators (no$gba, no$gmb, no$cpc, no$msx, no$c64, no$2k6, no$zx81, no$x51).
The editor can be launched from inside of the debugger (by Alt+E hotkey, by retaining the recently edited line number when re-launching the editor).
And, when editing assembler source code files, F9-key can used to launch the assembler from inside of XED. That is, the file is saved to disk, the A22i assembler is started (built-in in all debuggers), and, in case of successful assembly, the program is loaded & started in the emulator. Otherwise, the assembler displays a list of errors, and the editor is moved directly to the source code line number in which the first error has occured.

16bit DOS debuggers
The XED editor is included built-in in all nocash windows debuggers, and in the no$gba 32bit DOS version only.
For use with other nocash 16bit DOS debuggers the XED editor must be downloaded separately at http://www.work.de/xed.htm, and must be installed in a directory which is included in your PATH statement, and XED must be selected as preferred editor in debugger setup.


 XED Commandline based standalone version

Standalone 16bit DOS version
This version is written in turbo pascal, nevertheless fast enough to work on computer with less than 10MHz. It uses 16bit 8086 code, and works with all 80x86 compatible CPUs, including very old XTs.
The downside is that it is restricted to Conventional DOS Memory, so that the maximum filesize is 640K (actually less, because the program and operating system need to use some of that memory).

Using the 32bit debugger-built-in version as 32bit standalone editor
I haven't yet compiled a 32bit standalone version, however, any of the no$xxx 32bit debuggers can be used for that purpose. By commandline input:
  no$xxx /x <filename>   Edit text file in standalone mode
  no$xxx /b <filename>   Edit binary file in standalone hexedit mode

Standalone Commandline Syntax
Syntax: XED <filename> [/l:<line number>] | /?
  <name>    Filename, optionally d:\path\name.ext
  /?        Displays commandline help
  /l:<nnn>  Moves to line number nnn after loading
The filename does not require to include an extension, the program automatically loads the first existing file with any of following extensions appended: XED, ASM, ASC, INC, BAT, TXT, HTM, DOC, A22, PAS.

Standalone DOS Return Value
XED returns a three-byte return value after closing the program. This data is used when calling XED as external editor from inside of nocash DOS debuggers, but it might be also useful for other purposes.
Because normal DOS return values are limited to 8bits only, the three bytes are written into video RAM at rightmost three character locations in first line:
 VSEG:77*2  Exit code   (00h=Exit normal, F9h=Exit by F9-key)
 VSEG:78*2  Line number (Lower 8bits, 1..65536 in total)
 VSEG:79*2  Line number (Upper 8bits)
The color attribute for these characters is set to zero (invisible, black on black). Use INT 10h/AH=0Fh to determine the current video mode (AL AND 7Fh), if it is monochrome (07h) then use VSEG=B000h, otherwise VSEG=B800h.


 XED Copyright & Homepage

Nocash XED editor.
Copyright (C) 1993-2003 by Martin Korth.
All rights reserved.

XED Homepage
http://www.work.de/nocash/xed.htm

Nocash Homepage
http://www.work.de/nocash/



 The A22i Assembler

Online Assembler
In the debuggers code window, you can directly enter assembler instructions and modify the program code. The assembler input box shows up automatically when typing the first character of the new instruction.
The most basic purpose would be to overwrite an opcode by typing "NOP", but you could also enter any other instruction, such like "ADD R0,R0,4" when having debug info (.sym file) loaded, you may also use labels as parameters, eg. "B mainloop".
Note: Aside from translating machine code instructions, the assembler input box can be also used to change the value of CPU registers, by typing "r0=12345678", or "sp=3007FF0" for example. For curiosity, it also parses simple commands such like: run, reload, help, exit, date, etc.

Source Code Assembler
The assembler can be also used to assemble source code files, by using the Assemble File function in Utility menu. This function has been mostly implemented for my own pleasure, and because I didn't wanted to install thirdparty tools on my computer. It's having some nice features, but it's also lacking some possibly important functions (see below).

A22i Advantages
It's easy to use, very fast, produces ready-for-use debug info .sym files, it understands official ARM syntax, as well as more reasonable cleaned-up syntax, and also different assembler dialects, directives, and numeric formats, it can be used directly from inside of the debugger (and from inside of the editor), and vice-versa, it's able call the editor in case of assembly errors.

A22i Disadvantages
The two major problems are: It isn't supporting any macros. And it's having only <very> simple maths support, it'd more or less recognize expressions such like "100h*8+end-begin" but it'd completely fail on any more complicated ones like "3+(4+5)*100h<<2&1ffh".

Possible (Dis-)advantages
If you are wanting to use linkers, make files, project files, header files, command files, resource files, script files, libraries, strip commands, and object files - forget about it!
A22i translates a source code file into a binary file, not more, not less.

For more info about instruction set and directives, see:
CPU Reference
Pseudo Instructions and Directives

Sample Code
For a source code example, have a look at the Magic Floor game at the no$gba webpage, the package includes the binary, source code, with comments, and .sym debug info file.
http://www.work.de/nocash/magicflr.htm