Question

In: Computer Science

Write hack assembly language code for eq lt gt

Write hack assembly language code for eq lt gt

Solutions

Expert Solution

Answer :

eq' represents the Equality in Hack Assembly Language

For any two variables x and y, this 'eq' command returns true if x=y and false otherwise.

'lt' represents the less than in Hack Assembly Language

For any two variables x and y, this 'lt' command returns true if x<y and false otherwise.

'gt' represents the greater than in Hack Assembly Language

Let us consider the 'C' Code:

i=3;

j=2;

if(i>j)

printf("%d", i);

Writing this 'C' Code in Hack Assembly Language using 'gt':

push 3

pop i

push 2

pop j

gt

push i

Let us consider the 'C' Code:

i=2;

j=3;

if(i<j)

printf("%d", j);

Writing this 'C' Code in Hack Assembly language using 'lt':

push 2

pop i

push 3

pop j

lt

push j

Let us consider the 'C' Code:

i=3;

j=3;

if(i==j)

printf("EQUAL");

Writing this 'C' Code in Hack Assembly language using 'eq':

push 3

pop i

push 3

pop j

eq

push constant 0

NOTE : PLEASE GIVE ME UP VOTE. THANK YOU.


Related Solutions

hack assembly language code for eq(equal), gt(greater than) and lt(less than).
hack assembly language code for eq(equal), gt(greater than) and lt(less than).
How to write fill.asm code (hack assembly)
How to write fill.asm code (hack assembly)
Write hack assembly language code for function (declaration) call (a function) return (from a function)
Write hack assembly language code for function (declaration) call (a function) return (from a function)
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code...
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code that transmits a single character and lights the red LED upon receiving that character. The board will "talk" to itself. The green LED should turn on whenever a message is sent and the LCD will display the message being received.
write a assembly language program to convert GRAY to BCD code in 8051
write a assembly language program to convert GRAY to BCD code in 8051
This is to be done with MIPS assembly language. Write MIPS code which is equivalent to...
This is to be done with MIPS assembly language. Write MIPS code which is equivalent to the follow java program: int day = (int)(Math.random() * 7); switch (day) { case 1: System.out.println(“Monday”); break case 2: System.out.println(“Tuesday”); break case 3: System.out.println(“Wednesday”); break case 4: System.out.println(“Thursday”); break case 5: System.out.println(“Friday”); break case 6: System.out.println(“Saturday”); break case 0: System.out.println(“Sunday”); break }
Write a MIPS assembly language to transpose a square integer matrix in code
Write a MIPS assembly language to transpose a square integer matrix in code
Need to code this is assembly language. Using the windows32 framework, write a procedure to read...
Need to code this is assembly language. Using the windows32 framework, write a procedure to read a string and shift each character of the string by one. As an example, if your input string is Abcz, your output should be Bcda. Note that you must test your string for non-alphabetic characters (such as numbers and special characters). If there are non-alphabetic characters, you should terminate your program with an appropriate message. You should display your converted string using the output...
Write an assembly language program code to clear and set bit 7th and 19th in a...
Write an assembly language program code to clear and set bit 7th and 19th in a 32-bit variable called N.
Using x86 assembly language, create a flowchart and write an example of code that will sort...
Using x86 assembly language, create a flowchart and write an example of code that will sort 2 arrays of unsigned doubleword integers in ascending order and output the largest element in each array. Any sorting procedure can be used, but this procedure must be called twice for each array. The first time it is called, the first array should be sorted and the second time it is called, the second array must be sorted. As well as outputting which is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT