Write A Program In Assembly Language That Calculates The Sum Of First Five Odd Numbers (1, 3, 5, 7, 9) And Stores The Result In AX Register. You Can Do It With The Help Of Loop (initialize AX Register With Value 0 And BX With Value 1, And Then On?

3

3 Answers

Anonymous Profile
Anonymous answered
ORG 100   / Origin of program is HEX 100
     LDA ADS   / Load first address of operand
     STA PTR   / Store in pointer
     LDA NBR   / Load -100
     STA CTR   / Store in counter
     CLA   / Clear AC
LOP, ADD PTR I / Add an operand to AC
     ISZ PTR   / Increment pointer
     ISZ CTR   / Increment counter
     BUN LOP   / Repeat loop again
     STA SUM   / Store sum
     HLT   / Halt
ADS, HEX 150   / First address of operands
PTR, HEX 0     / Reserved for a pointer
NBR, DEC -100  / Initial value for a counter
CTR, HEX 0     / Reserved for a counter
SUM, HEX 0     / Sum is stored here
     ORG 150   / Origin of operands is HEX 150
     DEC 75    / First operand
  .
  .
  .
     DEC 23
     END
Anonymous Profile
Anonymous answered
Can someone help me with this  Roman Number System - Problem Statement:  Although more than 2000 years old, the Roman number system is still used today. At the end of a movie, for  example, the year the film was released is often given using Roman numerals. The year a corner stone of a new  building was laid is also often given using the Roman number system. It is frequently used on clocks and  wristwatches and it is thus worth our while to be able to convert a decimal number to Roman numerals.  How does this system work?  1 (in decimal) is represented by I.  5 is represented by V.  10 is represented by X.  50 is represented by L.  34  100 is represented by C.  500 is represented by D.  1000 is represented by M.  What about all the numbers in between? Let’s start at 2. This is represented by two 1s, i.e. II and 3 by three 1s,  i.e. III. But 4 is not represented by IIII as we would expect, but rather by IV (1 less than 5). The same principle is  used for all the numbers after this. The number 9 is thus represented by IX (1 less than 10), the number 30 by  XXX and the number 40 by XL (10 less than 50), The number 900 is represented by CM (100 less than 1000).  How would we represent the number 1979 using Roman numerals? Breaking it up into powers of 10 gives 1000  plus 900 plus 70 plus 9. 1000 is represented by M, 900 is represented by CM (100 less than 1000), 70 is  represented by LXX (50 plus two 10s) and 9 by IX (1 less than 10). The year 1979 is thus represented as  MCMLXXIX using the Roman number system.  Now write a program in assembly language that accepts a year from the keyboard and displays the equivalent of  the year using Roman numerals.
Anonymous Profile
Anonymous answered
[org 0x0100]

mov bx, 0 ; initialize array index to zero
mov ax, 0 ;
mov bx, 1;

loop: Add ax, bx ; load number in ax
  add bx,2; add bx by 2
  cmp ax, 9 ; compare ax with 9
  jne loop ; no swap if already in order

mov ax, 0x4c00 ; terminate program
int 0x21

Answer Question

Anonymous