Code Monkey home page Code Monkey logo

y86-64-virtual-machine's Introduction

Y86-64 Virtual Machine

源于《深入理解计算机系统》by Randal E. Bryant, David R.O' Hallaron 第四章处理器体系结构篇x86-64的简易版y86-64

feature 1 汇编码->机器码

使用示例 1

irmovq $15,%rbx
rrmovq %rbx,%rcx
rmmovq %rcx,-3(%rbx)
addq %rbx,%rcx
命令 python y86_64.py testCode.txt output.txt
输出结果
30f30f0000000000000020314013fdffffffffffffff6031
编译器命令提示

使用示例 2

irmovq $-4, %rbx
irmovq $10, %rax
subq %rbx, %rax
halt
输出结果
30f3fcffffffffffffff30f00a00000000000000613000

feature 2 机器码->虚拟机执行

使用示例 3

利用脚本testVM.py,其中的机器码由示例2编译生成
from y86_64 import y86_64_vitualMachine
a = y86_64_vitualMachine(2000)
b = '30f3fcffffffffffffff30f00a00000000000000613000'
a.runCommands(b)
测试得到输出结果:
运行结束!

寄存器状态:
%rax 0e00000000000000
%rbx fcffffffffffffff
%rcx 0000000000000000
%rdx 0000000000000000
%rsi 0000000000000000
%rdi 0000000000000000
%rsp 0000000000000000
%rbp 0000000000000000
%r8 0000000000000000
%r9 0000000000000000
%r10 0000000000000000
%r11 0000000000000000
%r12 0000000000000000
%r13 0000000000000000
%r14 0000000000000000
%pc 1700000000000000
可以由示例2汇编语法得到,最终%rax=10-(-4)=14,转换为十六进制为0xe,小端表示则为0e0000000000000000,而%rbx为-4的小端表示,也就是fcffffffffffffff,整个指令执行到pc为23结束。

y86-64-virtual-machine's People

Contributors

xynnn007 avatar

Watchers

James Cloos avatar

Forkers

vishwateja12

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.