Diese Seite mit anderen teilen ...

Informationen zum Thema:
Beiträge im Thema:
Erster Beitrag:
vor 3 Jahren, 5 Monaten
Letzter Beitrag:
vor 1 Jahr, 3 Monaten
Beteiligte Autoren:
Robin Tönniges, Dennis Kuschel

MyCPU Operating System

Startbeitrag von Dennis Kuschel am 14.03.2015 11:06

Please ask MyCPU OS related questions here.


Hi Dennis,

I have a little question about accessing the Ram-Code-Pages 0-31 within the kShell.

There are commands like "db" and "save" but no matter what "page" I set as parameter to these commands I always get the same output.

For example I have two TSR-Programs running in the same memory area but in different pages, one in page 0 and the other in page 6.
If i try "save test $FF1B $FFFF 0 6" or "save test $FF1B $FFFF 6" the output ist always the same from page 0.

Maybe you can help me out :)

von Robin Tönniges - am 07.12.2015 01:29
Hi Robin,

programs are always loaded into "ROM-pages", where "ROM-pages" can also be called "CODE-pages". ROM-pages are the memory pages that are located in the address range 0x8000-0xFFFF. RAM-pages are in the area 0x4000-0x7FFF. So the command to save your test-programs must be

"save test $FF1B $FFFF 0 0" and "save test $FF1B $FFFF 0 6"

Note that the first 0 is only a place-holder (it is a don't care).

Another way is to access the ROM-page via the RAM-page window, because it is the same memory chip, but with other address decoding. Take the ROM-page number and multiply it with two. If the ROM-address is equal or above 0xC000, add one to the RAM-page number. To access the upper half of the ROM-page 6 you must take the RAM-page number 13, and use the address range 0x7F1B to 0x7FFF:

"save test $7F1B $7FFF 13"

von Dennis Kuschel - am 07.12.2015 06:03
Hi Dennis,

I can report a "small" success ;)
But I'm even more confused :confused:

This is whats "mem -a" returns:

PG PSB Filename Adr-Range Size used bytes (ZP/RAMpg)
00 F9B7 mem F9E2-FFFF 061E 0 / 0
06 D492 :sl26cs89 D4BD-D514 0058 0 / 0
06 D515 sl26cs89 D540-DCC1 0782 0 / 0
06 DCC2 sl20net DCEF-FE8F 21A1 2 / 16384
06 FE90 sl21para FEBB-FF1A 0060 0 / 0
06 FF1B netstart FF46-FFFF 00BA 0 / 0
0E FF38 testPrg FF63-FFFF 009D 0 / 0

I want to get the "testPrg".

If I try "save test $FF63 $FFFF 0 14" I get the wrong memory area (dont know which but its the wrong :) )
If I try "save test $7F63 $7FFF 29" its again the wrong (but another wrong).
The strange thing is that no matter what page (RAM or ROM) I use the output ist still the same except I change the Adress-Range.

So after a little try and error I finally get the expectet result with "db -p 15 $7F63" :confused:

EDIT: It seems that the "save" command fetches only new data on the first execute.
All following executes give the same result until I reset the CPU.
This means "save test $7F63 $7FFF 15" gives also the expected correct output as "db -p 15 $7F63".

I understand that "db" can only switch between RAM-pages (0-63) but if my programm is in a ROM-page (in my case 0Eh=14) why its not the RAM-page 29? :confused::confused:
I thought because the ROM-pages are twice as large as the RAM-pages the page number has to be multiplied with two as you explained.

Hopy you can tell me wheres my mistake :-(

von Robin Tönniges - am 07.12.2015 18:21
Hi Robin!

First of all, the "save" command seems to be broken for ROM-pages other than page 0. So you should use "save" only with the RAM-page-area 0x4000-0x7FFF.

Second, I was mistaken. The ROM-page-numbers that are shown by the mem-command are not the index numbers but the register values. So the 32kb ROM-page $0E consists of the RAM-pages $0E and $0F.

In your example above you must use the command "save test $7F63 $7FFF $0F". You can verify the result with the db-command, which should give the same result: "db -p $0F $7F63 $9D".

von Dennis Kuschel - am 09.12.2015 12:48
Hi Dennis,

your described way worked fantastic and now I think I've understood the "Memory-Thing". ;)

Thank you!

von Robin Tönniges - am 11.12.2015 19:30
Again hi Dennis ;)

I have a little question about the Screen-Keyboard switching.

Couse sometimes I prefer to use the TTY and sometimes the VGA I "hacked" the kmain.asm and now I use the I/O Port on the Multi IO Unit to select the Console with jumpers.

No Jumper means VGA and a jumper on Port 0 means TTY.

Now I want to make a third option:
A jumper on Port 1 should select VGA and TTY Keyboard (CON_DISP_SCREEN+CON_KEYB_TTY wich is declared as CONSOLE_EMU).

Unfortunately this combination doesn't work.
The CPU always uses the hardware keyboard until I also uses "CON_DISP_TTY".

Is there an automatic switch to the hardware keyboard every time the VGA is in use?
And if so can you give me a hint to disable it? :)

Thank you!

von Robin Tönniges - am 07.02.2016 16:14
Found it by myself :xcool:

I have commented the 2 lines in "_scon11" out.

_scon11 CLA
;AND #00Fh
JMP _setkeyb1

von Robin Tönniges - am 07.02.2016 18:00
Hi Robin,
that was also my solution that I just wanted to tell you ;-)
But I'm not sure about the possible side-effects with existing MyCPU software.

von Dennis Kuschel - am 08.02.2016 13:55

Loading a system library from C-program

Hi Dennis,

I have al little questing regarding the use of system librarys from a c-program..

In the source of the compiler I've found "loadLibrary" and "libCall".
The "loadLibrary" function seems to work but I have really no idea how to use the "libCall" function.
How have the "paramStruct" have to look like?

Hope you can help :confused:

von Robin Tönniges - am 18.04.2017 17:55

Re: Loading a system library from C-program

Hi Robin,

for your information, the loadLibrary and libCall - functions have nothing to do with the assembler kernel routines KERN_LIBSELECT and KERN_LIBCALL. If you whish to use these KERN_xxx -functions you have to use the C-function kcall():

void __fastcall__ kcall(unsigned kvaddr, char *accu, char *xreg, char *yreg, char *flags);
/* calls a kernel function via the kernel vector table (kvaddr == KERN_xxx) */

Here is the answer to your original question:
The format of "paramStruct" is defined by yourself. You can pass any data you want to the function. But you have to set the parameter "structsize" to the size (in bytes) of your "paramStruct".

The libCall-function is really special. The C-runtime-environment knows some extra kind of libraries. A C-library program is a C-program that gets also loaded into the memory area 0x8000-0xFFFF, but starts always at address 0x8000 with its file-header and C-entry-point. When the library gets loaded into memory by calling "loadLibrary", it registers itself to the system by calling "installLibrary". Then you can use "libCall" to call into this library, which will then call the handler-function that was registered with the handler-parameter of the installLibrary-function.
This mechanism allows us to write C-programs that are much larger than 32kb. The big C-program is splitted into smaller parts (up to 32kb) which are called "libraries". These libraries are then called by the main program function. I use this mechanism for the contiki OS. The whole OS kernel fits into one 32kb page. Each application program you open (webbrowser, calculator, etc) gets loaded into a separate 32kb page. The contiki kernel has a main loop that calls periodically all application modules, which in turn call library functions in the contiki kernel.

von Dennis Kuschel - am 19.04.2017 18:37
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.