assembly - machine code instructions for a program -


how put program instruction c = a-b; in machine code instructions? i've been provided op-codes, memory address a=80, b=81, c=82 , program counter = 30 hex. instructions 16 bits long 4bit op-code, 4bit register , 16 bit memory address.

i need know formal way how started. because don't understand lecturer teaches. if can clear direction, confident can without of lecturer.

the mnemonics this:

mov eax, [a] ; move 4 bytes starting @ address eax register sub eax, [b] ; subtract 4 bytes starting @ memory address b eax register mov [c], eax ; move contents of eax register memory address of c 

you substitute in opcodes operations (mov, sub), register address (eax), memory addresses (a, b, c) , and result actual machine instructions. i'm assuming here numbers 32 bit integers, i'm using eax register 32 bits long x86 processor, specifics of register use arbitrary, long it's big enough hold number. mov instruction read many bytes register can hold starting @ memory address provided.

you don't explicitly need program counter example, cpu increments program counter executes each instruction.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -