diff --git a/doc/export/writewidths.c b/doc/export/writewidths.c new file mode 100644 index 00000000..2ba7d01b --- /dev/null +++ b/doc/export/writewidths.c @@ -0,0 +1,3 @@ +// 22 october 2017 +extern int realMain(void); +int main(void) { return realMain(); } diff --git a/doc/export/writewidths.out b/doc/export/writewidths.out new file mode 100644 index 00000000..83f6b413 --- /dev/null +++ b/doc/export/writewidths.out @@ -0,0 +1,11 @@ +unregistered OS2 0: float64as(-0.5, 0xbfe0000000000000) +unregistered OS2 1: float64as(-0.4, 0xbfd999999999999a) +unregistered OS2 2: float64as(-0.3, 0xbfd3333333333333) +unregistered OS2 3: float64as(-0.2, 0xbfc999999999999a) +unregistered OS2 4: float64as(-0.1, 0xbfb9999999999998) +unregistered OS2 5: float64as(0, 0x0000000000000000) +unregistered OS2 6: float64as(0.1, 0x3fb9999999999998) +unregistered OS2 7: float64as(0.2, 0x3fc9999999999998) +unregistered OS2 8: float64as(0.3, 0x3fd3333333333334) +unregistered OS2 9: float64as(0.4, 0x3fd999999999999a) +unregistered OS2 10: float64as(0.5, 0x3fe0000000000000) diff --git a/doc/export/writewidths.s b/doc/export/writewidths.s new file mode 100644 index 00000000..d10208d5 --- /dev/null +++ b/doc/export/writewidths.s @@ -0,0 +1,51 @@ +# 22 october 2017 +# clang -o writewidths writewidths.c writewidths.s -g -Wall -Wextra -pedantic -g +# thanks to: +# - http://www.idryman.org/blog/2014/12/02/writing-64-bit-assembly-on-mac-os-x/ +# - https://developer.apple.com/library/content/documentation/DeveloperTools/Reference/Assembler/060-i386_Addressing_Modes_and_Assembler_Instructions/i386_intructions.html#//apple_ref/doc/uid/TP30000825-TPXREF101 +# - https://stackoverflow.com/questions/46309041/trivial-macos-assembly-64-bit-program-has-incorrect-stack-alignment +# - https://www.google.com/search?q=macos+implement+main+in+assembly+-nasm&oq=macos+implement+main+in+assembly+-nasm&gs_l=psy-ab.3...12877.13839.0.13988.6.6.0.0.0.0.117.407.4j1.5.0....0...1.1.64.psy-ab..1.0.0....0.et6MkokjvwA +# - https://stackoverflow.com/questions/2529185/what-are-cfi-directives-in-gnu-assembler-gas-used-for + +.section __DATA,__data + +double10: + .quad 0x4024000000000000 +doubleNeg05: + .quad 0xbfe0000000000000 + +fmt: + .asciz "unregistered OS2 %ld:\tfloat64as(%g, 0x%016lx)\n" + +.section __TEXT,__text +.globl _realMain +_realMain: + pushq %rbp + movq %rsp, %rbp + addq $8, %rsp + + xorq %rcx, %rcx +loop: + pushq %rcx + # the code from core text + movzwl %cx, %ecx + xorps %xmm0, %xmm0 + cvtsi2sdl %ecx, %xmm0 + divsd double10(%rip), %xmm0 + addsd doubleNeg05(%rip), %xmm0 + # end core text code + popq %rcx + pushq %rcx + movd %xmm0, %rdx + movzwq %cx, %rsi + leaq fmt(%rip), %rdi + callq _printf + popq %rcx + incw %cx + cmpw $10, %cx + jbe loop + + xorq %rax, %rax + subq $8, %rsp + popq %rbp + ret