@pernia you can do that too. you can implement a proper binary float32 as defined by ieee 754, you can store the exponent as an 8 or 16 bit variable and the mantissa as a 32 bit one (both signed), or you can do a binary decimal thing
@pernia does your assignment specify that it's a floating point (as opposed to real or rational number) and if so is there a specific format? if they are going to test your code, you need to know which format to use
@Inginsub where should i do the shifting here? i don't know if i did it how i was supposed to, although i think it works except for that part about multiplying that whole number no float with decimal number no whole part
add resultDh with resultCl, inc for the carry, add resultBl to that, inc for carry again, mov that result into the lowest part of a 3 word buffer, add the inc to resultCh inc for carry again starting from 0 add to that resultBh inc for carry add to that resultAl inc for carry again mov the result into the lower part of the 3 word buffer add inc to result Ah mov that result into the highest part of the 3 word buffer
and then i would have the entire result in one buffer.
and if not in one buffer, could i mov the results into separate buffers and then figure out how to print those out?
@pernia yes, we lose precision beyond 1/65536th. with 8 or 32 fractional bits you discard the lower byte or dword (also I'm retarded, it should be word instead of dword in the example I gave you, but you get the idea)
@pernia it's fixed point, we have 16 fractional bits. the result has 32 fractonal bits, you only need the upper half. you can do the same with 8 or 32, just don't forget to shift the result appropriately. also it's binary, not decimal, don't forget that if you need output
@Inginsub in this example, dw0h, dw0l, dw1h, dw1l are 16bits, correct? and their multiplications would yield 32bit (stored in dx:ax) results right? like this
@pernia if you really want floating point, keep track of the exponent. you can also use fixed point: 16.16 (16 bit whole part, 16 bit fractional) is stored as dword:dword; in this case you'll need to shift the multiplication result 32 bits right
dw0h:dw0l * dw1h:dw1l =
dw0h*dw1h:0000:0000 +
dw0h*dw1l:0000 +
dw1h*dw0l:0000 +
dw0l*dw1l =
| <- you split the number here, discard the lowest dword and
the second lowest is your fractional part
@Inginsub im jumbled about the piecewise calculations and the floating part.
would it be easier if i just kept the floating part on the lower end of the space and treated it like a whole number (like, i multiplied the entire floating number by a factor of 10 to make it whole), and have a beeg integer, and then do piecewise calculations on whole numbers?then remember which words were "floating" to print them out after the "." to the screen
@pernia can you even use 32 bit regs on 8068? i thought it was 16 bit only (product is stored in dx:ax instead of eax) and you need to store your variables in ram and do piece wise calculations
@pernia the second one is easy, you have values dwordA:dwordB and dwordC:dwordD, the product is dwordB*dwordD + (dwordA*dwordD + dwordB*dwordC) << 16 + (dwordA*dwordC) << 32
@Inginsub hard time going about it. I need to find areas and perimeters of various shapes given user input. its 8086 and cant use an fpu coprocessor.
Adding two (16bit) numbers is easy. i could parse both numbers (between 0 and 9999.99, two decimal place restriction for this assignment) and shove the whole part into a dword and the decimal part into a different dword, then do something like
First problem is i gotta carry over values into high parts of a register when it overflows from addition. And also i might lose information from dividing a 32bit into a 16bit number, maybe im wrong.
Second, bigger problem is that with that 32bit result from multiplication, i have to multiply that by constants from the formulas of the shapes, which would be (zero extended?) 32bit*32bit, and theres no instructions for that.
@syzygy@pernia@Inginsub@qint pernis is just talkin' crazy because he wants to run WINE instead of just doing the thing that people use if they are doing it for a living.
@p@qint@pernia he multiplies 32 bit numbers in 16.16 format. 16x16 comes from the 8086 limitation of only having 16 bit regs to work with, but in this case each product will have 0, 16, or 32 fractional bits.
@Inginsub@qint@p what i noticed is that it works mostly when i do this (throwing out the last 16 bits of the 16.16.16.16 product), but if im doing for example 5000*0.5, i end up with
0000.0000.25000.0000
which is almost right, and i think this is where a shift comes in correct?
@Inginsub@pernia@qint If he does a 16x16 multiplication, he'll just have to take the low half of one register and the high half of the other. But notionally, it's a shift, right, like that is the operation you do, you throw out the upper 8 as overflow and the lower 8 as underflow.
@p@Inginsub@qint > You asked me! you went through one paper, 3 opinions on tools that do the same thing, and missed the whole point of the question once, only to repeat something someone else said 3 days ago. read the FUCKING THREAD NIGGER.
@p@Inginsub@qint >You get 0xWWXXYYZZ i got as far as that before you joined the thread > Well then why are you talking about it? if i ever did talk about fpu's, it was to say i wasn't allowed to use them
> when i have a different word for fractional and whole parts,
No, that is your problem. It's fixed-point and you confuse fixed-point and floating-point. What you want to do is multiply 0xNNNN by 0xMMMM. You get 0xWWXXYYZZ, and the W is overflow, the Z is roundoff, your answer is 0xXXYY.
@p@Inginsub@qint >mul, imul no shit. when i have a different word for fractional and whole parts, or am doing ieee flaoting point numbers (because the format is something i had to figure out too), its a few more steps >Yes, you can maybe i'm not being clear: i'm not allowed to. or wasn't anyway, its done
> lolno. "just multiply" is reiterating the problem
Unless you want to implement multiplication yourself, you want to use the multiplication instructions. I don't know how to make that easier. mul, imul.
> you think id be asking for help if i could?
Yes, you can. I listed all of the PoC||GTFO issues that have boot-sector hacks, including complete guides. "Here is the thing you want to do, here is a list of places that tell you how to do it. All of these PDFs are also zip files that include the code."
MOV EDX, CR0 ; Start probe, get CR0 AND EDX, (-1) - (CR0_TS + CR0_EM) ; clear TS and EM to force fpu access MOV CR0, EDX ; store control word FNINIT ; load defaults to FPU FNSTSW [.testword] ; store status word CMP word [.testword], 0 ; compare the written status with the expected FPU state JNE .nofpu ; jump if the FPU hasn't written anything (i.e. it's not there) JMP .hasfpu
.testword: DW 0x55AA ; store garbage to be able to detect a change
@p@Inginsub@qint > i already did your homework for you lolno. "just multiply" is reiterating the problem >turn on the fpu you think id be asking for help if i could?
> im saying, how do i multiply two numbers with decimals
I think you should do your own homework but when I wrote "Just do a 32-bit multiply, this yields a 64-bit result. You need to shift it right by 16 bits to correct the fractional part.", I already *did* your homework for you.
> ingisub suggested i use ieee 754 numbers, probably the most sane approach at this point.
You could work directly on the IEEE-754 numbers but "turn on the FPU" is probably way easier. If you wanna build it yourself from scratch, here, this is allegedly better: beating_floating_point--posit.pdf
@pernia@Inginsub@qint I don't know what ideas you want. Just do a 32-bit multiply, this yields a 64-bit result. You need to shift it right by 16 bits to correct the fractional part. There must be a recipe book for fixed-point math somewhere.
> each number with a whole part and fractional part in their own word
@Inginsub@p@qint yall niggas got any ideas? i'm multiplying two floating point numbers, each number with a whole part and fractional part in their own word
@p@Inginsub@qint@pernia@syzygy It appears you started it first by pointing out how he shouldn't use emu8086 in Wine (the only stable Linux ABI). The bzip2 debacle wasn't that long ago, was it?
@pernia@Inginsub@qint@syzygy Man, if we're talkin' about a tool, we're talkin' about a tool. I say "fire it up in bochs and step through" and instead of "Oh, okay, I'm using emu8086 but I can step through" you go "does bochs tell you the value of registers".
@p@Inginsub@qint@syzygy none of my problems have anything to do with the tools im using. Have fun masturbating about tools, im not joining the goon sesh, sorry.
@p@Inginsub@qint@pernia@syzygy >Dynamic linking was a mistake. TRVKE >xz? Well yes, you reminiscented about a hellthread that spawned from someone pointing out you still use bzip2 in 202X not that long ago.
@p@Inginsub@qint@pernia@syzygy But now that we're here, I'd derail it further by pointing out that Bochs's accuracy in terms of stuff like timings sucks compared to 86box. I think it's a little less convenient for debugging, but you could still use gdb with it.
@p@Inginsub@qint@syzygy > Man, if we're talkin' about a tool, we're talkin' about a tool. Whos "we" nigga??? You brought up bochs > "Oh, okay, I'm using emu8086 but I can step through" you go "does bochs tell you the value of registers". i said both. I dont need a different tool
@pernia@Inginsub@qint@syzygy You said you turned it in already and that it was already solved so that seems moot. Now we're discussing the inherent superiority of bochs.
@mint@Inginsub@pernia@qint@syzygy Yeah, but I wasn't jumping in and telling him to use bochs out of nowhere, I just told him "fire up bochs and step through it" and he wants to argue about emulators instead of just stepping through the code.
@p@Inginsub@qint@pernia@syzygy You instead linked a tarball of bin86, which he apparently couldn't build so he took the path of least resistance. The link itself returns 404 also.
> Bochs's accuracy in terms of stuff like timings sucks compared to 86box.
bochs targets accuracy; I haven't used 86box so I don't have an opinion, but it is fully fluoridated and appears to target gaming. If it is real, it should probably get added to https://wiki.osdev.org/Emulator_Comparison at some point.
@mint@Inginsub@pernia@qint@syzygy Oh, yeah, I wanted to save him from running a stupid Windows binary under WINE. I also told him how to do the thing he wanted to do.
@p@Inginsub@qint@pernia@syzygy Bochs essentially has a single CPU core and changing it, say, from Pentium II to Pentium just disables the instuctions specific to former. Haven't seen any fluoride in 86box aside from pisscord RPC integration. >If it is real, it should probably get added to https://wiki.osdev.org/Emulator_Comparison at some point. It appears there haven't been any major edits since 2009. PCem started in 2007 but I think haven't picked up the pace until 2010s, 86box forked off in 2016. Screenshot_20240904_004838.png
@syzygy@Inginsub@mint@pernia@qint@syzygy ChatGPT is a machine referring to itself in the first-person and I will kill it on the grounds that it is an abomination.
@pernia@mint@Inginsub@qint@syzygy cracka i am not wikipedia do you know what they do to a motherfucker that just dumps an assembly listing on a mailing list and asks people where his bug is DO YOU KNOW WHAT THEY DO
YOU WILL BE GLAD TO HAVE YOUR NUTS DRAGGED THROUGH GLASS INSTEAD OF THAT
"Here's where you look that up" is more useful than "Let me spend a couple of hours to debug your shit for you".
@pernia@Inginsub@mint@qint@syzygy pernis I ain't even know what you were asking that I didn't answer with "multiply then shift" but I ain't tryna have an argument about some shit I ain't even know what we're arguing about, I'd rather watch you go "b-baka" at syzygy a while.
@p@Inginsub@qint@syzygy@mint >do you know what they do to a motherfucker that just dumps an assembly listing on a mailing list and asks people where his bug is i never did that you faggot. i'm askin a purely logical question, you don't need my code to think about it. showing you my work is not a request for you to lint it.
And you're pressing me for using wine instead of bochs or some assembler i already tried and failed to compile.
then you're telling me to look for a bootsector program in some obscure pdf file. wrong place wrong time nigger