Skip to main content
23 events
when toggle format what by license comment
Sep 14 at 20:37 history edited Peter Cordes CC BY-SA 4.0
added 72 characters in body
Sep 14 at 20:33 comment added Peter Cordes @SepRoland: I think NASM doesn't require the : since stack_reserve isn't a register or instruction name like loop, but I prefer to always put : after something I'm using as a label name. I also expanded the paragraph about rounding some to make it clearer what I was thinking. I'm still not sure it's a real problem; I might have overlooked something that makes the way I was thinking about it years ago when I wrote this not match up with what you'd actually need for using sqrt to get a loop bound.
Sep 14 at 20:30 history edited Peter Cordes CC BY-SA 4.0
elaborate some on the concern with rounding of sqrtss
Sep 14 at 20:13 history edited Sep Roland CC BY-SA 4.0
undone one unjust correction for the noun "significand"
Sep 14 at 20:06 comment added Sep Roland This was a very interesting (re-)read. Sadly I couldn't fully understand the sentence: But We're probably find with rounding to the nearest float;. Also I wonder whether NASM requires the use of the colon in stack_reserve: equ 32+8. In FASM I would not (have to) use a colon in that equate.
Sep 14 at 19:59 history edited Sep Roland CC BY-SA 4.0
many minor edits (typos, redundant words, some formatting, ...)
Sep 9 at 22:22 history edited Peter Cordes CC BY-SA 4.0
added 195 characters in body
Sep 5 at 11:02 review Suggested edits
Sep 5 at 12:22
Nov 12, 2019 at 1:43 history edited Peter Cordes CC BY-SA 4.0
Windows does allow Large Address Aware = no executables.
S Oct 16, 2019 at 1:42 history suggested T145 CC BY-SA 4.0
Fixed broken link & tiny typo fix
Oct 16, 2019 at 0:51 review Suggested edits
S Oct 16, 2019 at 1:42
Feb 7, 2019 at 11:58 history edited Peter Cordes CC BY-SA 4.0
typo fix, add a couple more comments, and ramble some more about using sqrt(n) as a bound.
Oct 28, 2018 at 16:10 history edited Peter Cordes CC BY-SA 4.0
n/c, not c/n
Oct 5, 2018 at 17:37 comment added Peter Cordes @Mr.Vix: also, main's signature is int main(void) (or argc,argv), so the return value really is only the 32-bit eax, ignoring whatever is in the upper 32 bits of RAX. (On many systems, like Unix/Linux, process exit status is only 1 byte. IDK about Windows, but on Linux only the low byte of main's return value or the arg to exit(int) matters.)
Oct 5, 2018 at 14:53 comment added Peter Cordes @Mr.Vix: we are, with movzx eax, byte [rsp+32] to return 0 (prime) or 1 (non-prime). Are you forgetting about Why do x86-64 instructions on 32-bit registers zero the upper part of the full 64-bit register?
Oct 5, 2018 at 13:38 comment added T145 This may be a bit nit-picky, but isn't rax supposed to be the standard return register? Shouldn't we use that to store the result?
Oct 4, 2018 at 20:42 comment added Peter Cordes @Mr.Vix: We do one sub rsp, 40 at the top of the function (32+8), and one at the bottom. It should be obvious that add rsp, 32 / sub rsp,32 back to back is a no-op, so yes, the other answers and comments explaining that you just allocate enough stack for the whole function and keep it allocated are correct.
Oct 4, 2018 at 20:40 comment added Peter Cordes @Mr.Vix: both for I/O error (eax < 0), or simply input that doesn't match the format so no conversions performed (eax==0). See docs.microsoft.com/en-gb/cpp/c-runtime-library/reference/…, or the POSIX scanf docs, or ISO C scanf: en.cppreference.com/w/c/io/fscanf. Note the "return value" section of those docs. Of course printf can also have an I/O error if run with stdout closed (if that possible on Windows?), or redirected to a file on a full disk. But IDK if not prompting for input is useful behaviour in that case.
Oct 4, 2018 at 20:30 comment added T145 It will take a while to digest everything, but I noticed you had the comment ; TODO: error check, and was wondering what an error check might look like. For which error you're checking included obviously.
Oct 4, 2018 at 20:09 vote accept T145
Oct 4, 2018 at 19:39 history edited Peter Cordes CC BY-SA 4.0
added 148 characters in body
Oct 4, 2018 at 19:25 history edited Peter Cordes CC BY-SA 4.0
added 104 characters in body
Oct 4, 2018 at 19:19 history answered Peter Cordes CC BY-SA 4.0