home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics Programming Black Book (Special Edition)
/
BlackBook.bin
/
disk1
/
zenasmlg
/
zen_list.exe
/
LST13-5.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-02-15
|
867b
|
56 lines
;
; *** Listing 13-5 ***
;
; Negates several 32-bit values using the branch-on-zero-AX
; approach.
;
jmp Skip
;
; Negates a 32-bit value.
;
; Input:
; DX:AX = 32-bit value to negate
;
; Output:
; DX:AX = negated 32-bit value
;
; Registers altered: AX, DX
;
;-------------------------------------------------------
; Branching-out exit for Negate32Bits when AX negates to
; zero, necessitating an increment of DX.
;
Negate32BitsIncDX:
inc dx
ret
;
Negate32Bits:
not dx
neg ax
jnc Negate32BitsIncDX
ret
;
Skip:
call ZTimerOn
; First, negate zero.
sub dx,dx
mov ax,dx ;0
call Negate32Bits
; Next, negate 1 through 50.
X=1
rept 50
sub dx,dx
mov ax,X
call Negate32Bits
X=X+1
endm
; Finally, negate -1 through -50.
X=-1
rept 50
mov dx,0ffffh
mov ax,X
call Negate32Bits
X=X-1
endm
call ZTimerOff