26 lines
700 B
NASM
26 lines
700 B
NASM
; task :
|
|
; - sum the following 5 numbers
|
|
; - save the result of the sum at memory address 7F
|
|
; (numbers are in base16 notation)
|
|
11
|
|
18
|
|
23
|
|
25
|
|
30
|
|
; expected sum: A1
|
|
|
|
; program:
|
|
|
|
; mem = [0] * 128
|
|
; mem[0:5] = [0x11, 0x18, 0x23, 0x25, 0x30]
|
|
A2 00 ; LDX # 0 ; x = 0
|
|
A9 00 ; LDA # 0 ; a = 0
|
|
; loop: ; while True:
|
|
75 00 ; ADC zp,x 0 ; a += mem[0 + x]
|
|
E8 ; INX i ; x += 1
|
|
E0 05 ; CPX # 05 ; _ = (x == 5)
|
|
D0 F9 ; BNE r loop ; if _ == True: break
|
|
85 7F ; STA zp 7F ; mem[0x7f] = a
|
|
; forever: :
|
|
4C 12 00 ; JMP a forever ; while True: pass
|