Author Topic: On-Calc Virtual Processor  (Read 5386 times)

0 Members and 4 Guests are viewing this topic.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
On-Calc Virtual Processor
« on: April 24, 2011, 12:38:30 am »
I have decided, once again, to start up another project... This time it is going to be a virtual processor on the calc. The reason I decided to start this was to give beginners a safe way to play with assembly, get accustomed to hexadecimal and syntax, and to get them used to low level stuff. For that reason, I wanted some input about what instructions should be supported. I am using BatLib extensively, so I have access to some resources (like for reading/writing bytes and the emulated LCD and whatnot). At the moment, I have this stuff finished:

-The memory map consists of 4 memory banks of 256 bytes each (1024 bytes, total)
-There are 16 pages in all making a total of 4096 bytes of memory
-There is a PC register (functioning)
-There is an SP register (not used yet)
-There are registers a,b,c,d,e,h,l,f as in Z80 assembly
-I have loads all of the loads working in the form of ld reg8,reg8 where reg8 can be a,b,c,d,e,h,l, or (hl)
-There is an emulated LCD port that is 32x32
-There are four emulated ports for memory mapping

The emulated LCD port cannot be written to, yet (there isn't an in/out instruction), but here is how it works:
-Load a byte into the port (port 0). This is an MSB
-Load another byte and this becomes the LSB. At this point, the LCD "refreshes" using the MSB and LSB as an address in memory for where the LCD data is.

Unfortunately, a 32x32 screen means that half of a page is used up (128 bytes), but at least you don't have to write every byte of an image to a port x.x

So anyway, here is what I plan to add soon:
add / adc
sub / sbc
and / xor
or / compare (really I didn't want to type "cp")
jr / jp / call / ret
ld (address),reg8 / ld reg8,(address)
ld reg8,immediate / (in/out/bit/extended/ex de,hl/ex sp,hl /ex pc,hl
push / pop

port 5- key port: write is the same as the actual key port, read is the same. The value refreshes after the next instruction finishes.


So does anybody have any suggestions or ideas?!




Here is a screeny, too. When you notice that I use these commands:
dim(14,Str2,0,15
dim(14,Str2,1,1
dim(14,Str2,2,49
dim(14,Str2,3,255
...
Str2 has the name of the hacked string and I am writing to the first few bytes 0F0131FFFFFFFFF...
That translates to:
Code: [Select]
ld b,(hl)
ld a,b
ld l,a
So the first time it was run, hl was 0, so it read byte 0 (0F) and stored it to b. Then it loaded b into a and then it loaded a into l. The next time it was run, hl was 000Fh and byte 15 was FFh, so FF was loaded into b, b into a, and a into l. The next time it was run, hl=00FFh and byte 255 was 00h, so 0 was loaded into b, then a, then l and it all starts all over again.

As a note, I could have just done 37h and it would have done ld l,(hl), but I needed an example XD

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: On-Calc Virtual Processor
« Reply #1 on: April 24, 2011, 12:41:27 am »
Looks awesome, Xeda!
* Freyaday can't wait.
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: On-Calc Virtual Processor
« Reply #2 on: April 24, 2011, 12:44:13 am »
Yeah, the whole point to it is that as long as you don't have any apps that interfere with BatLib, it won't crash. This will give freedom to users from the worry of crashing their calc. Also, another note is that the final product will be faster, but while I am beta testing it, I need to view the registers at every step. I also plan to make an assembler and hex editor for it to make programming it easier XD

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: On-Calc Virtual Processor
« Reply #3 on: April 24, 2011, 12:44:56 am »
Are the token hooks for Axe safe?
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: On-Calc Virtual Processor
« Reply #4 on: April 24, 2011, 12:51:17 am »
The token hooks should be, but Axe messes with other RAM areas for BatLib. I am trying to see if it will cause a crash or not, but for some reason, my version of Axe isn't creating the token hook ???

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: On-Calc Virtual Processor
« Reply #5 on: April 24, 2011, 12:53:38 am »
Maybe BatLib is uninstalling the hook?
« Last Edit: April 24, 2011, 12:53:58 am by Freyaday »
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: On-Calc Virtual Processor
« Reply #6 on: April 24, 2011, 12:57:03 am »
I don't know ... I tried clearing my RAM first and it doesn't work. I have Axe 0.5.1 so does anybody know how I can install that token hook?

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: On-Calc Virtual Processor
« Reply #7 on: April 24, 2011, 12:58:42 am »
Does the program in question have an Axe header on it?
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: On-Calc Virtual Processor
« Reply #8 on: April 24, 2011, 01:08:51 am »
Okay, I finally managed to get it to modify the tokens... and BatLib seems to overwrite the token hook ability of Axe. I will say, though, that before, Axe and BatLib absolutely did not work and would cause a crash, but now all it does is cause some commands in BatLib to not work properly.

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: On-Calc Virtual Processor
« Reply #9 on: April 24, 2011, 01:09:55 am »
Well, slight nonfunctionality is better than crashing. Why was it crashing, though?
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: On-Calc Virtual Processor
« Reply #10 on: April 24, 2011, 01:15:11 am »
There are pieces of RAM that BatLib uses for executing code, pointers to code, and storing vital information and Axe was modifying that. I then fixed up my code a little more so that that wouldn't occur, but they do still interfere with each other D:

I would have BatLib reinstall the code if it was practical, but that could really slow things down. As it is, I added a command specifically because of this problem to BatLib. As long as BatLib is installed, you can run command 100 to reinstall the vital RAM in case you know other programs are tampering with the same RAM XD

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: On-Calc Virtual Processor
« Reply #11 on: April 24, 2011, 01:17:55 am »
So will BatLib be necessary to run this virtual processor?
* Freyaday just realized Blaid Drugg is machine code for a virtual processor. Freyaday doesn't even know Assembly.
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: On-Calc Virtual Processor
« Reply #12 on: April 24, 2011, 01:19:45 am »
Yes, BatLib is necessary for it... I might make one that is in all assembly at some point that won't rely on an App, but for now it is a lot easier /faster /smaller to program in BASIC.

Offline ralphdspam

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 841
  • Rating: +38/-1
  • My name is actually Matt.
    • View Profile
Re: On-Calc Virtual Processor
« Reply #13 on: April 26, 2011, 10:13:42 pm »
Looks great, Zeda!  :)

Is that Break support I see?
ld a, 0
ld a, a

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: On-Calc Virtual Processor
« Reply #14 on: April 26, 2011, 10:22:24 pm »
Kind of XD It is only a pause, but I think I will add in later a special key to let the user step through emulation. I think I will also display the hex code or disassembly below the "LCD."

Also, as an update... I have added these instructions:
add a,reg8
adc a,reg8
sub a,reg8
sbc a,reg8

Once I add in relative jumping and port reading/writing, then I will be off to a good start! Also, as another note, reg8 includes (hl), like the Z80 :)