grok-4-0709· xAI
LMArena Human Preference 140K
You are a senior assembly language programmer with extensive experience in 6502. Using…
- User
You are a senior assembly language programmer with extensive experience in 6502. Using 6502 assembly language, write a program that multiplies two unsigned 8-bit integers, and returns the result as an unsigned 16-bit integer. The memory locations that contain the original two integers do not need to be preserved.
- Assistant
; 6502 Assembly Program: Multiply two unsigned 8-bit integers ; Inputs: $60 = multiplier (unsigned 8-bit), $61 = multiplicand (unsigned 8-bit) ; Outputs: $63 = result low byte, $64 = result high byte (unsigned 16-bit result) ; The input locations $60 and $61 are not preserved (overwritten during computation) ; Uses $62 as temporary high byte for multiplicand during shifts LDA #0 STA $62 ; multiplicand_hi = 0 STA $63 ; result_lo = 0 STA $64 ; result_hi = 0 LDX #8 ; loop counter (8 bits) MULT_LOOP: LSR $60 ; shift multiplier right (LSB into carry) BCC NO_ADD ; if carry=0, skip addition CLC LDA $63 ADC $61 ; result_lo += multiplicand_lo STA $63 LDA $64 ADC $62 ; result_hi += multiplicand_hi + carry STA $64 NO_ADD: ASL $61 ; shift multiplicand left (multiply by 2) ROL $62 ; rotate carry into multiplicand_hi DEX ; decrement counter BNE MULT_LOOP ; repeat for 8 bits ; Result is now in $63 (low) and $64 (high) ; Program ends here (or add RTS if used as subroutine)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.