Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- name "sum maxi"
- name "sum maxi"
- Data SEGMENT
- N DB 4 DUP(?)
- SOMME DW 3 DUP(?)
- MAXI DW 3 DUP(?)
- VALSOM DB 3 DUP(?)
- Data ENDS
- Code SEGMENT
- Start:
- MOV MAXI,100 ;initialising the maximum
- MOV AX,0
- MOV BX,0
- MOV CX,0
- Loop: INC BX ;increasing the integers counter
- MOV SOMME,AX ;copying total to the SUM variable
- ADD AX,BX ;adding this integer to the total
- CMP AX,MAXI ;testing that the total amount is less or equal than maxi
- JLE Loop ;if yes relooping
- DEC BX ;if no decrease the numbers counter
- MOV AX,BX ;move bx value to ax
- MOV N,AL ;saving the value to N
- MOV BX,10 ;preparing bx to divide
- DIV BX ;converting to decimal through DX
- ADD AX,48 ;converting first digit to ascii
- ADD DX,48 ;converting second digit to ascii
- MOV AH,AL ;moving first digit to AH
- MOV AL,DL ;moving second digit to AL
- MOV BX,offset N
- MOV [BX],AH
- MOV Byte ptr[BX+1],AL
- MOV Byte ptr[BX+2],20h
- MOV Byte ptr[BX+3],'$'
- MOV AX,SOMME
- MOV DX,0
- MOV BX,10 ;preparing bx to divide
- DIV BX ;converting to decimal through DX
- ADD AX,48 ;converting first digit to ascii
- ADD DX,48 ;converting second digit to ascii
- MOV AH,AL ;moving first digit to AH
- MOV AL,DL ;moving second digit to AL
- MOV BX,offset VALSOM
- MOV [BX],AH
- MOV Byte ptr[BX+1],AL
- MOV Byte ptr[BX+2],'$'
- MOV DX,offset N
- MOV AH,9
- INT 21h
- MOV DX,offset VALSOM
- MOV AH,9
- INT 21h
- MOV AX,4C00h
- INT 21h
- Code ENDS
- END Start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement