Difference between revisions of "Assembly Language Division"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
Line 1: Line 1:
      INP R0,2
+
1      INP R0,2
      INP R1,2
+
2      INP R1,2
      MOV R2,#0
+
3      MOV R2,#0
  LOOP: SUB R0,R0,R1
+
  4 LOOP:SUB R0,R0,R1
      ADD R2,R2,#1
+
5      ADD R2,R2,#1
      CMP R0,#0
+
6      CMP R0,#0
      BGT LOOP
+
7      BGT LOOP
      BEQ END
+
8      BEQ END
      SUB R2,R2,#1
+
9      SUB R2,R2,#1
  END: OUT R2,4
+
  10 END:OUT R2,4
      HALT
+
11    HALT

Revision as of 09:03, 14 January 2019

1      INP R0,2
2      INP R1,2
3      MOV R2,#0
4 LOOP:SUB R0,R0,R1
5      ADD R2,R2,#1
6      CMP R0,#0
7      BGT LOOP
8      BEQ END
9      SUB R2,R2,#1
10 END:OUT R2,4
11     HALT