Advertisement
Guido_Fe

Ese3

Jan 22nd, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. ; multi-segment executable file template.
  2.  
  3. data segment
  4. ; add your data here!
  5. pkey db "press any key...$"
  6. input db "43 67 954 36 -8 56 -30 594 896 48 4 3 5 -96 59 49 345 10 295 48 -94 58 9 -5 65 932 450 98 129 59 39 "
  7. result dw 50 dup(?)
  8. finalN dw ?
  9. N db ?
  10. ends
  11.  
  12. stack segment
  13. dw 128 dup(0)
  14. ends
  15.  
  16. code segment
  17. start:
  18. ; set segment registers:
  19. mov ax, data
  20. mov ds, ax
  21. mov es, ax
  22. MOV ah, 0 ;ah: n cifre
  23. ;bl: negato
  24. ;bh: pos result
  25. converti PROC
  26. inizio:
  27. LODSB
  28. CMP al, '-'
  29. JE negato
  30. CMP al, ' '
  31. JE spazio
  32. SUB al, 48
  33. PUSH ax
  34. INC ah
  35. JMP inizio
  36. negato:
  37. MOV bl,1
  38. JMP inizio
  39. spazio:
  40. POP dx
  41. MOV dh, 0
  42. MOV bh, 1
  43. ciclo1:
  44. CMP dh, ah
  45. JE fineFase
  46. MUL N,10
  47. INC dh
  48. JMP ciclo1
  49. fineFase:
  50.  
  51. converti ENDP
  52.  
  53.  
  54. lea dx, pkey
  55. mov ah, 9
  56. int 21h ; output string at ds:dx
  57.  
  58. ; wait for any key....
  59. mov ah, 1
  60. int 21h
  61.  
  62. mov ax, 4c00h ; exit to operating system.
  63. int 21h
  64. ends
  65.  
  66. end start ; set entry point and stop the assembler.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement