A86: Another Question


[Prev][Next][Index][Thread]

A86: Another Question




hello, can someone tell me why this outputs huge numbers? Am I missing
something??

Generate:
  ld a,20
  ld (temp),a
  ld a,10
  ld (temp2),a		;Sets Vars
  ld hl,price		;Pointer
  ld b,14			;14 bytes
GenLoop:
  push hl			;Save hl/bc
  push bc
  ld a,(temp)		;Increase Temp and Temp2 by 2 each
  inc a \ inc a
  ld (temp),a
  ld a,(temp2)
  inc a \ inc a
  ld (temp2),a
  ld a,(temp2)
  call Random		;Mardell's random routine -- 1 and temp2
  ld b,a
  ld a,(temp)		;add temp
  add a,b
  pop bc			;pop
  pop hl
  ld (hl),a			;put a into hl
  inc hl			;increase mem addy
  djnz GenLoop		;goto agian if not 14
  ret

varspace=$
 price = varspace+1
 price1 = varspace+2
....
 price14 = varspace+3


Random:	       ; Creates a pseudorandom number 0 <= x < A
 ld b,a	       ; Thanks to Jimmy Mardell for this routine
 ld a,r
 add a,a
 ld hl,0
 ld d,0
 ld e,a
RMul:
 add hl,de
 djnz RMul
 ld a,h
 ret

					Thanks in advance,

							-Ahmed

--
Ahmed El-Helw
ahmedre@bellsouth.net
http://asm8x.home.ml.org
ICQ: 3350394


Follow-Ups: