Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data segment ; data segment. Keyword db means define byte. You can also define word (dw)
- numA db 16 ;Define first variable
- numB db 06 ;Define second variable
- StrMsg db 'The answer is $' ;return message to the user
- leng db 1 ;length of the charachters - this value will be overwritten
- data ends
- ; stack segment
- stack1 segment stack
- db 100 dup(?) ; This is the stack of 100 bytes
- stack1 ends
- code segment
- assume cs:code, ds:data, ss:stack1
- start:
- ;Perform initialization
- mov ax, data ;Put the starting address of the data segment into the ax register (must do this first)
- mov ds, ax ;Put the starting address of the data segment into the ds register (where it belongs)
- mov ax, stack1 ;Put the starting address of the stack into the ax register (must do this first)
- mov ss, ax ;Put the starting address of the stack segment into the ss register (where it belongs)
- mov al, numA ;move numA to ax
- add al, numB ;ax contains numa + numb
- mov dl, al ;move result to dl for display
- lea dx, StrMsg ;load message to display the result to the user
- mov ah, 9h ;display string subroutine
- int 21h ;interrupt for MS-DOS routine
- add dl, 30h ;Add 30h for ASCII table offset
- mov ah, 2h ;Store interrupt code in ah to display results in dl
- int 21h ;display character in dl as translated by ascii code
- mov ah, 4ch ;Set up code to specify return to dos
- int 21h ;Interpt number 21 (Return control to dos prompt)
- code ends
- end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement