2 Write an assembly code that stores an 8 bit number of your

2. Write an assembly code that stores an 8 bit number of your choice in a particular memory location of your choice. Then, subtract number 4 from the number which you stored in this memory location (you have to bring the number from memory into one of the accumulators, subtract 4 from it, and then store it back in the same memory location).

Solution

normal synatax for assembly substraction is
sub register1,register2 //the result will be stored in register1 it is two may addressing
  

for given problem:

MOV AC,8 bit number   :loads 8-bit number into accumulator
STA memory_location   :stores in memory location
LDA memory_location   :loads memory data into accumulator
SUB #number       :substract the number from accumulator
STA memory_location   :result will stored in memory
HLT           :terminate the program

//arithmatic operations done only in binary numbers the representaion of ASCII decimal values like 1 2 3 4 as 31H,32H,33H,34H so that

example:

in memory location(4000H)-have - 8

(4000H)-4=4

MOV AC,38H   :loads 8 into accumulator
STA 4000H   :stores in memory
LDA 4000H   :load data into ac
SUB 34H       :substract 4 from 8
STA 4000H   :sotres result in memory
HLT       :terminate program

(or simple understand)

mov ac,0000 1000
sta 4000H
lda 4000H
sub 0000 0100
sta 4000H
hlt

2. Write an assembly code that stores an 8 bit number of your choice in a particular memory location of your choice. Then, subtract number 4 from the number whi

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site