Uploaded by louiejay.layderos

Exercise1 BasicMathematicalOperations Register (1)

advertisement
BASIC ASSEMBLY PROGRAMMING
INSTRUCTION
Computer Registers
Registers are a type of computer memory used to quickly accept, store, and transfer data and instructions
that are being used immediately by the CPU. The registers used by the CPU are often termed as Processor
registers.
The computer needs processor registers for manipulating data and a register for holding a memory
address. The register holding the memory location is used to calculate the address of the next instruction
after the execution of the current instruction is completed.
The following image shows the register and memory configuration for a basic computer.
1
A. The following commands are the operation used to program in assembly language.
1. mov (move data) it copies and transfer data between two registers, or between an immediate
data to a register. add (add data)
Format:
mov <destination>, <source>
mov <register>, <register>
mov <register>, <data>
Example:
Hexadecimal
mov ax, 1234H
mov bl, 12H
mov ax, bx
Decimal
mov bh, 30
mov cl, 15
mov cl, bh
2. add (add data) it is used to get the sum of two registers or a register and a data and store the
result to the left most register.
Format:
add <destination>, <source>
add <register>, <register>
add <register>, <data>
Example:
Hexadecimal
mov ax,1234H
add al, ah  al=al + ah
mov bx, 0034H
add ax, bx  ax = ax +bx
Decimal
mov bh, 30
mov bl, 45
add bh, bl  bh = bh+ bl
3. sub (subtract data) it is used to get the different of two registers or a register and a data and
store the result to the left most register.
Format:
sub <destination>, <source>
sub <register>, <register>
sub <register>, <data> Example:
hexadecimal
mov ax, 1234H
sub al, ah  al = al -ah
mov cx, 0012H
sub ax, bx  ax = ax –bx
Decimal
mov bh30
mov bl, 45
sub bl, bh  bl = bl – bh
4. mul (multiply data) it is used to get the product of a given register AX and multiply data, and
stores the result to AX register. (If the product is greater than 16 bits, the overflow is stored in
DX register.)
Format:
mul <source>
mul <register>
2
Example:
Hexadecimal
mov ax, 1234H
mov bl, 03H
mul bl  ax = ax * bl
Decimal
mov al, 30
mov bl, 4
mul bl  ax = ax * bl
5. div (divide data) it is used to get the quotient of a given register AX register and divide data, and
stores the result to AX register. (If the quotient produces a remainder, the data is stored in DX
register.)
Format:
div <source>
div <register>
Example:
Hexadecimal
mov ax, 1234H
mov bl, 02H
div bl  ax = ax / bl
Decimal
mov al, 40
mov bl, 2
div bl  ax = ax / bl
6. inc (increment by one) it is used to increase the value of the register by one(1).
Format:
inc <register>
Example:
Hexadecimal
mov dx, 0FF0H
inc dx  dx = dx +1
Decimal
mov dl, 50
inc dl  dl = dl +1
7. dec (decrement by one ) it is used to decrease the value of the register by one(1).
Format:
dec <register>
Example:
Hexadecimal
mov dx, 0FF0H
dec dx  dx = dx +1
Decimal
mov dl, 50
dec dl  dl = dl +1
References:
https://www.javatpoint.com/computer-registers
https://datacadamia.com/computer/instruction/instruction#basic
https://datacadamia.com/computer/instruction/instruction#example
https://robocatz.com/instruction-pointer.htm
https://www.geeksforgeeks.org/computer-organization-problem-solving-instruction-format/
http://www.cs.umd.edu/~meesh/411/CA-online/chapter/instruction-set-architecture/index.html
3
Name:
Date Performed:
Laboratory
Date:
Date Submitted:
Schedule:
BASIC ASSEMBLY PROGRAMMING INSTRUCTION
Exercises: Determine the contents of AX register, BX register, CX register, DX register and IP address
after executing every sequence of assembly language instruction.
1. mov ax, 1234H
mov bh, 30
mov bl, 12H
add ax, bx
AX = __________
BX= __________
CX= __________
DX= __________
IP(1st) = __________
IP(2nd) = __________ IP (3rd) = __________
IP(4th) = __________
2. mov ax, 1234H
mov bl, 02H
div bl
add bl, ABH
AX = __________
BX= __________
CX= __________
DX= __________
IP(1st) = __________ IP(2nd) = __________ IP (3rd) = __________ IP(4th) = __________
3. mov ax, 1234H
mov bl, 03H
mul bl
add al, 1AH
AX = __________
BX= __________
CX= __________
DX= __________
IP(1st) = __________ IP(2nd) = __________ IP (3rd) = __________ IP(4th) = __________
4. mov ax,1234H
sub al, ah
mov bx, 0034H
mov cx, al
add cl, al
AX = __________
BX= __________
CX= __________
DX= __________
IP(1st) = __________ IP(2nd) = __________ IP (3rd) = __________ IP(4th) = __________
4
5. Determine the contents of AX, BX, CX, and DX after executing every sequence of assembly
language instruction. Write your answer on the space provided.
Table 1:
Register Code
1.
MOV AX, 0420H
2.
MOV BX, 1220H
3.
MOV CX, 0002H
4.
MUL CX
5.
SUB AX, BX
6.
ADD AL, BL
7.
ADD CL, AH
8.
SUB AH, CL
9.
MOV DL, AH
10.
ADD AL, BL
AX Register
BX Register
CX Register
DX Register
Show your solution below:
Observation:
Conclusion:
5
Download