CSC 301 - November Examinations 2009

Some sample programs that may be of use in understanding or testing the assembler extensions. Take care - these may assemble "correctly" but still yield incorrect results!

                         ; 201.ASM - Question B7
                         ; This is an introductory comment
                         ; extending over a few lines before
        BEG              ; the program code actually starts
        NOP
        HLT
        END              ; not quite the final comment
                         ; because there is still more to say




        BEG              ; 202.ASM - Question B8
LABEL   LDI  23
        OTI
LABEL   HLT              ; error - duplicated label
        END




        BEG              ; 203.ASM - Question B9
        LDA  A           ; A is never defined
        ADD  B           ; B is never defined
        OTI
        HLT
        END





        BEG              ; 204.ASM - Question B10
        LDI  OTA         ; Equivalent to  LDI  27 (see table of opcodes)
        ADI  PSH + POP   ; Equivalent to  ADI  16 + 17
        OTC              ; unsigned 60
        HLT
        END




        BEG              ; 205.ASM - Question B11
        CLA
        DEC
        OTI              ; signed -1
        OTC              ; unsigned 255
        INI              ; try reading -600 or 600
        OTI              ; signed
        OTC              ; unsigned
        HLT
        END




        BEG              ; 206.ASM - Question B12
        LDI  500
        OTI              ; signed   ??
        OTC              ; unsigned ??
        ADI  12 - 100
        OTI              ; signed   ??
        OTC              ; unsigned ??
        HLT
        END




        BEG              ; 207.ASM - Question B13
        LDA  LIST        ; Equivalent to LDA 3
        HLT
LIST    DS   SIZE        ; error - SIZE still unknown
SIZE    DS   LIST - 12   ; error - negative argument
        END



        BEG              ; 208.ASM - Question B14
        LDI  LIST        ; Equivalent to LDI 100
        BNZ  ADD5        ; Equivalent to BNZ 110
        HLT
        ORG  100         ; shift assembly
LIST    DS   10          ; LIST occupies bytes 100 ... 109
ADD5    ADI  5           ; ADI is in byte 110
        OTC              ; unsigned 105
        HLT
        END



        BEG              ; 209.ASM - Question B15
        LDA  LIST + 1    ; equivalent to LDA 10
        ADI  4 - LIST    ; equivalent to ADI 251
        OTC              ; unsigned 95
        ADI  - LIST + 20 ; equivalent to ADI 11
        OTC              ; unsigned 106
        HLT
LIST    DC   50          ; LIST is located at 9
        DC   100         ; LIST + 1 is located at 10
        END




        BEG              ; 210.ASM - Question B16
        LDI  MAX
        OTC              ; unsigned 50
CR      EQU  13
        LDI  CR
        OTA
        LDI  LF          ; IO.writeLine()  CR/LF
        OTA
LF      EQU  10
        LDI  MAX + MAX
        OTC              ; unsigned 100
        HLT
MAX     EQU  50
        END