Saturday 2 December 2017

Write a program in VVM Assembler which will divide two numbers, i.e. divide number A by number B

write a program in vvm which will divide two numbers i.e divide number A by number B if B>A or B=0 or B is negative then the program should prompt for another input for B<A, if A=0 then result should be zero and if a>b it should show result.
in //input for a sto 90 //store a at 90 in //input for b sto 91 //store b at 91 lda 91 // load b (91) brz 07 // if b = 0 read go for new input brp 08 //if b is negative go for new input jmp 02 // jump for b new input lda 90 // load a brz 30 //if a=0 then show directly zero lda 90 // load 90 value sub 91 // a-b brp 14 //if b>a go for new input jmp 02 //jump for b<a lda 90 //load 90 brz 30 //if 90 value = 0 then jump 30 sub 91 //subtract values 90-91 sto 90 //store at 90 position brp 20 //if 90 value postive or zero then jump 20 jmp 30 //jump to line no 30 *20 //line 20 start lda 92 //load 92 add 93 //add 92+93 sto 92 //store the added value at 92 location jmp 14 //jump 14 line no *30 //line 30 starts lda 92 //load 92 out //output result hlt //terminated program *90 //90 line number start
dat 000  //90 location there is 0 hardcoded
dat 000  //91 location there is 0 hardcoded
dat 000  //92 location there is 0 hardcoded
dat 001  //93 location there is 1 hardcoded

No comments:

Post a Comment