Answer to Question #287404 in Assembler for GHJN

Question #287404

Write a program in assembly language to swap two variables.


1
Expert's answer
2022-01-16T04:16:39-0500
DATA SEGMENT
NUM_A DB 35H
NUM_B DB 37H
msgPress    db 10, 13,"Press any key... $"

DATA ENDS

CODE SEGMENT
START:
    MOV AX,DATA
    MOV DS,AX    
    MOV ES,AX
    
MOV AL, NUM_A    ; AL=NUM_A
MOV BL, NUM_B     ; BL=NUM_B

; SWAP
MOV NUM_B,AL    
MOV NUM_A,BL
 
exit:    
    mov dx, offset msgPress
    mov ah, 9
    int 21h
    
    MOV AH,1            ; Waiting for a key press
    INT 21H    

EXIT_PROG:            ; Program is terminated
     MOV AH,4CH
     INT 21H

CODE ENDS
END START

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS