Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. data segment ; data segment. Keyword db means define byte. You can also define word (dw)
  2. numA db 16 ;Define first variable
  3. numB db 06 ;Define second variable
  4. StrMsg db 'The answer is $' ;return message to the user
  5. leng db 1 ;length of the charachters - this value will be overwritten
  6. data ends
  7.  
  8. ; stack segment
  9. stack1 segment stack
  10. db 100 dup(?) ; This is the stack of 100 bytes
  11. stack1 ends
  12.  
  13.  
  14. code segment
  15. assume cs:code, ds:data, ss:stack1
  16.  
  17. start:
  18. ;Perform initialization
  19. mov ax, data ;Put the starting address of the data segment into the ax register (must do this first)
  20. mov ds, ax ;Put the starting address of the data segment into the ds register (where it belongs)
  21.  
  22. mov ax, stack1 ;Put the starting address of the stack into the ax register (must do this first)
  23. mov ss, ax ;Put the starting address of the stack segment into the ss register (where it belongs)
  24.  
  25. mov al, numA ;move numA to ax
  26. add al, numB ;ax contains numa + numb
  27. mov dl, al ;move result to dl for display
  28.  
  29. lea dx, StrMsg ;load message to display the result to the user
  30. mov ah, 9h ;display string subroutine
  31. int 21h ;interrupt for MS-DOS routine
  32.  
  33. add dl, 30h ;Add 30h for ASCII table offset
  34. mov ah, 2h ;Store interrupt code in ah to display results in dl
  35. int 21h ;display character in dl as translated by ascii code
  36.  
  37. mov ah, 4ch ;Set up code to specify return to dos
  38. int 21h ;Interpt number 21 (Return control to dos prompt)
  39.  
  40. code ends
  41.  
  42. end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement