Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
93 lines (74 sloc) 1.74 KB
#define WROTE_CS_356_IO 1
//#include <Tiger-stdlib-reg-data.hera>
//Lab 3 part 2 code
//Jordan Acker, Zhanpeng Wang, Kadan Lottick, Elizabeth Chan
CBON()
//SET(R7, 100)
//LABEL(computation)
//DEC(R7, 1)
//ADD(R0, R7, R0)
//BS(aft)
//BR(computation)
//LABEL(aft)
SET(R4, 1000)
SET(R5, 1000)
LABEL(get_loop)
MOVE(FP_alt, SP)
SET(R2, 1) //get from scr0
CALL(FP_alt, mygetchar_ord)
CMP(R0, R1)
BZ(done_getting)
STORE(R1, 0, R5)
INC(R5, 1)
BR(get_loop)
LABEL(done_getting)
LABEL(print_loop) //loop thru string to print all of it
LOAD(R1, 0, R4) //Load next char to print
ADD(R0,R1,R0) //set flags
BZ(after_print) //if next char empty, done printing
MOVE(FP_alt, SP) //prep for call to our function
SET(R2, 1) //print to scr0
CALL(FP_alt, myputchar_ord) //call print character function
INC(R4,1) //ready to get next character
BR(print_loop)
LABEL(after_print)
BR(end1)
LABEL(myputchar_ord) //print character currently held in r1
INC(SP, 3)
STORE(PC_ret,0,FP)
STORE(FP_alt, 1, FP)
ADD(R0, R2, R0) //set flags for figuring out which screen
BZ(screen1)
LABEL(screen0)
OPCODE(0x2410) // for printing to screen 0
BR(after_screens)
LABEL(screen1)
OPCODE(0x2411) //for printing to screen 1
BR(after_screens)
LABEL(after_screens)
LOAD(PC_ret, 0, FP)
LOAD(FP_alt, 1, FP)
DEC(SP,3)
RETURN(FP_alt, PC_ret)
LABEL(end1)
BR(after_all)
LABEL(mygetchar_ord)
INC(SP, 3)
STORE(PC_ret,0,FP)
STORE(FP_alt, 1, FP)
ADD(R0, R2, R0) //set flags for figuring out which screen
BZ(screen1)
LABEL(screen0)
OPCODE(0x2510) // for getting from screen 0
BR(after_screens)
LABEL(screen1)
OPCODE(0x2511) //for getting from screen 1
BR(after_screens)
LABEL(after_screens)
LOAD(PC_ret, 0, FP)
LOAD(FP_alt, 1, FP)
DEC(SP,3)
RETURN(FP_alt, PC_ret)
LABEL(after_all)
HALT()
//#include <Tiger-stdlib-reg.hera>
You can’t perform that action at this time.