ok so i was playing around with asm and did this simple program:
.model small
.stack 100h
.data
sum dw ?
.code
extrn Writeintroc, Crlfroc
main proc
mov ax,@data
mov ds,ax
mov dx,1
mov bx,10
mov ax,0
L1:
add ax,dx
add dx,dx
mov sum,ax
call Writeint
call Crlf
loop L1
mov ax,4c00h
int 21h
main endp
end main
....it adds 1+2+4+8+16+32.........+1024
im just wondering how would i change this code to do
-1 + 2 -3 +4 -5 + 6 .......+ (-1 )^n N ?
.model small
.stack 100h
.data
sum dw ?
.code
extrn Writeintroc, Crlfroc
main proc
mov ax,@data
mov ds,ax
mov dx,1
mov bx,10
mov ax,0
L1:
add ax,dx
add dx,dx
mov sum,ax
call Writeint
call Crlf
loop L1
mov ax,4c00h
int 21h
main endp
end main
....it adds 1+2+4+8+16+32.........+1024
im just wondering how would i change this code to do
-1 + 2 -3 +4 -5 + 6 .......+ (-1 )^n N ?