Close

a first basic module.

A project log for YGREC32

because F-CPU, YASEP and YGREC8 are not enough and I want to get started with the FC1 but it's too ambitious yet.

yann-guidon-ygdesYann Guidon / YGDES 07/03/2024 at 10:320 Comments

Here is a first attempt at writing a module that just prints "Hello world!".

It shows the basic structure of a module as well as the IPC/IPE/IPR instructions that allow modules to call each others.

; HelloWorld.asm

Section Trampoline

; init:
Entry 0
  IPE
    ; nothing to initialise
  IPR

; run:
Entry 1
  IPE
  ; no check of who's calling.
  jmp main

Section Module

main:
; get the number/ID of the module that writes
; on the console, by calling service "ModuleLookup"
; from module #1 
  set 1 R1
  set mod_str R2
  IPC ModuleLookup R1
; result:  module ID in R1

; write a string of characters on the console
; by calling the service "WriteString"
; in the module designated by par R1
  set mesg_str R2
  IPC WriteString R1

  IPR ; end of program.

Section PublicConstants
  mod_str:  as8 "console"
  mesg_str: as8 "Hello world!"

I'm a bit concerned that the IPC instruction has a rather long latency but... Prefetching would make it even more complicated, I suppose.

Discussions