Programming Assignment 2 - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

Programming Assignment 2

Description:

Find out what this instruction is about (using the opcodes table) OPCODE = 1 Byte ... The 'z' refers to zero, which is the ASCII code for the null character. ... – PowerPoint PPT presentation

Number of Views:20
Avg rating:3.0/5.0
Slides: 7
Provided by: pani4
Category:

less

Transcript and Presenter's Notes

Title: Programming Assignment 2


1
Programming Assignment 2
  • Virtual Machine Implementation

2
Goals
  • Implement a Java-like virtual machine (you dont
    really have to know anything about the Java VM)
  • Stack based machine
  • Fetch instructions and execute them
  • Return top of stack (if the program returns)

3
Process
  • Read instructions from memory one-by-one
  • Interpret them
  • Find out what this instruction is about (using
    the opcodes table)
  • OPCODE 1 Byte
  • Read the operands (if available)
  • OPERANDS 1-4 Bytes
  • Update the PC accordingly
  • Call appropriate procedure to handle the
    instruction.

4
General info on data segment
  • .ascii str
  • This stores str in memory, but without a null
    terminator.
  • .asciiz str
  • This stores str in memory, but with a null
    terminator. The "z" refers to zero, which is the
    ASCII code for the null character. This is how
    C-style strings are stored.
  • .byte b1, ..., bn
  • Store n bytes contiguously in memory (you get to
    pick n).
  • .halfword h1, ..., hn
  • Store n 16-bit halfwords contiguously in memory
    (you get to pick n).
  • .word w1, ..., wn
  • Store n 32-bit words contiguously in memory (you
    get to pick n).
  • .space numBytes
  • Reserves numBytes of space in memory.

5
Keep in mind
  • Check for the validity of opcodes
  • Make sure you dont go out of bounds
  • In stack
  • In variables memory

6
Stack implementation
  • Example in class
Write a Comment
User Comments (0)
About PowerShow.com