[go: up one dir, main page]

0% found this document useful (0 votes)
60 views2 pages

Q) Write A Program in C & Convert Into Assembly Language and Then Into

The document provides instructions for an assignment to write a C program to print a multiplication table for a user-input number, convert it to assembly language, and then to machine language using an provided opcode table. The C program prompts the user for a number, initializes a counter, and uses a while loop to repeatedly add the input number to a running total and print the result until the counter reaches 10. The summary converts the C code to assembly language instructions and then machine language opcodes.

Uploaded by

Rashmi Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views2 pages

Q) Write A Program in C & Convert Into Assembly Language and Then Into

The document provides instructions for an assignment to write a C program to print a multiplication table for a user-input number, convert it to assembly language, and then to machine language using an provided opcode table. The C program prompts the user for a number, initializes a counter, and uses a while loop to repeatedly add the input number to a running total and print the result until the counter reaches 10. The summary converts the C code to assembly language instructions and then machine language opcodes.

Uploaded by

Rashmi Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

OS Assignment No-1

F.Y MCA
Shraddha Sawant Desai

Q] Write a program in C & convert into assembly language and then into
machine language using following instructions provided in Opcode table.

Binary Operations
Opcode
0000 LOADX
0001 STORE X
0010 CLEAR X
0011 ADD X
0100 INCREMENT X
0101 SUBTRACT X
0110 DECREMENT X
0111 COMPARE X
1000 JUMP X
1001 JUMPGT X
1010 JUMPEQ X
1011 JUMPLT X
1100 JUMPNEQ X
1101 IN X
1110 OUT X
1111 HALT

Answer-
>>Program of printing multiplication table of number given by user in C.

Code:

void main()

{ int a, r, count=0;

printf(“Enter a number.”);

scanf(“%d”,a);

r=a;

while(count<=10)

{ a=a+r;

count++;

printf(a);

[Type text] Page 1


OS Assignment No-1
F.Y MCA
Shraddha Sawant Desai

>>Conversion into assembly language.

IN a

1. LOAD a
2. STORE r
3. CLEAR count
4. LOAD ten
5. COMPARE count
6. JUMPGT line 13
7. OUT a
8. LOAD a
9. ADD r
10. STORE a
11. INCREMENT count
12. JUMP line 4
13. HALT

>>Conversion into Machine language.

LOAD a 000000000000 0000000000001101


STORE r 000000000001 0001000000001110
CLEAR count 000000000010 0010000000001111
LOAD ten 000000000011 0000000000010000
COMPARE count 000000000100 0111000000001111
JUMPGT line 13 000000000101 1001000000001100
OUT a 000000000110 1110000000001101
LOAD a 000000000111 0000000000001101
ADD r 000000001000 0011000000001110
STORE a 000000001001 0001000000001101
INCREMENT 000000001010 0100000000001111
count
JUMP line 4 000000001011 1000000000000011
HALT 000000001100 1111000000000000
a 000000001101 0000000000000000
r 000000001110 0000000000000000
count 000000001111 0000000000000000
ten 000000010000 0000000000001010

[Type text] Page 2

You might also like