Menu

FlexxCpu / Blog: Recent posts

I am going to release an new version called 07 rev_D

In this version the main differences will be the following:

1) a new high-level cpu opcode named "BCHK":
Description and syntax:
BCHK , // for example: BCHK R, 0, 9, ADDR : -- Checks the Register if it's within limits (lower,upper) then jumps at address if are valid

A piece of code that uses the instruction BCHK:
~~~
ADDR X , I -- increments Register with another Register
ADDR Y , J -- increments Register with another Register ... read more

Posted by Davide Ug. Lini 2018-07-20

Here is a good hint if you are interested in the simulations of custom-designed virtual cpus

I would like to mention 3 projects that I found on internet and who have made a complete simulation of CPU and they are:
DCPU-16
MyCPU
openCPU

and we do not forget the legendary custom-designed CPU-8 !!!! (this is real CPU and many emulators have been developed)

Well, that's all for now.
I greet you and thank you.

Posted by Davide Ug. Lini 2018-06-20

I just released a new update 07 rev_C

New update 07 rev_C

Differences from previous version 7th rev_B are these:

1) I introduced the new assembly directive EQU, now we can use this syntax: EQU VIDEO, 0x3b800 (for example)
2) I introduced the string argument for the STR instruction, now we can use this syntax: STR STRING1, "Hello world", 0x00
3) I introduced the binary argument for the IMMEDIATE value on any instruction, now we can use this syntax: 0b0011010 (for example)
4) I added a new identifier to add comments inside the code, it is used by many assemblers, this is the syntax: <semi-colon> comment
5) I improved the two macros that manage the operations of the stack of the cpu. I rewritten in order to make more flexible the optimizations on the stack. The most common instructions that operate on the stack have been made faster thanks to these new macros. Also for this purpose I added a new pointer called cpuSTK to accelerate the operations on the stack.
6) New opcodes RORB/ROLB have been added to the cpu simulation, see the example file "Flexx_Sprite_Mono_Test.asm". They primarily serve to carry out the displacement of n bits from a byte value, by specifying a destination register to retrieve the bits which exceed the limit .
7) I added a new sample file (Flexx_PixelMFont_Test.asm) that illustrates how to define and insert, inside the code, a long sequence of bytes to use to draw a font on the screen in graphical mode monochrome.... read more

Posted by Davide Ug. Lini 2018-06-13

About the target of the executable image

I forgotten to tell you that the FlexxCpu executable is an 32bit image but works great in Windows 64.
Also, the font to be used with this console app is raster 8x12 standard vga. Other fonts work fairly well but the graphics window is not resized.

Posted by Davide Ug. Lini 2018-05-30

I am going to release an optimized version called 07 rev_B Special !

This is the fastest version after I introduced the recent checks on memory addresses to increase the safety of writing into memory of CPU.
Now the simulator has been compiled with option -Ofast of GCC compiler. It is the best optimization that the compiler can generate...
Furthermore the macros that relate the stack operations of the cpu have been optimized to the maximum.
It is the best version also as regards the correction of recent errors.. but it is risky as a dragster !
Stay tuned.
Have fun. ... read more

Posted by Davide Ug. Lini 2018-05-29

I just released new patch 07 rev_A

Differences from previous version 7th rev_00 are these:

1) I hope I have finally solved the problem of the repositioning and resizing of the console window in the center of the screen
2) Eliminated unnecessary macros RDTSC_START/RDTSC_STOP from source code and replaced by __rdtsc() of the GCC compiler
3) Fixed a important bug on loading/saving files assembly inside the integrated editor(!)
4) Removed the external library ConLib because it was not used anymore
5) I added two functions in the external library Conio.c (I hope that they serve..)
6) New opcodes REGS/RSET have been added to the cpu simulation, see the example file "Flexx_For_Next_Test.asm"
7) Some other minor bugs and improvements have been fixed
8) I added the control on the key F1 to enter in the editor, in addition to E and V keys
9) I have reduced the factor that determines the frequency simulated to 3. This should be the frequency closer to the real one.
10) Starting from the prior version (7th rev_00) I replaced the two macros that relate to the management of the stack of the cpu. I rewritten to prevent the stack go to overwrite the video memory or the program code, but now I realized that the previous macro of "6th release rev_C deluxe" version were a bit faster. I have analyzed the assembly code produced by the GCC compiler. ... read more

Posted by Davide Ug. Lini 2018-05-29

I just released version 07 of FlexxCpu.

Main differences from latest 06 version are these:

1) now all video modes are been mapped in ram[] buffer instead of use a separate buffer[]
2) mode number 12 of the 320x200 graphic resolution has been restored to 11
3) new graphic resolution 640x400 monochrome can be used by setting the video mode to 12
4) GDI operations have been accelerated, now is only set the buffer of the bitmap instead of create continuously the bitmaps on screen
5) some bugs during the loading/saving of the file assembly has been fixed
6) base macros of read/write operations on simulated memory have been rewritten
7) new opcodes that access the cpu memory were added, including also for/next and ijpn opcodes that are used to perform loops like basic
8) many example files are been modified in according to new opcodes
9) most of existing opcodes have been optimized in speed... read more

