Name | Stack effect | Operation | Operation after a b ? |
Operation after a 0? |
ASM |
---|---|---|---|---|---|
if |
( -- ) |
if zero flag = 0 | if a != b | if a | beq ... |
=if |
( -- ) |
if zero flag = 1 | if a == b | if !a | bne ... |
+if |
( -- ) |
if negative flag = 0 | if (i16)a - (i16)b >= 0 | if (i16)a >= 0 | bmi ... |
-if |
( -- ) |
if negative flag = 1 | if (i16)a - (i16)b < 0 | if (i16)a < 0 | bpl ... |
vif |
( -- ) |
if overflow flag = 0 | n/a | n/a | bvs ... |
^if |
( -- ) |
if overflow flag = 1 | n/a | n/a | bvc ... |
<if |
( -- ) |
if carry flag = 0 | if (u16)a < (u16)b | if false | bcs ... |
>if |
( -- ) |
if carry flag = 1 | if |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
daiyon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 constant nil | |
: cons ( car cdr -- list ) here >r swap , , r> ; | |
: list ( x... #x -- list ) nil swap 0 ?do cons loop ; | |
: list: ( x... #x "name" -- ) list constant ; | |
: car ( list -- car ) @ ; | |
: car! ( car list -- ) ! ; | |
: cdr ( list -- cdr ) cell+ @ ; | |
: cdr! ( cdr list -- ) cell+ ! ; | |
: list. ( list -- ) begin ?dup while dup car . cdr repeat ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reset: | |
; initialize everything... | |
main: | |
; update game state... | |
; process sprites in a copy of OAM stored in WRAM... | |
; other stuff... | |
inc ReadyFlag ; signal that we're done processing for this frame | |
spin: | |
lda ReadyFlag ; wait until flag is cleared by NMI routine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zero: | |
.db $00 | |
; assuming A is 8-bit, X/Y are 16-bit | |
clear_wram: | |
; From fixed CPU address to IO register, | |
; transfer unit is one byte | |
lda #%00001000 | |
sta DMAP0 ; $4300 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use nfmt::Nfmt; | |
fn main() { | |
println!("{}", number(25252)); // 25,252 | |
println!("{}", number(-500)); // -500 | |
println!("{}", cents(1234567890)); // $12,345,678.90 | |
println!("{}", cents(-200000)); // ($2,000.00) | |
println!("{}", hex(32768)); // 0x8000 | |
println!("{}", hex(!0)); // 0xFFFFFFFFFFFFFFFF | |
println!("{}", yen(573765)); // 57万3765円 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#define NFMT_BUF_LEN 32 | |
const char nfmt_set[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
char nfmt_base; | |
char nfmt_buf[NFMT_BUF_LEN+1] = {0}; | |
char* nfmt_ptr; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct SingleCursor { | |
cursor: u16, | |
mask: u16 | |
} | |
impl SingleCursor { | |
pub fn new(offset: u16, mask: u16) -> SingleCursor { | |
SingleCursor { | |
cursor: offset, | |
mask: mask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
crayonforth source code block format | |
each block is 256 dwords (1024 bytes), stored little-endian | |
31...24 23...16 15...8 7...0 | |
____0ttt aaaaaabb bbbbcccc ccdddddd word | |
____0000 aaaaaabb bbbbcccc ccdddddd extension of previous word | |
__ux1ttt ________ hhhhhhhh llllllll number | |
____1111 ________ ________ ________ end of data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
word = 2 bytes | |
0x10000 words (128 KB) of ram | |
addresses are words rather than bytes | |
0000-7fff generally contains forth dictionary and thus isn't usually swapped out | |
words are big endian | |
rom is split into 0x2000-word (16 KB) banks | |
maximum rom size is 0x8000 banks (512 MB) |
NewerOlder