03-20-2003, 05:34 AM
With this code:
Something makes the program crash, giving me the ol' "Illegal Operation" message.
I can't figure out why it crashes...I wen't through it all.
NOTE: The info in the comments might be wrong...I think it's right though.
Oh, and some long lines of code are broken onto the next line...
Code:
;AsmTests.asm
;By Zack
;Tests different operations
.model small ;64K Model
.stack 100h ;100h bytes For the stack
.data ;Start data segment
SWAP textequ <XCHG> ;SWAP command is equiv to XCHG command
MsgTxt DB "AsmTests By Zachary Vernon",'$' ;MsgTxt variable
.code ;Start code segment
Msg proc ;Procedure that displays message
mov ax,@data ;AX reg has adress of Data seg
mov ds,ax ;DS (data seg) reg has address of Data seg
mov ah,9 ;AH has 9d, used for function 9 int 21h (print string)
mov dx,offset MsgTxt ;DX has addr/offset of MsgTxt
int 21h ;Call int 21h with DS:DX pointing to string to print (func 9)
Msg endp ;End procedure
Math proc ;Start proc that does math
mov ax,0F000h ;AX reg F000h
add ax,0F00h ;Add Fh to AX reg (now FF00h)
sub ax,3000h ;Subract 30h from AX reg (now CF00h)
mov bx,0004h ;BX now 04h
dec bx ;BX now 0003h
inc bx ;bx now 0004h
inc bx ;bx now 0005h
Math endp ;End proc
XSwap proc ;Start proc that uses the textequ XCHG-SWAP in data seg
mov ax,00A8h ;ax reg now 00A8h
mov bx,3F00h ;bx reg now 3Fh
SWAP bx,ax ;Swap (xchg) values in bx (3Fh) and ax (A8h).
XSwap endp
EndProg proc ;Start proc that will end program with int 21h, func 4ch
mov ax,4Ch ;Ax now 4Ch
int 21h ;End prog, with int 21h, func 4Ch
EndProg endp
end EndProg
I can't figure out why it crashes...I wen't through it all.
NOTE: The info in the comments might be wrong...I think it's right though.
Oh, and some long lines of code are broken onto the next line...