It is currently Mon Sep 16, 2019 7:03 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Tue Feb 19, 2019 7:08 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21591
Location: NE Indiana, USA (NTSC)
bleubleu wrote:
  • $0e = reads argument 0 passed from the engine, puts in variable slot $01 (i have 32 variable slots). Note that the compiler detected we never access the second argument, so it ignores it. Minor optimization.
  • $05 = equality comparison. Compares whatever is in variable $01 (what we just read) to constant $02 (when the minus bit, $80, is set, it means that its not a variable, but a constant stored in a table somewhere else. Whenever I encounter an hardcoded constant at compile-time, I look to see if I've seen it before and add it to that table if its new. Constants like "0" comes back quite often, so this is efficient).
  • $0a = jump to the location indicated (10, which is the end) if the last test condition was false. My conditional statements are optimized for "ORs of ANDs" (or "Disjunctive normal form" if you want to sound pretentious).
  • $13 = calls an engine function (engine function $05 is "set_timer") that takes a single argument and puts in in "r0" (a zero page variable in my engine), which is the constant table at location $0a.
  • $1a = end.

One thing that tripped me up while reading your "assembly language" in the comments to the right was that most architectures' equality comparison behaves as != instead of ==: a subtraction that is true if they are different or false if not. That way, the interpreter can use the same logic for compare and subtract.

_________________
Pin Eight | Twitter | GitHub | Patreon


Top
 Profile  
 
PostPosted: Tue Feb 19, 2019 7:51 pm 
Offline

Joined: Tue Aug 28, 2018 8:54 am
Posts: 145
Location: Edmonton, Canada
bleubleu wrote:
I hope this example can make it clear how easy it is to output this king of bytecode as you parse. Interpreting this is super easy, simple jump table, and a 32-byte array for your "RAM".


It does well, thank you.


Top
 Profile  
 
PostPosted: Tue Feb 19, 2019 8:05 pm 
Offline

Joined: Wed Apr 04, 2018 7:29 pm
Posts: 65
Location: Montreal, Canada
tepples wrote:
One thing that tripped me up while reading your "assembly language" in the comments to the right was that most architectures' equality comparison behaves as != instead of ==: a subtraction that is true if they are different or false if not. That way, the interpreter can use the same logic for compare and subtract.


I see your point. But I really made it up as I went along. :) There was no masterplan, I didn't try to copy any existing architecture really.

Also, reusing the same opcodes for multiple things wasnt much of a concern. I favored large and very specific op-code that do a lot of things, as opposed to micro-ops that can be reused. The idea was to keep the bytecode compact, and have the ASM code be quite efficient. This mean that I probably have a lot more code in my interpreter, but that's ok.

-Mat


Top
 Profile  
 
PostPosted: Tue Jun 11, 2019 11:42 am 
Offline
User avatar

Joined: Thu Jul 05, 2018 3:21 pm
Posts: 8
Location: Milwaukee WI
WOW,

This looks absolutely fantastic. I love the art style, the black outlines, the blinking eyes on the sprite, shadows, color palettes. So many nice visual touches. Very impressive :)

Are you looking for music by chance?

_________________
https://soundcloud.com/user-634230995-350638590/sets/nes-music-highlights


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group