| 1 |
;File: fig0621.pep |
| 2 |
;Computer Systems, Fourth edition |
| 3 |
;Figure 6.21 |
| 4 |
; |
| 5 |
BR main |
| 6 |
numPts: .BLOCK 2 ;global variable #2d |
| 7 |
value: .BLOCK 2 ;global variable #2d |
| 8 |
j: .BLOCK 2 ;global variable #2d |
| 9 |
; |
| 10 |
;******* void printBar (int n) |
| 11 |
n: .EQUATE 4 ;formal parameter #2d |
| 12 |
k: .EQUATE 0 ;local variable #2d |
| 13 |
printBar:SUBSP 2,i ;allocate #k |
| 14 |
LDA 1,i ;for (k = 1 |
| 15 |
STA k,s |
| 16 |
for1: CPA n,s ;k <= n |
| 17 |
BRGT endFor1 |
| 18 |
CHARO '*',i ; cout << '*' |
| 19 |
LDA k,s ;k++) |
| 20 |
ADDA 1,i |
| 21 |
STA k,s |
| 22 |
BR for1 |
| 23 |
endFor1: CHARO '\n',i ;cout << endl |
| 24 |
RET2 ;deallocate #k, pop retAddr |
| 25 |
; |
| 26 |
;******* main () |
| 27 |
main: DECI numPts,d ;cin >> numPts |
| 28 |
LDA 1,i ;for (j = 1 |
| 29 |
STA j,d |
| 30 |
for2: CPA numPts,d ;j <= numPts |
| 31 |
BRGT endFor2 |
| 32 |
DECI value,d ; cin >> value |
| 33 |
LDA value,d ; call by value |
| 34 |
STA -2,s |
| 35 |
SUBSP 2,i ; push #n |
| 36 |
CALL printBar ; push retAddr |
| 37 |
ADDSP 2,i ; pop #n |
| 38 |
LDA j,d ;j++) |
| 39 |
ADDA 1,i |
| 40 |
STA j,d |
| 41 |
BR for2 |
| 42 |
endFor2: STOP |
| 43 |
.END |