Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ex2.asm.
- .MODEL SMALL
- .STACK 100h
- .DATA
- unsignedString DB 13,10, 'The average of the numbers in the array as unsigned is: XXXXX',13,10,'$'
- signedString DB 13,10, 'The average of the numbers in the array as signed is: XXXXXX',13,10,'$'
- SUM DW ?
- myArr DW 0FA0h, 8001h, 150h, 1h, 2h, 3h, 4h, 5h
- sizeArr DW 8
- Avg DW ?
- ten DW 10h
- .CODE
- ProgStart:
- MOV AX,@DATA
- MOV DS,AX
- MOV CX, sizeArr
- MOV DI, OFFSET myArr
- sum_label:
- MOV AX, [DI]
- ADD SUM, AX
- ADD DI,2
- LOOP sum_label
- average:
- MOV AX, SUM
- DIV sizeArr
- MOV Avg, AX
- printUNSIGNEDstring:
- MOV AX, Avg
- MOV DX,0
- DIV ten
- ADD DL,'0'
- MOV unsignedString[62],DL
- MOV DX, 0
- DIV ten
- ADD DL,'0'
- MOV unsignedString[61],DL
- MOV DX, 0
- DIV ten
- ADD DL,'0'
- MOV unsignedString[60],DL
- MOV DX, 0
- DIV ten
- ADD DL,'0'
- MOV unsignedString[59],DL
- MOV DX, 0
- ADD AL,'0'
- MOV unsignedString[58],AL
- MOV AH,9
- MOV DX,OFFSET unsignedString
- INT 21h
- finish:
- MOV AH,4Ch
- INT 21h
- END ProgStart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement