projects/07/VMtranslator/CodeWriter.php
/**
     * Push the value of segment[index] onto the stack
     */
Push the value of segment[index] onto the stack
Push the value of segment [ index ] onto the stack
protected function writePushSegment($label, $index)
    {
        $this->writeLine('@' . $index);
        $this->writeLine('D=A       // Store the index value in D');
        $this->writeLine("@$label   // set address to $label");
        $this->writeLine("A=D+M     // set the address to be $label + index");
        $this->writeLine('D=M       // store the push value in D');
        $this->writePush();
    }
protected function writePushSegment ( $ label , $ index ) { $ this -> writeLine ( '@' . $ index ) ; $ this -> writeLine ( 'D=A       // Store the index value in D' ) ; $ this -> writeLine ( " @ $ label    // set address to  $ label " ) ; $ this -> writeLine ( " A=D+M     // set the address to be  $ label  + index " ) ; $ this -> writeLine ( 'D=M       // store the push value in D' ) ; $ this -> writePush ( ) ; }
Push the value of segment[index] onto the stack
Push the value of segment [ index ] onto the stack
// Find where the value is stored.