To Find Average of two Bytes > Assembly Language
Microprocessor
To Find Average of two Bytes > Assembly Language
ASSUME DS:DATA, CS:CODEDATA SEGMENT
N01 DB 80H
N02 DB 80H
AVG DB ?
DATA ENDS
CODE SEGMENT
START: MOV BX,DATA
MOV DS,BX
MOV AL,N01
ADD AL,N02
ADC AH,00H
MOV CL,02H; SHR AX,01H
DIV CL; SAR AX,01H
MOV AVG,AL
MOV AH, 4CH
INT 21H
CODE ENDS
END START
OUTPUT on TASM:
≡ File Edit View Run Breakpoints Data Options Window Help READY
╔═[■]═CPU 80486═══════════════════════════════════════════════╤═══════1════[↕]═╗
║ cs:0000 BB195B mov bx,5B19 │ ax 0080 │c=0║
║ cs:0003 8EDB mov ds,bx │ bx 5B19 │z=0║
║ cs:0005 A00000 mov al,[0000] │ cx 0002 │s=0║
║ cs:0008 02060100 add al,[0001] │ dx 0000 │o=0║
║ cs:000C 80D400 adc ah,00 │ si 0000 │p=0║
║ cs:000F B102 mov cl,02 │ di 0000 │a=0║
║ cs:0011 F6F1 div cl │ bp 0000 │i=1║
║ cs:0013 A20200 mov [0002],al │ sp 0000 │d=0║
║ cs:0016►B44C mov ah,4C │ ds 5B19 │ ║
║ cs:0018 CD21 int 21 │ es 5B09 │ ║
║ cs:001A 0000 add [bx+si],al │ ss 5B19 │ ║
║ cs:001C 0000 add [bx+si],al │ cs 5B1A │ ║
║ cs:001E 0000 add [bx+si],al │ ip 0016 │ ║
║ cs:0020 0000 add [bx+si],al │ │ ║
║ cs:0022 0000 add [bx+si],al │ │ ║
╟─────────────────────────────────────────────────────────────┼────────────┴───╢
║ ds:0000 80 80 80 00 00 00 00 00 ÇÇÇ ▲ ss:0002 0080 ║
║ ds:0008 00 00 00 00 00 00 00 00 ■ ss:0000►8080 ║
║ ds:0010 BB 19 5B 8E DB A0 00 00 ╗↓[Ä█á ▒ ss:FFFE 3302 ║
║ ds:0018 02 06 01 00 80 D4 00 B1 ☻♠☺ Ç╘ ▒ ▒ ss:FFFC 5B1A ║
║ ds:0020 02 F6 F1 A2 02 00 B4 4C ☻÷±ó☻ ┤L ▼ ss:FFFA 0016 ║
╚◄■▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒►╧═══════════════─┘
F1-Help F2-Bkpt F3-Mod F4-Here F5-Zoom F6-Next F7-Trace F8-Step F9-Run F10-Menu
Comments
Post a Comment