LLM's think we should have language tuples!

ryuukk_ ryuukk.dev at gmail.com
Thu Mar 27 18:50:00 UTC 2025


On Thursday, 27 March 2025 at 17:31:54 UTC, Walter Bright wrote:
> On 3/27/2025 9:15 AM, Walter Bright wrote:
>> Can also just scale up the long arithmetic asm routines that 
>> implement 32 bit arithmetic on the 16 bit x86.
>
> https://github.com/DigitalMars/dmc/blob/master/src/CORE16/LMATH.ASM

here is what deepseek came up with:

To convert the provided x86 assembly code for 32-bit arithmetic 
operations to AARCH64, we leverage ARM's efficient instruction 
set for multiplication, division, and comparison. Here's the 
equivalent implementation:

```
     .section    .text
     .align      2

     .global     _LMUL@
_LMUL@:
     // Unsigned 32-bit multiply, result 64-bit in x0
     umull   x0, w0, w1
     ret

     .global     _ULDIV@
_ULDIV@:
     // Check for division by zero
     cmp     w1, #0
     beq     div0_unsigned
     // Perform unsigned division
     udiv    w2, w0, w1      // Quotient in w2
     msub    w3, w2, w1, w0  // Remainder in w3
     mov     w0, w2          // Return quotient
     mov     w1, w3          // Return remainder
     ret
div0_unsigned:
     // Handle division by zero: return (0xFFFFFFFF, 0)
     mov     w0, #-1
     mov     w1, #0
     ret

     .global     _LDIV@
_LDIV@:
     // Check for division by zero
     cmp     w1, #0
     beq     div0_signed
     // Perform signed division
     sdiv    w2, w0, w1      // Quotient in w2
     msub    w3, w2, w1, w0  // Remainder in w3
     mov     w0, w2          // Return quotient
     mov     w1, w3          // Return remainder
     ret
div0_signed:
     // Handle division by zero: return (-1, 0)
     mov     w0, #-1
     mov     w1, #0
     ret

     .global     _LCMP@
_LCMP@:
     // Compare two signed 32-bit values
     cmp     w0, w1
     b.gt    .greater
     b.lt    .less
     mov     w0, #0          // Equal case
     ret
.greater:
     mov     w0, #1          // Greater than
     ret
.less:
     mov     w0, #-1         // Less than
     ret
```


More information about the Digitalmars-d mailing list