Q:

How to divide input by 2 then round up

I don't fully understand the div concept in assembler, all I know is that the quotient gets stored in EAX and the remainder in EDX. But i'm trying to figure out how to divide a user input by 2 and if there's a remainder then round it up. For example:

N= 3 / 2 = 1.5 Rounded up to 2
N= 9 / 2 = 4.5 Rounded up to 5
N= 4 / 2 = 2

A:

To divide by two, you shift the register right one place. The low bit is shifted into the Carry flag.
So if the number is even, 0 is shifted into CF. If the number is odd, 1 is shifted into CF.
So, to divide by two and round up, you shift right one place, then add the value of the carry flag:
; assume that the value is in EAX
shr eax, 1   ; divide by 2. Low bit into Carry flag
adc eax, 0   ; add the value of the Carry flag

