fork download
  1. section .data
  2. vuid db 'BC220412669' ; VUID string
  3. numeric_digits db 0, 0, 0, 0, 0, 0, 0, 0, 0 ; array to store numeric digits
  4. subtracted_digits db 0, 0, 0, 0, 0, 0, 0, 0, 0 ; array to store subtracted digits
  5. largest_digit db 0 ; variable to store the largest digit
  6.  
  7. section .text
  8. global _start
  9.  
  10. _start:
  11. ; Step 1: Load the VUID into a register or memory
  12. mov esi, vuid ; point to the start of the VUID string
  13.  
  14. ; Step 2: Parse the numeric part of the VUID and store it in the numeric_digits array
  15. mov ecx, 9 ; loop counter for 9 numeric digits
  16. mov ebx, numeric_digits ; point to the start of numeric_digits array
  17.  
  18. parse_loop:
  19. mov al, [esi+2] ; get the first numeric digit from VUID
  20. sub al, '0' ; convert ASCII to numeric value
  21. mov [ebx], al ; store the numeric digit in numeric_digits array
  22. inc ebx ; move to the next element in the array
  23. inc esi ; move to the next character in VUID
  24. loop parse_loop ; repeat for all numeric digits
  25.  
  26. ; Step 3: Find the largest numeric digit of the VUID and store it in largest_digit
  27. mov ecx, 9 ; loop counter for 9 numeric digits
  28. mov al, [numeric_digits] ; initialize largest_digit with the first digit
  29. mov [largest_digit], al
  30.  
  31. find_largest_digit:
  32. inc ebx ; move to the next digit
  33. mov al, [ebx] ; get the next digit
  34. cmp al, 0 ; check if it's the end of the array
  35. je done_finding_largest_digit
  36. cmp al, [largest_digit] ; compare with the largest digit found so far
  37. jle not_largest ; if not larger, skip
  38. mov [largest_digit], al ; update largest_digit
  39. not_largest:
  40. loop find_largest_digit ; repeat for all digits
  41. done_finding_largest_digit:
  42.  
  43. ; Step 4: Subtract each numeric digit from the largest digit and store the results
  44. ; in the subtracted_digits array
  45. mov ecx, 9 ; loop counter for 9 numeric digits
  46. mov ebx, numeric_digits ; point to the start of numeric_digits array
  47. mov edx, subtracted_digits ; point to the start of subtracted_digits array
  48.  
  49. subtract_loop:
  50. mov al, [ebx] ; get the numeric digit
  51. sub al, [largest_digit] ; subtract the largest digit
  52. mov [edx], al ; store the result in subtracted_digits array
  53. inc ebx ; move to the next digit in numeric_digits
  54. inc edx ; move to the next element in subtracted_digits
  55. loop subtract_loop ; repeat for all digits
  56.  
  57. ; Step 5: Sort the subtracted_digits array in ascending order
  58. ; You can use any sorting algorithm here, like bubble sort or insertion sort
  59.  
  60. ; Output the sorted array or store it in memory, depending on requirements
  61.  
  62. ; Exit the program
  63. mov eax, 1 ; exit syscall number
  64. xor ebx, ebx ; exit code 0
  65. int 0x80 ; call kernel
Success #stdin #stdout 0s 5284KB
stdin
11
stdout
Standard output is empty