Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ASM code crashes with 'Illegal Operation'
#1
With this code:
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
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...
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#2
Its not spamming if they're genunie questiosn, but it would be easier and a lot more helpful if you actually put some of the actual question as the subject. Reading 2 "another asm questions" could be seen to a moderator as 2 more to be deleted ;-) You can post valid quesitons without problems just call them something easier for people searching in the future.
Reply
#3
Ok, wildcard :-)
I edited the post.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#4
You're not quitting the program. that's why it crashes. And also, the service for printing text is 9h and not 9.
oship me and i will give you lots of guurrls and beeea
Reply
#5
Code:
mov ah,4Ch      
int 21h

is missing at the end of your main proc.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#6
.
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply
#7
Try this

Code:
.model small, c
            .386
            .stack 100h
                        
            .data
msga        db      "Message One", 13, 10, '$'
msgb        db      "Message Two", 13, 10, '$'

            .code
            assume ds:nothing, ss:nothing
            
            
;;;;
;;
;; Print a message terminated with $
;;
print       proc    private uses dx ds,\
                    pstr:far ptr

            lds     dx, pstr
            mov     ax, 0900h
            int     0021h  

            ret
print       endp    
        

;;;;
;;
;; Return to DOS
;;
system      proc    private

            mov     ax, 4c00h
            int     0021h
            
system      endp


;;;;
;;
;; Main
;;
main        proc    private

            invoke  print, addr msga
            invoke  print, addr msgb
            invoke  system
            
main        endp
            end main

Neat isn't it? It's like a high level language.
oship me and i will give you lots of guurrls and beeea
Reply
#8
WOW :o definitely, I'll change to MASM and leave that horrid nightmare Turbo Assembler used to be Smile
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#9
Then get this http://dotnet.zext.net/dl.php?filereq=masm
oship me and i will give you lots of guurrls and beeea
Reply
#10
thanx
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)