Created
January 31, 2015 23:04
-
-
Save jacobmischka/8ec2d696265712e3aa22 to your computer and use it in GitHub Desktop.
stack
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
/* --- Stack operations --- */ | |
static void pushb(BYTE val) { | |
Memory_WriteByte((STACK_ADDR | cpu.SP--), val); | |
} | |
static void pushw(WORD val) { | |
BYTE tmp = (BYTE)(val & 0xFF); | |
Memory_WriteByte((STACK_ADDR | cpu.SP--), tmp); | |
tmp = (BYTE)((val & 0xFF00) >> 8); | |
Memory_WriteByte((STACK_ADDR | cpu.SP--), tmp); | |
} | |
static BYTE pullb() { | |
return Memory_ReadByte((STACK_ADDR | ++cpu.SP)); | |
} | |
static WORD pullw() { | |
WORD tmp = (WORD)Memory_ReadByte((STACK_ADDR | ++cpu.SP)); | |
return tmp & (WORD)(Memory_ReadByte((STACK_ADDR | ++cpu.SP)) << 8); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment