OS-9 Assembly Code Development: Difference between revisions

From F256 Foenix
Jump to navigationJump to search
(Added Memory and DAT Image)
Line 5: Line 5:


=== Memory and DAT Image ===
=== Memory and DAT Image ===
<code>mmap</code> and <code>pmap</code> will output the current status of the memory in the system. mmap shows which memory blocks are currently in use.  pmap shows the blocks that are mapped in the DAT Image for a particular process.
<code>mmap</code> and <code>pmap</code> will output the current status of the memory in the system. <code>mmap</code> shows which memory blocks are currently in use.  <code>pmap</code> shows the blocks that are mapped in the DAT Image for a particular process.
[[File:Mmappmap.png|none|thumb]]
[[File:Mmappmap.png|none|thumb]]



Revision as of 19:03, 17 June 2024

Overview

Each process in NitrOS-9 is allocated its own 64K address space. When run, the program object code is loaded into one memory space, and the variables and data structures are loaded into the other. In addition, NitrOS-9 keeps an separate per-process MMU table (DAT Image). So it is important to use the OS-9 calls F$MapBlk and F$ClrBlk calls to map in memory blocks with the MMU.

When a new process is created, registers U, Y, DP and SP are set with U = start of data area, Y = end of data area, DP = page # of beginning page, SP = end of data area + 1. Each process includes its own execution and data directories, and std in, std out and std err.

Memory and DAT Image

mmap and pmap will output the current status of the memory in the system. mmap shows which memory blocks are currently in use. pmap shows the blocks that are mapped in the DAT Image for a particular process.

Program and Data Module Structure

There are 9 different types of modules in 4 possible languages:

Module Types Language
Code Module Type Name Code Language
$1x Program Module Prgm $x0 Data (non-executable)
$2x Subroutine Module Sbrtn $x1 6809 Object Code
$3x Multi-module Multi $x2 BASIC09 I-Code
$4x Data Module Data $x3 PASCAL I-Code
$5x-$Bx User-definable module $x4-$xF Reserved for Future Use
$Cx OS-9 System Module Systm
$Dx OS-9 File Manager Module FlMgr
$Ex OS-9 Device Driver Module Drivr
$Fx OS-9 Device Descriptor Module Devic

The two most used will be Program Modules and Data Modules.

Program Modules

Data Modules

Here is a portion of the font module, which is a data module in NitrOS-9.

               nam       font

               ttl       F256 font

               use       defsfile

tylg           set       Data

atrv           set       ReEnt+rev

rev            set       $01

               mod       eom,name,tylg,atrv,start,0

name           fcs       /font/

start

L0000          fcb   $00,$00,$00,$00,$00,$00,$00,$00 

L0008          fcb   $7C,$82,$AA,$82,$BA,$92,$82,$7C 

*More data here

               emod

eom            equ       *

               end

Writing Position Independent Code

All code in NitrOS-9 must be position independent. Addresses are not known until a program module is loaded and executed. All addressing must be "program counter relative addressing". All branch and long branch instructions are program counter relative.

Rules:

Use BRA and LBRA instead of JMP

Use BSR and LBSR instead of JSR

Use program counter relative indexed addressing for all load, store, arithmetic and logical instructions.

Accessing Variables and Data Structures

Accessing Table Data with PCR