Notice: SSI.php was unable to load a session! This may cause problems with logout and other functions - please make sure SSI.php is included before *anything* else in all your scripts! in /home/tiplus/www/forum/SSI.php on line 180
This is the assembly stack application !
Post useful routines here (written by you or anybody else).

Posting a routine give you points that you can spend by voting for others routines :
Now some rules :

Code routines

; A bunch of operations on 24-bits numbers
;
;Outputs:
; AHL : always the result of the operation
; In many cases, BDE is destroyed, so you've better make like it always is



; Adds AHL to BDE (24 bits addition)
;Inputs :
; AHL : first 24-bits number
; BDE : second 24-bits number
AHLplusBDE:
add hl,de
adc a,b
ret

; Substract BDE from AHL (24-bits substraction)
;Inputs :
; AHL : first 24-bits number
; BDE : second 24-bits number
AHLminusBDE:
or a
sbc hl,de
sbc a,b
ret

; Shift AHL left B times (shift left is the same than multiplying by two)
;Inputs :
; AHL : 24-bits number
; B : times you want AHL to be shifted left
AHLslB:
ld c,a
xor a
cp b
jr z,AHLslBend
sla l
rl h
rl c
dec b
jr AHLslB+2 ; skips the "ld c,a xor a" instructions
AHLslBend:
ld a,c
ret

; Shift AHL right B times (shift right is the same than dividing by two)
;Inputs :
; AHL : 24-bits number
; B : times you want AHL to be shifted right
AHLsrB:
ld c,a
xor a
cp b
jr z,AHLsrBend
srl c
rr h
rr l
dec b
jr AHLsrB+2 ; skips the "ld c,a xor a" instructions
AHLsrBend:
ld a,c
ret

; Bitwises AHL and BDE
;Inputs:
; AHL : first 24-bits number
; BDE : second 24-bits number
AHLandBDE:
and b
ld b,a
ld a,h
and d
ld d,a
ld a,l
and e
ld l,a
ld h,d
ld a,b
ret

; Bitwises AHL or BDE
;Inputs:
; AHL : first 24-bits number
; BDE : second 24-bits number
AHLorBDE:
or b
ld b,a
ld a,h
or d
ld d,a
ld a,l
or e
ld l,a
ld h,d
ld a,b
ret

; Bitwises AHL xor BDE
;Inputs:
; AHL : first 24-bits number
; BDE : second 24-bits number
AHLxorBDE:
xor b
ld b,a
ld a,h
xor d
ld d,a
ld a,l
xor e
ld l,a
ld h,d
ld a,b
ret

; Inverts the content of AHL
;Inputs:
; AHL : 24-bits number
; Note : it's basically the same as AHL xor $FFFFFF
InvAHL:
cpl
ld b,a
ld a,h
cpl
ld d,a
ld a,l
cpl
ld l,a
ld h,d
ld a,b
ret
1 votesPlease log in to propose another solution or vote for this routine

Post your routine

You must log in to post routines