Category : Files from Magazines
Archive   : DDJ8707.ZIP
Filename : DISQUE.EXP

 
Output of file : DISQUE.EXP contained in archive : DDJ8707.ZIP

shr cx,1 ;Convert byte count to word count
jnc word_move ;If cx was odd, carry will be set
movsb ;Move the odd byte
word_move:
jcxz exit ;In case cx was equal to 1 originally
rep movsw ;Move words
exit:

example 1



xor ax,ax ;Assume equal
rep compsb ;Compare strings
je exit ;If equal, we're finished
ja above ;If above, set ax to 1
dec ax ;Below. Set flag to -1
jmp short exit
above: inc ax
exit:

example 2



xor ax,ax
rep cmpsb
je exit
sbb ax,ax ; If above, cf=0, if below cf=1
cmc ; If above, cf=1, if below cf=0
adc ax,0 ; If above ax=1, if below ax=-1


example 3



lolab: in al,dx ;Get status

test al,1 ;Is it low?
jnz lolab ;Wait until it is
cli ;No more interrupts
hilab: in al,dx ;Get status
test al,1 ;Is it high?
jz hilab ;Wait until it is
movsw ;Write to the screen
sti ;Reenable interrupts


example 4



mov bx,[si] ;Load value "outside of" cli-sti
lolab: in al,dx ;Get status
test al,1 ;Is it low?
jnz lolab ;Wait until it is
cli ;No more interrupts
hilab: in al,dx ;Get status
test al,1 ;Is it high?
jz hilab ;Wait until it is
mov es:[di],bx ;Write to the screen
sti ;Reenable interrupts


example 5



mov ax,word ptr [bp].value ;8 bytes, 30 cycles
mov bx,ax
mov ax,word ptr [bp].value[2]

mov ax,word ptr [bp].value[2] ;6 bytes, 35 cycles
mov bx,word ptr [bp].value

les bx,[bp].value ;5 bytes, 35 cycles
mov ax,es


example 6




cmpi.l #15,d0 If < 15, byte move is faster
blt.s bytemove
* Special code to move words
* Addresses must both be even or both be odd
moveq.l #0,d2 d2 is a flag for code below
move.l a0,d3 Copy the address register
lsr.b #1,d3 Is from an odd address?
addx.l d2,d2 If from is odd, increment flag

move.l a1,d3 Cannot 'btst' an address register
btst #0,d3
beq.s evenaddr
addq.l #1,d2 To is odd. increment flag

evenaddr btst #0,d2 If one addr is odd and the other even,
bne.s bytemove we cannot do it

lsr.b #1,d2 If both were odd, d2 is 2; else it is 0
* Now d2 = 1 indicates odd, d2 = 0 says even
btst #0,d0 Is n an odd number?
beq.s evenlen
addq.l #1,d2 N is odd. Set flag

evenlen cmpi.l #1,d2 Find out which even/odd
* combination we have here
beq.s oddeven One is odd, one is even
blt.s wordmove Both are even. Take off!
move.b (a0)+,(a1)+ Both are odd. Fix the odd byte

wordmove asr.l #2,d0 Convert byte count to word count
bcc.s longmove Any odd byte has been moved
move.w (a0)+,(a1)+ Now move extra half-word

longmove subq.l #1,d0 Decrement for dbf
longloop move.l (a0)+,(a1)+
dbf d0,longloop
bra.s exit

oddeven btst #0,d0 Was the count the odd one?
bne.s oddcnt

evencnt subq.l #1,d0 The address was odd, count even;
move.b (a0)+,(a1)+ Now the addr is even, count odd!

oddcnt asr.l #2,d0 Convert byte count to word count
bcc.s lngmove2 The odd byte will been moved later
move.w (a0)+,(a1)+ Now move extra half-word




lngmove2 subq.l #1,d0 Decrement for dbf
lngloop2 move.l (a0)+,(a1)+
dbf d0,lngloop2
move.b (a0)+,(a1)+ Move the odd byte
bra.s exit

bytemove subq.l #1,d0 Decrement for dbf
loop move.b (a0)+,(a1)+ *to++ = *from++
dbf d0,loop while --n > 0

exit rts Return


example 7




shr cx,1 ;As in the text
jnc word_move
movsb
word_move:
jcxz exit
mov ax,si ;Use ax to test addresses
and ax,di ;Put the addresses together
shr ax,1 ;If both addresses were odd,
jnc not_odd ;the carry flag will be set
movsb ;Move to an even address
dec cx ;One less word for the repeat
jcxz finish ;If only one word
rep movsw
finish: movsb ;Move the last byte
jmp short exit
not_odd:
rep movsw
exit:


example 8


  3 Responses to “Category : Files from Magazines
Archive   : DDJ8707.ZIP
Filename : DISQUE.EXP

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/