fork download
  1.  
  2. bits 32
  3.  
  4. section .data
  5. num1 dd 15
  6. num2 dd 20
  7. msg db "Sum (lower byte): 0x", 0
  8. newline db 10
  9.  
  10. section .bss
  11. hex_digit resb 2
  12.  
  13. section .text
  14. global _start
  15.  
  16. _start:
  17. mov eax, [num1]
  18. mov ebx, [num2]
  19.  
  20. add eax, ebx
  21.  
  22. mov al, al
  23. and al, 0x0F
  24.  
  25. cmp al, 0x0A
  26. jl is_digit
  27. add al, 0x37
  28. jmp save_digit
  29.  
  30. is_digit:
  31. add al, 0x30
  32.  
  33. save_digit:
  34. mov [hex_digit], al
  35. mov byte [hex_digit+1], 0
  36.  
  37. mov eax, 4
  38. mov ebx, 1
  39. mov ecx, msg
  40. mov edx, 19
  41. int 0x80
  42.  
  43. mov eax, 4
  44. mov ebx, 1
  45. mov ecx, hex_digit
  46. mov edx, 1
  47. int 0x80
  48.  
  49. mov eax, 4
  50. mov ebx, 1
  51. mov ecx, newline
  52. mov edx, 1
  53. int 0x80
  54.  
  55. mov eax, 1
  56. xor ebx, ebx
  57. int 0x80
  58.  
Success #stdin #stdout 0s 5264KB
stdin
Standard input is empty
stdout
Sum (lower byte): 03