cpsc411 / cpsc411-book

The WIP book for CPSC 411
Other
59 stars 7 forks source link

Expose more x64 instructions #76

Open wilbowma opened 2 years ago

wilbowma commented 2 years ago

Looks like some of the IRs unnecessarily restrict some operand combinations. x64 supports lots of additional memory operations than the IRs support. Consider:

main:
    add QWORD [rsp - 0], 0
    add QWORD [rsp - 8], rax
    cmp QWORD [rsp - 0], rax
    jge main

https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:assembly,selection:(endColumn:21,endLineNumber:5,positionColumn:21,positionLineNumber:5,selectionStartColumn:21,selectionStartLineNumber:5,startColumn:21,startLineNumber:5),source:'main:%0A++++mov+QWORD+%5Brsp+-+8%5D,+rax%0A++++add+QWORD+%5Brsp+-+0%5D,+0%0A++++add+QWORD+%5Brsp+-+8%5D,+rax%0A++++cmp+QWORD+%5Brsp+-+0%5D,+rax%0A++++jge+main%0A'),l:'5',n:'0',o:'Assembly+source+%231',t:'0')),k:33.333333333333336,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:nasm21402,filters:(b:'0',binary:'1',commentOnly:'0',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'1',trim:'1'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:assembly,libs:!(),options:'-f+elf64',selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1,tree:'1'),l:'5',n:'0',o:'NASM+2.14.02+(Assembly,+Editor+%231,+Compiler+%231)',t:'0')),k:33.333333333333336,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compiler:1,editor:1,fontScale:14,fontUsePx:'0',wrap:'1'),l:'5',n:'0',o:'Output+of+NASM+2.14.02+(Compiler+%231)',t:'0')),k:33.33333333333333,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4