since multiple steps are required in PB to achieve the same end.
In ASM. using the registers, the register pair DX,AX can be used to hold a double-word, and this can be divided by any word (16 bit) reference, with the AX register receiving the Integer result, and the DX register receiving the remainder (the potion we want to have returned).
A variation of the register approach has the word to be divided into in the AX register, and this can be divided by a byte (8 bit) value, and the integer result will be in AL, with the remainder in AH.
For greatest flexability, we would normally elect to use the first form.
Code: Select all
Procedure.w Mod(value1.w,base1.w)
temp1.w
MOV ax,value1
XOR dx,dx
DIV base1
MOV temp1,dx
ProcedureReturn temp1
EndProcedure
OpenConsole()
ConsoleColor(15,1)
For a.w=1 To 50
Print("Mod("+Str(a)+",13) ==> "+Str(Mod(a,13)))
If (a & 1)
ConsoleLocate(39,a/2)
ElseIf a<50
PrintN("")
EndIf
Next
While Inkey()=""
Wend