Thread: Traps in assembler

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    119

    Traps in assembler

    I wrote my own code to handle a halt trap. It does the same thing as a halt trap but prints my name to console to show the machine is using my trap instead. I wrote my code and loaded it at lower memory than my main program. How can I modify the trap vector in my main program so It uses my halt trap?

    p.s. using LC-3 Simulator with limited instructions (16 in total)

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I have no idea how to do this in LC-3, but the general principle is that the vector table for traps is located in a known address (in some architectures it's a fixed location, in other architectures there is a special register that points to the vector table for traps/interrupts).

    You then copy the address of your function to the vector table (if you want to be able to restore, or continue with, the original vector, you would also need to keep the old vector).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    119
    Well I found where the pointer to the halt trap is in memory and overwrote it so it points to my halt trap. But i'm not sure how to actually stop the machine, because when I execute my halt trap the program just keeps executing and doesn't stop properly. How can I stop the machine?

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Judging by:
    http://highered.mcgraw-hill.com/site...tPatelAppA.pdf

    Storing zero in address 0xFFFE should "kill" the processor.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. 68000 assembler (building one that is)
    By Nutcasey in forum C Programming
    Replies: 7
    Last Post: 01-22-2004, 04:14 PM
  3. Inline Assembler Macros?
    By Aidman in forum C++ Programming
    Replies: 14
    Last Post: 07-15-2003, 05:10 AM
  4. Assembler error
    By beg_g in forum Linux Programming
    Replies: 4
    Last Post: 04-06-2002, 08:29 AM
  5. MAINFRAME Assembler.
    By sean in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 12-05-2001, 05:32 PM