Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; multi-segment executable file template.
- data segment
- ; add your data here!
- N db ?
- suma db 0
- first db 1
- returnInst dw ?
- ends
- stack segment
- dw 128 dup(0)
- ends
- code segment
- sum proc
- cmp first, 1d
- je firstTime
- cmp cl, 01d
- je end
- mov al, cl
- mov ah, 0d
- mov dl, 3d
- div dl
- cmp ah, 0d
- jne calling
- add bl, cl
- calling:
- dec cx
- call sum
- end:
- push bx
- push returnInst
- ret
- firstTime:
- pop returnInst
- pop cx
- mov al, 0d
- mov first, 0d
- call sum
- sum endp
- start:
- ; set segment registers:
- mov ax, data
- mov ds, ax
- mov es, ax
- mov ah, 01h
- int 21h
- sub al, 48d
- mov ah, 0d
- mov dl, 10d
- mul dl
- mov N, al
- mov ah, 01h
- int 21h
- sub al, 48d
- add N, al
- mov cl, N
- mov ch, 0d
- push cx
- call sum
- pop ax
- mov sum, al
- mov ax, 4c00h ; exit to operating system.
- int 21h
- ends
- end start ; set entry point and stop the assembler.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement