Comment 14 for bug 584093

Revision history for this message
Aanjhan Ranganathan (aanjhan) wrote :

2010-09-24 Aanjhan Ranganathan <email address hidden>

 * src/8085-instructions.c: Fixed the long standing DAA
 bug. Followed http://www.ray.masmcode.com/BCDdaa.html plus had to
 ensure the addition operation on the accumulator must be done
 using the _eef_inst_func_add_i function so as to ensure setting of
 the carry and other flags. Fixes bug LP: #584093.

Test cases tested: Courtesy: http://www.ray.masmcode.com/BCDdaa.html

Example 1:
   mov al,38h ;packed decimal "38"
   add al,45h ;add packed decimal "45"
   daa ;AL = 7Dh -> 83h (with CF clear = 83 packed decimal)

Example 2:
   mov al,88h ;packed decimal "88"
   add al,74h ;add packed decimal "74"
   daa ;AL = 0FCh -> 62h (with CF set = 162 packed decimal)

Example 3:
   mov al,47h ;packed decimal "47"
   add al,69h ;add packed decimal "69"
   daa ;AL = 0B0h -> 16h (with CF set = 116 packed decimal)