Jump to content
IGNORED

Atari_Ace's Blog - Dealer Demo, part 6: Less is More


RSS Bot

Recommended Posts

We resume our disassembly of the Dealer Demo and find the next four Forth words, 0= and 0<, and then unexpectedly U< and <.

fig-FORTH  1.4V0 65535 U< .1  oK
The problem with defining U< with ": U< - 0< ;" is that when the difference is more than $7FFF, 0< is going to give the wrong answer, as it expresses a signed comparison. So it makes sense to make U< a primitive to avoid having to write a complicated implementation in Forth itself (as APX Forth did, which is probably 20x slower, and consumes more space to implement to boot).
0A1F: 21 0A     LESS    .WORD *+20A21: 38                SEC0A22: B5 02             LDA 2,X0A24: F5 00             SBC 0,X0A26: B5 03             LDA 3,X0A28: F5 01             SBC 1,X0A2A: 94 03             STY 3,X0A2C: 50 02             BVC L12580A2E: 49 80             EOR #$800A30: 10 01     L1258   BPL L12600A32: C8                INY0A33: 94 02     L1260   STY 2,X0A35: 4C EE 03          JMP POP
Now the Dealer Demo version:
http://www.6502.org/tutorials/compare_beyond.html. Section 4.3 in particular discusses the technique used here.

The next dozen words or so exactly match the implementation in the fig-Forth listing, so they don't merit much detailed discussion. They implement some arithmetic (+, -, D+, D-), some stack primitives (OVER, DROP, SWAP, DUP), some read/write primitives (@, C@, !, C!) and a couple of miscellaneous commands (+! and TOGGLE).
 
Attached File(s)


http://atariage.com/forums/blog/734/entry-15014-dealer-demo-part-6-less-is-more/
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...