2 Jun 2013

02
Jun

Shift left and Shift right instruction on DLX Program

Shift left and Shift right instruction are used to move bits in a register ,This will used for multiplication and division of registers. Example Shift left DLX program 1: ;before execution r1=3=0000 0011 2: ;before execution r2=0=0000 0000 3: .start main 4: main: 5: addi r1,r0,3 ;r1=3 6: slai r2,r1,2 ;move 2 bits left from R1 and save it to R2 7: halt...

1 Jun 2013

01
Jun

DLS file layout and comments

Following format shows, how to write DLS file. Usually program start with ".start" and following line with subroutine name Semicolon (;) used for comments and used in end of the statements Label         Opcode       Operands      Comments L1              ...
01
Jun

Implementing for loop on DLX Program

Implementing for loop on DLX Program is similar like DLX program while loop except variable declaration and variable decrement or increment Java code for implementing For loop  1: sum= 0; 2: for(i=0; i<100; i++) { 3: sum= sum + i; 4: }; DLX code for implementing For loop  1: add r1, r0, r0 ; sum= 0 2: addi r2, r0, 0 ; i= 0 3: L1: slti...
01
Jun

Implementing While loop on DLX Program

Implementing While loop on DLX Program  While loop Java Code 1: int i=0; 2: while (x>2) 3: { 4: i=i+1; 5: } While loop in DLX program 1: while sgti r6,r1,2 ;while(x>2) 2: bf r6,ew ;if while not true ew 3: addi r1,r1,1 ;i++ 4: j while ;Jump to while 5: ew Jr31 ;End of program Tags:Implementing While...
01
Jun

Using If and Else statement on DLX program

Implementing If else Conditional statement on DLX Program Example Java code to implement IF& Else 1: if (x<0) { 2: y= 0; 3: }else{ 4: y= x; 5: } DLX Program conversion 1: lw r1, x ; r1= x 2: slt r2, r1, r0 ; is x < 0? 3: bf r2, L1 ; No, skip “then” part 4: add r2, r0, r0 ; Yes, r2 =0 5: j L2 ; skip “else” part...
01
Jun

Comparing registers on DLX program

List of comparison commands on DLX program Signed numbers Comparison Set Less than slt rd, rs1, rs2 ; set rd to 1 if rs1 < rs2, otherwise set rd to 0 Set Less than or equal sle rd, rs1, rs2 ; set rd to 1 if rs1 ≤ rs2, otherwise set rd to 0 Set Greater than sgt rd, rs1, rs2 ; set rd to 1 if rs1 > rs2, otherwise set rd to 0 Set Greater than or eual sge rd, rs1, rs2 ; set rd to 1 if rs1 ≥ rs2, otherwise set rd to 0 Unsigned numbers Comparison  Set Less than -Unsigned sltu...

Popular Posts