Question: Hi, so I'm new to assembly language programming and I am not sure how to start converting my C program to assembly language. Any tips
Hi, so I'm new to assembly language programming and I am not sure how to start converting my C program to assembly language.
Any tips and ideas on how to convert, or a guide of what something in C would be translated to in assembly language would be great.
C program:




Instructions:
For this lab, you will write and test an asm program to convert from a decimal number encoded as a string to a hexadecimal number string using the division method: e.g. to convert "21602" to "5462".
Use equ for symbolic constants, the data section for initialized variables, and the bss section for uninitialized variables.
Convert loop control structures (while statements) into labels with goto statements jumping to those labels in the C code, then translate those to asm in a similar way.
Functions that do not return values are called procedures. Create at least 2 procedures in your C code (also no parameters), and then convert those to asm. All you need to do is create a label in the text section, followed by the code and a ret instruction. Use the call instruction to jump to the procedure.
"if" control structures cannot control blocks of code, so these will be converted to cmpinstructions followed by conditional jump instructions.
Use this algorithm:
Divide 21602 by 16, yielding 1350, remainder 2. Divide 1350 by 16, yielding 84, remainder 6. Divide 84 by 16, yielding 5, remainder 4. Divide 5 by 16, yielding 0, remainder 5. The hex form of 21602 is thus 5462.
C source code wrtten to file lab.c #define N 16 char dec[]-"2160e". int decimal-0;goal: set this to 21602 int n; int i; int e; int p; int t; int a0; int nibble ; int loopCounter 0; int quotient; int div; int remain; int b-0; char herTable N 0123456789ABCDEE": int c; char hezNum4:/we know that thf her number will have 4 digits char binN char bin Tablele
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
