Header Ads

Header ADS

MICROPROCESSOR EMU8086 - ASSEMBLER AND EMULATOR









Code: Basic Instructions

ORG 100H        ; Program starts from 100H address in RAM [Usually first line in the program]

MOV AX,1004H    ; Stores the 16 bit hex number in AX register

MOV BX,1004     ; Stores the decimal value in BX register

MOV CX,10101B   ; Stores the binary number in CX register

MOV DH,12H      ; Stores the 8 bit hex number in UPPER 8 bit of DX register

XCHG AX,BX      ; Exchanges the contents of AX and BX register
              
RET             ; Program terminates here [Usually last line of the program]






Code 01: Declaring variables
ORG 100H

MOV AX,1004H   ;[Stores 1004h into the AX register]

MOV CX, EEE1   ;[Stores the content in variable EEE1 into the AX register]

RET

EEE1 DW 1130H ; [Declares a variable]

Code 02: Declaring Array

ORG 100H

MOV AX,1004H   ;[Stores 1004h into the AX register]

MOV CX, EEE1        ;[Stores the content in variable EEE1 into the AX register]

MOV DX, EEE2[6]   ;[Stores the content of fourth element in the variable array EEE2 into DX register ]

RET

EEE1 DW 1130H  ;[Declares a variable]

EEE2 DW 1096H,4A43H,5FC2H,0D3B2H   ;[Declares an array of variables]


Code 03: Accessing array with SI register
ORG 100H
MOV SI,4      ; Stores the desired array index value into SI register
MOV AX,SU[SI] ; Points the desired array value through SI register, same as using SU[2]
RET
SU DW 1243H,6678H,12A6H,90D5H

Code 04: Addition Operation
ORG 100H

MOV AX,1234H  ;[Stores the value 1234H into AX register]

MOV BX, 1CD5H ;[Stores the value 1CD5H into BX register]
MOV CX,1452H  ;[Stores the value 1452H into CX register]

ADD BX,AX    ;[ ADD the contents of AX and BX and stores the result into BX]

ADD AX, 6723H ;[ADD AX with 6723H and stores the result into AX]

ADD BX,EEE2[2]  ;[ADD BX with the content of EEE1 and stores the result into BX]
ADD CX, EEE2 [4]  ;[ADD CX with the content at third element in EEE2 array and stores the result into CX]

RET
EEE1 DW 1130H
EEE2 DW 1235H,0C451H,1125H 


Code 05: Subtraction Operation:
ORG 100H

MOV AX,1234H  ;[Stores the value 1234H into AX register]

MOV BX, 1CD5H ;[Stores the value 1CD5H into BX register]
             
MOV CX,1452H  ;[Stores the value 1452H into CX register]

SUB BX,AX   

SUB AX, 6723H

SUB BX,EEE2[2] 

SUB CX, EEE2 [4] 

RET

EEE1 DW 1130H

EEE2 DW 1235H,0C451H,1125H 






Code#06: Multiplication Operation

ORG 100H

MOV AX,1234H

MOV BX,1267H

MUL BX ;[Multiplies the contents of AX and BX and stores in DX:AX]  

MUL EEE1 ;[Multiplies the contents of AX and EEE1 array and stores in DX:AX]

MUL EEE2 [2] ;[Multiplies the contents of AX and EEE[2] and stores in DX:AX]

MUL AX ; [Multiplies the contents of AX and AX and stores in DX:AX]

RET

EEE1 DW 1130H 

EEE2 DW 1096H,4A43H,5FC2H,0D3B2H


Code 07: Division Operation

ORG 100H

MOV AX,3A57H
MOV DX,12H

MOV BX,232H

DIV BX

DIV EEE1

DIV EEE2[4]

RET


EEE1 DW 1130H 

EEE2 DW 1096H,4A43H,5FC2H,0D3B2H








Exercise:
An array named ‘EEE18’ contains four values as X1, X2, X3, X4. Write a code in assembly language that will perform the following operation:
((X1+X2) *X3) / X4

ORG 100H
MOV AX,EEE18[0]
ADD AX,EEE18[2]
MUL EEE18[4]
DIV EEE18[6]
RET
EEE18 DW 1111H,23F5H,214DH,550AH



No comments

Theme images by enot-poloskun. Powered by Blogger.