Assembly language coding: Create a C program that includes inline assembly code.
ID: 3791112 • Letter: A
Question
Assembly language coding:
Create a C program that includes inline assembly code. The code should do the following:
Query the user for a 32-bit integer, saving the integer into an appropriate C variable. Use assembly code to copy the value into another C variable.
Query the user for a 16-bit variable saving the value into an appropriate C variable. Use assembly code to copy the value into another 16-bit C variable.
Query the user for an 8-bit character saving the value into an appropriate C variable. Use assembly code to copy the value into another 8-bit variable.
Copy the 8-bit value entered in step 3 into the lower 8-bit portion of the copied-to variable used in step 1 (using assembly).
Print the results of each of the above steps (using printf in your C code). I tried to do it but my code doesnt work at the end, here is what I did:
Module Mame: 5cc Assembly Language Intro Nanber Enter variable include ase is 128 Died a 16 nunber pied typed a 4 .A B 62 nunbor ,62 entry three into the bottoa g bits of copy one resales 62 62. int main print Scan print prin shor print Scan asm mov ax, entry mov copy 2, ax printf (Number typed was d", entry 2); printf ("InCopied variable is:%d", copy 2); char entry 3, copy 3 printf ("InP enter a 8 bit number.") lease scanf ("%d" Sentry3 mov ah, entry 3 mov copy 3, ah printf(Number typed was: entry 3); printf ncopied variable is:xd copy 3); asm mov eax, copy 1 mov al, entry 3 mov copyl, eax printf ("In Moving entry three into the bottom 8 bits of copy one results in: d", copyl) return 0 Debug En 2015 Run TimeExplanation / Answer
#include <stdio.h>
int main(void) {
long int a;
long int c;
int n,m;
char x,y;
printf("enter 32-bitvalue");
scanf("%ld",&a);
printf("%ld",a);
printf("enter 16 bit value");
scanf("%d",&n);
printf("enter 8-bit character");
scanf("%c",&x);
asm {
mov ax,a
mov c,ax
mov nx,n
mov m,nx
mov xx,x
mov y,xx
}
printf("%ld,c");
printf("%d",n);
printf("%c",y)
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.