Posted by Davide Ug. Lini 2018-05-25

How add new cpu opcodes at source code level

To add new cpu opcodes we need only to change two files: simulate.h and simulate.c
So we have to proceed with these steps:

(1) modify the file simulate.h

Open this file and go down at line under the comment //New Opcodes and add your new opcode ABC as last and before the end_ops constant.
For example:
//New Opcodes
MDIV , // MDIV R, 10, M : (S>D) -- Calc Modulus and Division putting them into destination Registers
STX , // STX 0xFF , M : (S>D) -- Store immed. value into contents of [MemoryAddress] pointed by Register
+ ABC , // short description ... read more

Posted by Davide Ug. Lini 2018-05-20

I have just released an update called 06 rev_C deluxe !!

Finally I have just completed the last revision!
No new features will be added in the future, except for bugs or new cpu opcodes..
This version provide a improvement to the environment of simulator..
I suggest to download this version.

Main differences from release 06 rev_B are these:
1) the aspect ratio of all graphic resolutions has been fixed, now all pixels are squares.
2) new high-resolution graphic 640x400 24bit.
3) text mode has been expanded up to 34 vertical lines.
4) the history debugger has been expanded to remember the twice of cpu opcodes.
5) the address of video memory has changed to 0x3B800 (first it was 0xB800)
6) mode number 11 of the 320x200 graphic resolution has been changed to 12.
7) 512K of memory ram.... read more

Posted by Davide Ug. Lini 2018-05-19

About the aspect ratio of the graphics mode

The aspect ratio of 320x200 resolution is not correct.
Probably I will make a patch.

Posted by Davide Ug. Lini 2018-05-18

Version 06 rev_B released: adding 320x200 graphics mode with 24 bit colors

  • Increased system memory to 128k.
  • Adding 320x200 graphics mode with 24 bit colors.

Try to look in the example file "Flexx_PixelColor_Test.asm".
To change the video mode you need to write these instructions:

// switch to graphic mode: 320x200 pixels with 24 bit colors
SET V, 13 ----> // 11=monochrome mode 13=color mode
OUTP 0x10, V

Well, that's all for now.
I greet you and thank you.

Posted by Davide Ug. Lini 2018-05-18

FlexxCpu memory map 64k

Posted by Davide Ug. Lini 2018-05-16

New version 06 rev_A released: adding PIXELs, last frontier!

In this release I added the routines to write pixels!!
Try to look in the example file "Flexx_PixelMono_Test.asm".

To change the video mode you need to write these instructions:

// switch to graphic mode
SET V, 11 ----> // 11=monochrome mode 13=color mode (NOT YET AVAILABLE)
OUTP 0x10, V

Well, that's all for now.
I greet you and thank you.

Posted by Davide Ug. Lini 2018-05-12

How debug the assembly code from first address memory

To debug the assembly code starting from first address memory, We need to do these steps:

(1) pause the simulator with "s" or "p" key
(2) reset the cpu with "r" key
(3) enter in debug mode pressing the "d" key..
(4) activate the monitor pressing the "m" key..
(5) press <enter> key as first key
(6) press <enter> or <space> key, to execute an instruction at time. </space></enter></enter>

To advance the debugging for a short time:
press "d" key to momentarily disable the debugger and subsequently press again the button "d".... read more

Posted by Davide Ug. Lini 2018-05-11

There is an small error in the version 06 that ...

There is an small error in the "main.c" that however does not prevent the correct execution of the simulator.
You can fix by yourself if you want to...

184: //Err --> char * ps = (WORD * )&vid; // video memory pointer
185: //Err --> char * ls = (WORD * )&vbtmp; // line buffer pointer

184: //Fix --> char * ps = (char * )&vid; // video memory pointer
185: //Fix --> char * ls = (char * )&vbtmp; // line buffer pointer... read more

Posted by Davide Ug. Lini 2018-05-08

I have just released version 06 of FlexxCpu.

The main difference with respect to the version 05_rev_F1 is the simulation of the color screen (!)
Try the asm example "Flexx_ColorMode_Test.asm" included to test the simulation of the color screen.
To change the video mode you need to write these instructions:
// switch to color mode
SET V, 3 ----> // 2=monochrome mode 3=color mode
OUTP 0x10, V
The OUTP opcode has been changed, I have exchanged the first argument (the register) with the second (the port address).
Now, in the simulation of the color screen, the access to video memory occurs at 16 bits instead of 8 as occurs in monochrome mode.
In the configuration file I added a variable that represents the video mode set.
The second difference I introduced is to have added four states into the CPU, this has allowed to reorganize the simulation in a much more efficient way. I also made a slight optimization of code by removing some unused variable (int wRunning).
With this small optimization the main loop of cpu simulation seems to go slightly faster (!)
If you are not interested in the simulation of the color text, I suggest you to download the version 05_rev_F1
that is the best version that has ever released.
Well, that's all..
I greet you and thank you.

Posted by Davide Ug. Lini 2018-05-05

Version 05 rev. F1 released

Another slight improvement!
I suggest to download this version.

