gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
version 0.81
[asm2wsl.git] / samples / sumn-stack-prompt.asm
1 .model small
2 ;#macros-removed-from-listing
4 .code
5 ;read_num, print_num, etc are macros
7 start:
8 mov ax, data
9 mov ds, ax
10 print_str prompt
11 read_num n
12 mov cx, n
13 l1:
14 print_str prompt
15 read_num num
16 push num
17 loop l1
18 ; now sum up the top n from the stack
19 mov cx, n
20 mov ax, 0
21 mov dx, 0
22 theloop:
23 pop ax ; get next from stack
24 add dx, ax ; array sum is in dx
25 loop theloop
26 ; result
27 print_new_line
28 print_str resStr
29 print_num dx
30 end1:
31 nop
32 end_execution
35 .data
36 num dw 12
37 n dw 3
38 rez dw 0
39 tempStr db " "
40 prompt db "number? $"
41 resStr db "result $"
43 .stack
44 end start
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner