I think I have this figured out but I would like a second opinion from
someone who unlike myself paid attention in math class. (I was talking to
Maureen Valente.)

 

I'm trying to port an S/390 assembler routine to Visual Basic. VB has no
shift operators. I'm trying to simulate SRL R6,8

 

No need to know Visual Basic, just pretend the following is pseudo-code. R6
is defined as a signed, 32-bit (31-bit in 390-speak) integer. The VB seems
to work correctly; I'm not asking for VB help. I'd just like any of the
mathematicians on the list to tell me if my logic, especially for negative
values, is correct. I'm worried that I may have missed some boundary
condition. (This code could be shortened to one line, but I did it this way
to make the logic and the debugging clearer.)

 

        ' Simulate a shift right logical 8

        If R6 >= 0 Then

            R6 = R6 \ 256     ' \ is integer division

        Else

            R6 = R6 \ 256   ' \ is integer division

            R6 = R6 - 1

            R6 = R6 And &HFFFFFF        ' Equivalent to S/390 X'FFFFFF'

            End If

 

Thanks,

Charles Mills



 


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to