Changes in this new release are these:
Fixed some bugs existing in the debugger.
Specifically I fixed some bugs and I added a special check in the core of cpu simulation that allows you to always have control of the keyboard when the simulated code becomes uncontrollable (infite loop, dead code, illegal code, ecc...)
The ability to see the screen update in real time during the debugging of the assembly code, when we press the key <d> to enter in debug mode.
I have introduced the reset of the screen with a random test routines and I added the cleanliness of the video memory.
I corrected an error caused by the key <end> in the text editor.
I added the function delayms(int milliseconds) already present in the conio library..... read more</end></d>

Posted by Davide Ug. Lini 2018-05-03

About the text editor included in the simulator

The text editor included in the simulator is a very trivial editor.
I implemented this editor only to make small changes and to test our code.
The Notepad is always better!!
hi all.

Posted by Davide Ug. Lini 2018-05-02

I have released the version 05 rev. F

This version is a slight improvement.

The compiler now allows to compile the ALS opcode to rename any register!! see the Alias test example.
We suppose to want use the MOV AX,BX syntax: we simply have to write ALS MOV, LDR and then ALS AX,A and ALS BX, B.
Now we can write in our code the MOV AX,BX command !!
One other thing that I changed is the formula to write into memory video because the previous was very coarse.
Previous formula was this: (char)(val|16 * ((char)val<16)) and did not allow to use all 256 ansi chars.
The new formula is this: (BYTE)val|15 * !(val&240)   and it allows to use all 256 ansi chars except those that have the code below 16 because these codes give serious problems of viewing. You can see this effect in the printAscii test example.
Then, I disabled the resetting of global var "simuPause" so that we can reset the cpu and check the debugging of the asm code starting from first address. With this small change we can do this: (1)pause the simulator, (2)reset the cpu and (3)check the debug of our code from first address pressing "d" key..
Finally I made some slight optimizations to some opcodes that read and write in the simulated memory, but these optimizations are things of little importance. and in any case not really increase the speed of the simulator.
Well, that's all..
I greet you and thank you.... read more

Posted by Davide Ug. Lini 2018-05-02

The version 05 rev. E was released

This is a minor update.
There was a problem that was preventing the reading from video memory (0xb800), this error was corrected.
The MOV opcode has been changed with name STM as the opposite to LDM.
I've implemented the reading from the 0x60 input port through the INP opcode, see Flexx_MiniGame_Test.asm
Now we can read the code from keyboard, for example: INP K, 0x60 ---> read the keyboard code into K register
I greet you and thank you.

Posted by Davide Ug. Lini 2018-05-01

FlexxCpu version 05 rev. D released

This is a maintenance release.
The compiler now allows to compile the ALS opcode (alias)... try the test example.
No longer need to use the directive 'NEW' for now, I have them removed everywhere in the sample files.
Now we can write the assembly instruction without " , " after the opcode name, for example:
we can write: "MUL Y , 80" or "MUL , Y , 80" indifferently.
bye

Posted by Davide Ug. Lini 2018-04-30

About FlexxCpu version 05 revision C

This is a very stable release due to fixing last bugs existing in its simulated memory during the
access to CPU registers when exceeding array limits.
Also the Halt opcode has been fixed as well as the execution of illegal opcodes.
Before this version the Halt opcode caused a reset, but it was wrong.
Instead, the illegal-opcode would be better that it would make a cpu reset, for now.
The compiler cannot yet allow to compile the ALS opcode (alias)...
As regards the text editor, it may be that i implements the F3 function key (New-File) and the function "Save-As".
This will be done in the next release..
Well, that's all..

Posted by Davide Ug. Lini 2018-04-29

FlexxCpu version 05 rev. C released

Changes in this new release are these:
Fixed some bugs existing in its simulated memory during the writing in CPU registers when exceeding limits.
Added the viewing of cursor blinking in the text editor.
F9 to choose the theme style. F10 to remove highline in the editor.
Added the possibility to load file directly from inside the editor.
The speed of the simulator is decreased due to the memory controls added to increase
the safety of writing in the simulated memory.

Posted by Davide Ug. Lini 2018-04-28

FlexxCpu version 05 rev. B released

Changes in this new release are these:
Fixed some bugs existing in its simulated memory during the writing in ram, video memory, ecc...
Now the writing in the simulated memory is totally safe except for CPU registers, I am trying to fix it in the next release(!)
Fixed a bug during the viewing of illegal opcode error.
Fixed a bug during the change of the program counter to avoid exceeding the memory limits.
Fixed a bug when writing chars in video memory that in some cases it may lock out the simulator.
Added the ability to change the color of the text editor with the possibility to choose between 10 combinations, press the F9 key.
Added the possibility to change the format of displayed data when the monitor is active.
The simulator now remember the x position of the cursor when re-entering in text editor,
press <c> to save configuration.
The speed of the simulator is decreased due to the memory controls added to increase
the safety of writing into the simulated memory. ... read more</c>

Posted by Davide Ug. Lini 2018-04-27

About to the ConLib library contained in this project

Probably this library will be removed from the project because it is not yet used.

Posted by Davide Ug. Lini 2018-04-25