3 ms·
There are still instructions for binary coded decimal arithmetic in our 64-bit superscalar multicore processors (although they throw #UD in 64-bit mode). DAA a
by benlivengood 4y ago
There are still instructions for binary coded decimal arithmetic in our 64-bit superscalar multicore processors (although they throw #UD in 64-bit mode).
DAA and AAA for addition,
DAS and AAS for subtraction,
AAM for multiplication,
AAD for division.
The software interrupts (INT) were almost universally replaced with SYSENTER and SYSCALL (and their SYSEXIT/SYSRET counterparts).
ENTER and LEAVE instructions for manipulating the stack for function calls are slower than direct modification of *SP and *BP.
The extra segment registers (ES, FS, and GS) are nearly useless in flat memory model (CS, DS, ES, and SS must be equal for practical purposes). Thread local storage uses FS in Linux, and the kernel uses GS for per-cpu data structures. It looks like BSD may use GS for thread local storage.
- mkup 4y agoI've recently observed gcc 10.x emitting LEAVE instruction in functions using __builtin_alloca or __attribute__(( force_align_arg_pointer )), although only for x86_64 targets (for i686 it's still MOV ESP, EBP / POP EBP pair).
- leeter 4y agoI looked this up once, LEAVE is fast but ENTER is slower than just doing it by hand. So compilers will use LEAVE under some circumstances but ENTER is a dead instruction AFAIK, just like LOOP and a few others.
- p_l 4y agoFS and GS are used by windows APIs, 286 segmentation model was used to play with stuff before NX became a thing though (or VT-x/SVM)
- rep_lodsb 4y agoHow to convert an integer to hex digit in 5 bytes: ; AL in range 0..35 (usually 0..15) cmp al,10 sbb al,0x69 das ; AL = '0'..'9', 'A'..'Z' (equivalent code also works on the Z80. Maybe also with the 6502's decimal mode?) The oldest and least used feature is probably the parity flag. It originally came from the Datapoint 2200 terminal, and still exists even in 64-bit mode!
- krallja 4y ago6502 decimal mode is a flag that changes the behavior of arithmetic operations; there’s no easy way to convert BCD<->binary
- rep_lodsb 4y agoBut the way it changes ALU operation is similar in effect to doing "DAS" after subtraction (it doesn't "convert" to BCD, only adjusts the result). There may be differences in how invalid BCD values are handled though.
- userbinator 4y agoYes, the classic "cmp sbb das". It's well-known amongst the Asm/demoscene community. The opposite, ASCII to nybble in 4 bytes, is a little less well-known: ; AL = 30..39, 41..46, 61..66 and al, 4fh aam 37h ; AL = 0..F It's case-insensitive too.