Git Product home page Git Product logo

js-y86-64's People

Contributors

boginw avatar lam2mo avatar laurence6 avatar orel33 avatar ssm951 avatar vaguilar avatar xsznix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

js-y86-64's Issues

str.indexOf is not a function

y64 code:

# Execution begins at address 0
    .pos 0
    irmovq stack, %rsp      # Set up stack pointer
    call main       # Execute main program
    halt            # Terminate program

f0:
        irmovq $0x10, %rax
        ret
f1:
        irmovq $0x11, %rax
        ret
f2:
        irmovq $0x12, %rax
        ret
f3:
        irmovq $0x13, %rax
        ret
f4:
        irmovq $0x14, %rax
        ret

jtable:
    .quad f0
    .quad f1
    .quad f2
    .quad f3
    .quad f4

jmp_to_n:
    pushq %rdi
    mrmovq -3(%rsp), %rbx # rbx = 8 * rdi
    mrmovq jtable(%rbx), %rbx
    irmovq 2, %r10
    rmmovq %rbx, real_jmp(%r10) # *real_jmp = %rbx
real_jmp:
    jmp jtable
    
main:
    irmovq $0x2,%rdi
    call jmp_to_n
    ret

# Stack starts here and grows to lower addresses
    .pos 0x200
stack:

behavior:
image

XOR/AND not clearing out the OF flag when needed

According to the CS:APP book 3rd edition, section 3.6.1, it is stated "For the logical operations, such as XOR, the carry and overflow flags are set to zero". To my understanding, other than not having the carry flag, y86 should have the same behavior on condition codes as x86.

Currently, if you do something like an addq that sets the overflow flag, the xorq instruction does not clear it. This is an easy fix in the instr.js file, line 81, where you can first set OF to zero before going into the switch statement.

Here is an example of a .ys code that reflects the discrepancy with the book stated above:

irmovq scratch, %rax
rrmovq %rax, %rbx
rmmovq %rbx, 0x8(%rax)
irmovq 0x9, %rax
irmovq 0x7fffffffffffffff, %rbx
addq %rbx, %rax
xorq %rax, %rax 
halt

scratch:

Behavior of conditional jump

The description on wiki page says jge "jumps to Dest if ~(SF^OF)", but the following code has different behavior with this description.

irmovq $0x8000000000000000, %rcx
irmovq $0x2, %rdx
subq %rdx, %rcx

# SF=0, OF=1
jge B2

B1:
irmovq $0xab, %rax
halt

B2:
irmovq $0xcd, %rax
halt

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.