random - RandomRange in assembly with Irvine -


i working on x86 assembly language. want 2 parameters 1 column , other 1 row, using randomrange within interval [0,5]. here tried adjust interval dividing random number 6, , getting number remains in dl remainder of division.

i implemented array holds numbers randomized before , jumps randomization if element 1, uses row*6+col check index, array not effective yet.

i segmentation fault, problem?

title program template     (template.asm)   include irvine32.inc include macros.inc  .data onezero byte 36 dup(0)  row byte 0 col byte 0 .code main proc  _again:  call randomrange mov bx, 6 div bx mov row, dl  call randomrange div bx mov col, dl  movzx eax, row mov ebx, 6 mul ebx movzx ecx, col add eax, ecx mov edi, eax mov al, 1 cmp al, onezero[edi] je _again  movzx eax, row call writeint movzx eax, col call writeint  main endp  end main 

the irvine randomrange function has functionality:

; returns unsigned pseudo-random 32-bit integer ; in eax, between 0 , n-1. input parameter: ; eax = n. 

also note div bx dividing 32 bit number formed dx:ax , not eax.

as segfault, use debugger , see crash is.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -