Write a program to add consecutive numbers from 0 +1+2+3+4 + etc. until the sum overflows (C=1). A flow chart is shown to help you.
Help! I can't figure this out.
Link to the IDE
Example to work with:
; =====================================
; yasp - testprogram
; Add two numbers to start, then increment one of them
; and add that to the previous sum, once the sum exceeds 255 stop
; =====================================
mov b0, 20 ; Move 20h to register b0
mov b1, 50 ; move 50h to register b1
main: ;this is a label for this address in the program
inc b1 ; increment b1 by 1
add b0, b1 ; add b0 and b1, and then put the result in b0
jc main2 ; jump on carry=1 to then end of the program.
debug b0 ; send the b0 value to the debug printout
jmp main ; go to the address label main
main2: jmp main2 ; infinite loop: goto main2 forever (to stop)
end
Step by step
Solved in 3 steps