Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REVERSE STRING
- DATA SEGMENT
- STRING DB 'IVASAV'
- DATA ENDS
- CODE SEGMENT
- ASSUME CS: CODE, DS: DATA, ES: DATA_SEG
- START: MOV AX, DATA
- MOV DS, AX
- MOV ES, AX
- MOV BP, 02
- MOV CX, 0006H
- MOV SI, CX
- MOV AX, CX
- DIV BP
- MOV CX, AX
- XOR DI, DI
- MOV BX, OFFSET STRING
- MOV AL, [BX+SI]
- XCHG [BX+DI], AL
- MOV [BX+SI], AL
- DEC SI
- INC DI
- LOOP 11
- INT 03H
- SUM OF ARRAY
- DATA SEGMENT
- ARR DB 01H,02H,03H,04H,05H
- CNT DB 05H
- DATA ENDS
- CODE SEGMENT
- START:MOV AX,DATA
- MOV DS,AX
- MOV AH,0H
- MOV CL,CNT
- LEA BX,ARR
- MOV AL,0H
- AGAIN:ADD AL,[BX]
- INC BX
- DEC CL
- JNZ AGAIN
- INT 03H
- FACTORIAL
- DATA SEGMENT
- NUM DW 0004H
- DATA ENDS
- CODE SEGMENT
- START:MOV AX,DATA
- MOV DS,AX
- MOV AX,NUM
- MOV CX,NUM
- DEC CX
- AGAIN:MUL CX
- DEC CX
- JNZ AGAIN
- MOV AH,4CH
- INT 03H
- FIBOACCI
- DATA SEGMENT
- ARR DB 01,02,03,04,05,06,07,08,09,10
- DATA ENDS
- CODE SEGMENT
- START:MOV AX,DATA
- MOV DS,AX
- MOV CL,05
- MOV AL,00
- MOV BL,01
- FIB: MOV DL,00
- ADD DL,BL
- ADD DL,AL
- MOV AL,BL
- MOV BL,DL
- LOOP FIB
- INT 03H
- ASCENDING DESENDING
- DATA SEGMENT
- ARR DB 05,04,02,01,03
- DATA ENDS
- CODE SEGMENT
- START:MOV AX,DATA
- MOV DS,AX
- MOV CL,05
- XOR AX,AX
- MOV DL,CL
- DEC CL
- L2 : LEA BX,ARR
- L1 :MOV AL,[BX]
- CMP AL,[BX+1]
- JC CONT
- XCHG AL,[BX+1]
- MOV [BX],AL
- CONT : INC BX
- LOOP L1
- DEC DL
- MOV CL,DL
- LOOP L2
- INT 03H
- #############
- DESCENDING JC --- JNC
- SEARCH
- DATA SEGMENT
- COUNT EQU 06H
- STR DB 'VASAVI'
- DATA ENDS
- CODE SEGMENT
- START: MOV AX,DATA
- MOV DS,AX
- MOV ES,AX
- MOV DI,OFFSET STR
- MOV CX,COUNT
- MOV AL,'I'
- REPNZ SCASB
- JNE NOTFIND
- MOV BX,0055H
- JMP EXIT
- NOTFIND: MOV BX,00FFH
- EXIT: INT 03H
- LAREST & SMALEST
- DATA SEGMENT
- ARR DB 02H,03H,01H,05H,07H
- DATA ENDS
- CODE SEGMENT
- START:MOV AX,DATA
- MOV DS,AX
- XOR AX,AX
- MOV CL,05H
- MOV DL,CL
- DEC CL
- L2: MOV BX,OFFSET ARR
- L1: MOV AL, [BX]
- CMP AL, [BX+1]
- JNC CONT
- XCHG AL,[BX+1]
- MOV [BX],AL
- CONT: INC BX
- LOOP L1
- DEC DL
- MOV CL,DL
- LOOP L2
- INT 03H
- #LARGE-JNC
- #SMALL-JC
- LED-SWITCH INTERFACE
- 1100 MOV AL,90
- MOV DX,AL
- OUT DX,AL
- LOOP:MOV DX,AL
- INC AL,DX
- MOV DX,FF32
- OUT DX,AL
- JMP LOOP
- MULTIBYTE ADDITION
- DATA SEGMENT
- NUM1 DB 15H,25H,35H
- NUM2 DB 20H,34H,20H
- NUM3 DB ?
- DATA ENDS
- CODE SEGMENT
- START:MOV AX,DATA
- MOV DS,AX
- MOV CX,03H
- CLC
- LEA SI,NUM2
- LEA BX,NUM2
- LEA DI,NUM3
- NEXT:MOV AL,[SI]
- ADC AL,[BX]
- INC SI
- INC BX
- INC DI
- LOOP NEXT
- INT 03H
- SIGNED MUL-DIV
- DATA SEGMENT
- NUM1 DB 0F2H
- NUM2 DB 02H
- PRODUCT DB?
- DATA ENDS
- CODE SEGMENT
- START:MOV AX,DATA
- MOV DS,AX
- MOV AL,NUM1
- MOV BL,NUM2
- IMUL BX
- IDIV BX
- MOV PRODUCT,AX
- MOV DIVISION,CX
- INT 03H
- BCD ADD
- DATA SEGMENT
- NUM1 DW 0005H
- NUM2 DW 0008H
- DATA ENDS
- CODE SEGMENT
- START:MOV AX,DATA
- MOV DS,AX
- MOV AX,NUM1
- MOV BX,NUM2
- ADC AX,BX
- DAA
- INT 03H
- PACK-UNPACK BCD
- DATA SEGMENT
- DATA ENDS
- CODE SEGMENT
- START:MOV AX ,DATA
- MOV DS ,AX
- MOV AL, 07H
- MOV AH, 03H
- MOV BL, 01H
- MOV BH, 02H
- ADD AX, BX
- AAA
- INT 03H
- TRAFFIC LIGHTS
- A1100
- MOV DS,FF36
- MOV AX,80
- OUT DS,AX
- MOV DS,FF30
- MOV AX,01
- OUT DS,AX
- MOV DS,FF32
- MOV AX,02
- OUT DS,AX
- BCD-BINARY
- DATA SEGMENT
- BCDIN DB 17H
- BINOUT DB ?
- DATA ENDS
- STACK SEGMENT
- STKWRD DW 50 DUP(0)
- TOS LABEL WORD
- STACK ENDS
- CODE SEGMENT
- START:MOV AX ,DATA
- MOV DS ,AX
- MOV AX ,STACK
- MOV SS ,AX
- MOV SP ,OFFSET TOS
- LEA SI, BCDIN
- LEA DI, BINOUT
- CALL BCDTOBIN
- INT 03H
- BCDTOBIN PROC NEAR
- MOV AL, [SI]
- MOV BL, AL
- AND BL, 0FH
- AND AL, 0F0H
- MOV CL, 04H
- ROR AL, CL
- MOV BH, 0AH
- MUL BH
- ADD AL, BL
- MOV [DI], AL
- RET
- BCDTOBIN ENDP
- STEPPER
- A1100
- MOV AL,80
- MOV DX,FF36
- OUT DX,AL
- START:MOV SI,1200
- MOV BL,04
- REPEAT:MOV AL,[SI]
- MOV DX,FF30
- OUT DX,AL
- CALL DELAY(111B)
- INC SI
- DEC BL
- JNZ REPEAT(110B)
- JMP START(1106)
- DELAY
- A111B
- MOV CX,0903
- LOOP:DEC CX
- JNZ LOOP(111E)
- RET
- DC MOTOR
- A1100
- MOV AL,80
- MOV DX,FF36
- OUT DX,AL
- MOV AL,05
- MOV DX,FF32
- OUT DX,AL
- CALL 1111
- JMP 1106
- MOV CX,FFFF
- DEC CX
- JNZ 1114
- RET
- 0 TO 9 DISPLAY
- 1100 MOV AL,80
- MOV DX,FF36
- OUT DX,AL
- MOV AL,7F
- MOV DDX,FF30
- OUT DX,AL
- AGN: CALL 1124
- START: MOV CL,0A
- MOV SI,1200
- REP:MOV AL,[SI]
- MOV DX,FF32
- OUT DX,AL
- CALL 1124
- INC SI
- DEC CL
- JNZ REP
- JMP START
- DLY: MOV DX,FFFF
- M:DEC DX
- JNZ M
- RET
- ORG 1300H
- 7SEGMENT
- MOV AL,80H
- MOV DX,FF36H
- OUT DX,AL
- MOV AL,01H
- MOV DX,FF30H
- OUT DX,AL
- MOV AL,F8H
- MOV DX,FF32H
- OUT DX,AL
- INT 03H
- ROLLING 7
- A6000
- MOV AL,80H
- MOV DX,FF36H
- OUT DX,AL
- START:MOV BH,06
- MOV BL,01
- BACK:MOV AL,BL
- MOV DX,FF30H
- OUT DX,AL
- MOV AL,F8H
- MOV DX,FF32H
- OUT DX,AL
- CALL DELAY(6050)
- MOV CL,01
- SHL BL,CL
- DEC BH
- JNZ BACK(600A)
- JMP START:(6006)
- INT 03H
- 7-DELAY
- A6050
- MOV CX,FFFF
- LOOP 6053
- RET
- DISPLAY HELLO
- M1200 PRESS ENTER
- 86
- 89
- C7
- C7
- C0
- START:MOV AL,80H
- MOV DX,FF36H
- OUT DX,AL
- LEA SI,1200
- LOOP:MOV CX,0005H
- MOV AL,7F
- MOV DX,FF30
- OUT DX,AL
- MOV AL,[SI]
- MOV DX,FF32
- OUT DX,AL
- INC SI
- CALL DELAY
- DEC CX
- JNZ LOOP
- JMP START
- DELAY:MOV BX,FFFF
- LOOP1:DEC BX
- JNZ LOOP1
- RET
- ADDRESSING
- IMMEDIATE:
- START: MOV AX,0010H
- INT 03H
- DIRECT:
- START:MOV AX,[0050]
- INT 03H
- BASE-INDEX:
- START: MOV AL,[BP+SI]
- MOV AX,[BX,DI]
- INDIRECT:
- START:MOV AX,[BX]
- ADD AX,0003H
- INDEXED:
- START:MOV AX,[SI,2000]
- REGISTER:
- START:MOV BX,0005H
- MOV AX,BX
- TRAFFIC LIGHT PROGRAM FOR CONTINUOUS ROTATION
- MOV AL,80
- MOV DX,FF36
- OUT DX,AL
- 1106:
- MOV AH,04
- MOV BX,2000
- 110B:
- MOV AL,[BX]
- MOV DX,FF30
- OUT DX,AL
- INC BX
- MOV AL,[BX]
- MOV DX,FF32
- OUT DX,AL
- CALL 1140
- INC BX
- DEC AH
- JNZ 110B
- JMP 1106
- 1140:
- MOV DX,000F
- MOV CX,FFFF
- LOOP 1146
- DEC DX
- JNZ 1143
- RET
- M2000
- 21 09 0C 09 64 08 24 03
- 2's,1’s complement
- assume cs:code,ds:data
- data segment
- n1 dw 0005h
- data ends
- code segment
- start:mov ax,data
- mov ds,ax
- mov ax,n1
- not ax
- mov bx,ax
- inc ax
- int 03h
- code ends
- end start
- factorial
- assume cs:code,ds:data
- data segment
- num dw 0003h
- data ends
- code segment
- start:mov ax,data
- mov ds,ax
- mov cx,num
- mov ax,cx
- dec cx
- fact:mul cx
- dec cx
- jnz fact
- int 03h
- code ends
- end start
- Multibyte addition
- Assume cs:code,ds:data
- Data segment
- Num1 db 01h,02h,03h,04h
- Num2 db 05h,06h,07h,08h
- Num3 db 04 dup(00)
- Data ends
- Code Segment
- Start:
- Mov ax,data
- Mov ds,ax
- Xor ax,ax
- Mov bx,ax
- Mov cl,al
- Mov dl,00h
- Mov cl,04h
- Lea si,num1
- Lea di,num2
- Lea bx,num3
- L1: mov al,[si]
- Adc al,[di]
- Mov cl,al
- Mov dl,00h
- Mov cl,04h
- Lea si,num1
- Lea di,num2
- L1: mov al,[si]
- Adc al,[di]
- Mov [bx],al
- Inc si
- Inc di
- Inc bx
- Loop l1
- Jnc l2
- Adc dl,00
- L2: mov [bx],dl
- Int 03h
- Code ends
- End start
- Multibyte subtraction
- Assume ds:data,cs:code
- Data segment
- N1 db 55h,66h,77h,88h
- N2 db 11h,22h,33h,44h
- Result db 4h dup(00)
- Data ends
- Code segment
- Start:mov ax,data
- Mov ds,ax
- Mov si,offset N1
- Mov di,offset N2
- Mov bx,offset result
- Clc
- Mov cx,0004h
- Mov ax,0000h
- Back:mov al,[si]
- Mov dl,[di]
- Sbb al,dl
- Mov [bx],al
- Inc si
- Mov di
- Inc bx
- Loop back
- Mov ah,4Ch
- Int 21h
- Int 03h
- Code ends
- End start
- Hardware add
- A1000
- Mov ax,0005h
- Mov bx,0005h
- Add ax,bx
- Int 03h
- G1000
- Hardware sub
- A1000
- Mov ax,0003h
- Mov bx,0003h
- Sub ax,bx
- Int 03h
- G1000
- Hardware mul
- A1000
- Mov ax,0002h
- Mov bx,0002h
- Mul bx
- Int 03h
- G1000
- Hardware div
- A1000
- Mov ax,0002h
- Mov bx,0002h
- Div bx
- Int 03h
- G1000
- Hardware fact
- A1000
- Mov ax,0001
- Mov cx,0003
- 1006:mul cx
- Dec cx
- Jnz 1006
- G1000
- Hardware sum
- M 1200 02
- M 1201 04
- A1000
- Mov ax,0000
- Mov cl,02
- Mov si,1200
- 1008:add al,[si]
- Inc si
- Dec cl
- Jnz 1008
- G1000
- smallest
- assume ds:data,cs:code
- data segment
- arr1 db 05h,04h,01h,02h,03h
- count db 05h
- data ends
- code segment
- start:mov ax,data
- mov ds,ax
- mov dl,count
- L2:mov cx,dx
- mov si,offset arr1
- L1:mov al,[si]
- cmp al,[si+1]
- jc continue
- xchg al,[si+1]
- mov [si],al
- continue:inc si
- loop L1
- dec dx
- jnz L2
- mov bx,offset arr1
- mov al,[bx]
- int 03h
- code ends
- end start
- largest
- assume cs:code,ds:data
- data segment
- arr db 02h,09h,03h,06h,08h,07h
- count db 06h
- data ends
- code segment
- start:mov ax,data
- mov ds,ax
- mov si,offset arr
- mov cl,count
- mov al,[si]
- up:inc si
- cmp al,[si]
- jnb go
- mov al,[si]
- go:loop up
- int 03h
- code ends
- end start
- search
- assume ds:data,cs:code
- data segment
- arr db 11h,21h,32h
- msg db 'FOUND','$'
- msg1 db 'NOT FOUND','$'
- count db 03h
- data ends
- code segment
- start:mov ax,data
- mov ds,ax
- mov es,ax
- mov cl,count
- mov si,offset arr
- cld
- mov al,32h
- repne scasb
- jz a2
- mov ah,09h
- lea dx,msg1
- int 21h
- jmp a3
- a2:mov ah,09h
- lea dx,msg
- int 21h
- a3:int 03h
- code ends
- end start
- reverse
- assume ds:data,cs:code
- data segment
- stg db 'SVCET','$'
- stg1 db 05h dup(?),'$'
- count db 05h
- data ends
- code segment
- start:mov ax,data
- mov ds,ax
- mov es,ax
- mov cl,count
- mov si,offset stg
- mov di,offset stg1
- cld
- add si,04h
- a1:movsb
- dec si
- dec si
- dec cl
- jnz a1
- mov ah,09h
- lea dx,stg1
- int 21h
- int 03h
- code ends
- end start
- ascending order
- assume ds:data,cs:code
- data segment
- arr db 05h,04h,01h,02h,03h
- count db 05h
- data ends
- code segment
- start:mov ax,data
- mov ds,ax
- mov dl,count
- L2:mov cx,dx
- mov si,offset arr
- L1:mov al,[si]
- cmp al,[si+1]
- jc continue
- xchg al,[si+1]
- mov [si],al
- continue:inc si
- loop L1
- dec dx
- jnz L2
- int 03h
- code ends
- end start
- descending order
- assume data:ds,cs:code
- arr1 db 05h,04h,01h,02h,03h
- count db 05h
- data ends
- code segment
- start:mov ax,data
- mov ds,ax
- mov dl,count
- L2:mov cl,dl
- mov si,offset arr1
- L1:mov al,[si]
- cmp al,[si+1]
- jnc continue
- xchg al,[si+1]
- mov [si],al
- continue:inc si
- loop L1
- dec dl
- jnz L2
- int 03h
- code ends
- end start
- search char
- assume cs:code,ds:data
- data segment
- str db 'VASAVI'
- size1 db 06h
- data ends
- code segment
- start:mov ax,data
- mov ds,ax
- mov es,ax
- CLD
- mov di,offset str
- mov cx,size1
- mov al,49
- REPNE SCASB str
- int 03h
- code ends
- end start
- sum of array numbers
- assume ds:data,cs:code
- data segment
- arr db 02h,03h,04h,05h,01h
- count db 05h
- data ends
- code segment
- start:mov ax,data
- mov ds,ax
- mov al,0h
- mov cl,count
- mov si,offset arr
- again:mov bl,[si]
- add ax,bx
- inc si
- dec cl
- jnz again
- int 03h
- code ends
- end start
- signed multiplication
- assume ds:data,cs:code
- data segment
- n1 dw -0002h
- n2 dw 0004h
- data ends
- code segment
- start:mov ax,data
- mov ds,ax
- mov ax,n1
- mov bx,n2
- imul bx
- int 03h
- code ends
- end start
- signed division
- assume ds:data,cs:code
- data segment
- n1 dw -0004h
- n2 dw 0002h
- data ends
- code segment
- start:mov ax,data
- mov ds,ax
- mov ax,n1
- mov bx,n2
- idiv bx
- int 03h
- code ends
- end start
- multibyte addition
- assume cs:code,ds:data
- data segment
- arr1 dw 0005h,0001h,0004h,0001h
- arr2 dw 0004h,0002h,0003h,0002h
- arr3 dw 4 dup(0)
- data ends
- start:mov ax,data
- mov ds,ax
- lea si,arr1
- lea di,arr2
- lea bx,arr3
- mov cx,04h
- sum:mov ax,[si]
- adc ax,[di]
- mov [bx],ax
- inc si
- inc di
- inc dx
- jnz sum
- int 03h
- code ends
- end start
- lcd
- A1000
- mov AL,90
- mov DX,FF36
- OUT DX,AL
- mov DX,FF30
- IN AL,DX
- MOV DX,FF32
- OUT DX,AL
- JMP 1106
- seven segment
- A1110
- mov al,80h
- mov dx,ff36
- out dx,al
- mov al,01h
- mov dx,ff30
- out dx,al
- mov al,f8h
- mov dx,ff32
- out dx,al
- int 03h
- Hello
- M1200 press enter
- 86
- 89
- C7
- C7
- C0
- Start:mov al,80h
- Mov dx,ff36h
- Out dx,al
- Lea si,1200
- Loop:mov cx,0005h
- Mov al,7F
- Mov dx,ff30
- Out dx,al
- Mov al,[si]
- Mov dx,ff32
- Out dx,al
- Inc si
- Call delay
- Dec cx
- Jnz loop
- Jmp start
- Delay:mov bx,ffff
- Loop1:dec bx
- Jnz loop1
- Ret
- Factorial Procedure
- Data segment
- Num2 dw 0003h
- Data ends
- Code segment
- Start: mov ax,data
- Mov ds,ax
- Mov ax,0000h
- Call myproc
- Int 03h
- Myproc proc near
- Mov ax,00001h
- Mov cx,num2
- Fact: mul cx
- Loop fact
- Ret
- Myroc endp
- Code ends
- End start
- Macro factorial
- Data segment
- Num1 dw 0004h
- Data ends
- Code Segment
- Start: mov ax,data
- Mov ds,ax
- Mov ax,0000h
- factMacro macro p1
- mov cx,p1
- mov ax,0001h
- fact: mul cx
- loop fact
- endm
- factMacro num1
- int 03h
- code ends
- End Start
- 8051 addressing mode
- Register: mov a,b
- Direct: mov 30h,a
- Indirect: mov a,@r0
- Indexed: MOVC a,@a+pc
- 8086 addressing modes
- Assume cs:code
- Code segment
- Start:
- Mov ax,0005h ; immediate
- Mov bx,[2000] ; direct
- Mov dx,[bx] ; indirect
- Mov bx,ax ; register
- Code Ends
- End Start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement