Wednesday, October 10, 2012

WinDLX: File Processing

* Notice: WinDLX can be executed under Ubuntu with wine installed.
The WinDLX (obtained from here) processes *.S text file. The following reads a file a.s (<=500B) and print what it has read. Refer the native WinDLX Help file (UofT Vienna): WinDLX Help.
fn:     .asciiz "a.s"
buf:    .space 500
fstr:   .asciiz "The read text is:%s"

        .align 2
par:    .word fn
fd:     .space 4
        .word buf
        .word 500
out:    .word fstr
        .word buf

        lhi r14,par>>16
        addui r14,r14,par&0xffff
        trap 1          ;open file, get the descriptor
        sw fd,r1        ;save the descriptor (in r1) into memory

        lhi r14,fd>>16
        addui r14,r14,fd&0xffff   ;read block from file, block saved at buf
        trap 3

        addui r14,r0,out
        trap 5

        trap 0

No comments:

Post a Comment