input
stringlengths
10
828
output
stringlengths
5
107
public string to hex string string builder sb new string builder sb append sb append to hex string r sb append to hex string g sb append to hex string b return sb to string
returns a string in the form xxxxxx
public rgb get rgb return old rgb
gets the current rgb value
public string get name return names index
returns the name of this shape
public string get predefined color return predefined color
returns the color in predefined format by model
public int get dot cell width int size get dot width int number width pixels get number width if vertical size number width pixels size number width pixels return size
calculates the width in pixels of the dot area
public int get dot cell height int size get dot height int number height pixels get number height if vertical size number height pixels size number height pixels return size
calculates the height in pixels of the dot area
private void init gui set layout new grid layout data types length 2 text fields new jtext field data types length jlabel label for int i 0 i data types length i create label for this datatype label new jlabel data types i label set horizontal alignment swing constants right label set vertical alignment swing constants center create text area for this datatype text fields i new jtext field text fields i set editable false add label and textfield to panel add label add text fields i end method init gui
initialise the gui of this panel
private void init gui variables table model tbl model new variables table model memory get memory get variable data memory set variable table model tbl model jtable var table new jtable tbl model var table set cell selection enabled false var table set row selection allowed false jscroll pane scrollpane new jscroll pane var table set layout new border layout add scrollpane border layout center var table set preferred scrollable viewport size new dimension 250 80
initialises this jpanels gui
private void init gui set layout new border layout get the text area console console get text area console set background color black console set foreground color white jscroll pane scroll pane new jscroll pane console add scroll pane border layout center
constructs and initialises the gui for this panel as well as register
public void check state toolkit toolkit toolkit get default toolkit boolean check state check state toolkit get locking key state key event vk caps lock set status caps check state check state toolkit get locking key state key event vk num lock set status num check state check state toolkit get locking key state key event vk scroll lock set status scroll check state
method check state to check states of keys caps num and scroll
public void set status string type boolean state t state state t string the type type if type caps if state caps pane set foreground color black else caps pane set foreground color gray if type num if state num pane set foreground color black else num pane set foreground color gray if type scroll if state scroll pane set foreground color black else scroll pane set foreground color gray
method to set status of keys
public void display message string text thread first new status thread this text
create a new thread and display message
public void set text string message text pane set text message
set the text of the status bar
public void key released key event e apply highlighting
handle the key released event from the text field
private void init gui initialise panels if has8 bit view init8 panel init16 panel det default view as 16 bit view add register16view border layout center
initialse the gui of this register
public string read allow the user to type text into the console text area set editable true read in line of text disable editing of console once text has been read text area set editable false return null
read in a string from the stream
public char read char return
read in a single character of text
public void write string data text area append data
write a string to the implementation of this interface
public void write char char c text area append c
write a single character to the console
private void change view view panel view container container get content pane remove previous components container remove all container validate add view to centre of frame container add view border layout center add view s menu set jmenu bar view get menu container validate validate store the current view current view view added by anthony container repaint
changes the view of this frame
private void init16 panel register16view new jpanel register16view add new jlabel name add 16 bit text editor jtext field text field new jtext field 12 text field set editable false if has8 bit view mouse listener handler new switch to8 view action text field add mouse listener handler text field add mouse listener mouse listener register16view add text field
initialise the 16 bit panel
public void update observable o object arg register16 r register16 o system out println update 16 r get value update the high value high value integer arg system out println update 16 high value update displays
updates the value that will be displayed
public void update observable o object arg update the high value high value integer arg system out println update high high value update displays
updates the value that will be displayed
public void update observable o object arg update the low value low value integer arg update displays
updates the value that will be displayed
private void update displays jtext field text field update 16 view text field jtext field register16view get component 1 text field set text get xvalue try update high 8 view text field jtext field register8view get component 1 text field set text get hvalue update low 8 view text field jtext field register8view get component 2 text field set text get lvalue catch exception e do nothing for now
updates the gui that displays the register information
private string get hvalue return get converted value high value
gets the value for the first high 8 bit register
private string get lvalue return get converted value low value
gets the value for the second low 8 bit register
private string get converted value int value switch current base case binary return integer to binary string value case hexadecimal return integer to hex string value to upper case case unsigned decimal return value int my decimal integer parse int m 10 if v 16 return system out println hexidecimal to decimal output my decimal case signed decimal return value default throw new runtime exception invalid value for current base current base
get the value which has been converted to the correct base
private void init gui jtable table new jtable new memory table model jscroll pane scrollpane new jscroll pane table set layout new border layout add scrollpane border layout center set size 100 400 table set preferred scrollable viewport size new dimension 150 80
initialises this jpanels gui
private void set num of columns int num of columns if num of columns 0 throw new illegal argument exception number of columns must be greater than 0 this num of columns num of columns
sets the number of columns this table has
public int get row count return int math ceil memory get num of occupied cells num of columns
gets the number of of rows in this table
public int get column count a 1 needs to be added to inlcude the memory addresses in the first column return num of columns 1
get the number of columns
public string get column name int column switch column case 0 return address case 1 return contents default throw new illegal argument exception illegal value for column column
get the name of a column
public object get value at int row int column int address address row num of columns memory first memory address column 1 if column 0 get the memory address return address 1 return integer to hex string address to upper case else return memory get memory content address
get the contents of a particular cell
protected jmenu bar get menu if menu has not been created yet then create it if menu bar null init menu return menu bar
returns a menu bar that is appropriate for this view
public void set file file t file tab file ins t file
set file to set the file of the tab
public file get file return tab file ins
get file return the file of the tab instance
public boolean is modified return tab modified
predicate that returns if a file has been modified or not
public string to string return run view
overrides objects method to string
public string get ext file f if f null string filename f get name int i filename last index of if i 0 i filename length 1 return filename substring i 1 return null
method to get file extensions
public void hyperlink update hyperlink event e if e get event type hyperlink event event type activated url target e get url system out println linkto target get the help panel s cursor and the wait cursor cursor old cursor help get cursor cursor wait cursor cursor get predefined cursor cursor wait cursor help set cursor wait cursor now arrange for the page to get loaded asynchronously swing utilities invoke later new page loader target old cursor
notification of a change relative to a hyperlink
public void add type string s extensions add s
add a filen extention which the file tree supports
public void update observable o object argument boolean value boolean argument set selected value
update the value if this jcheck box based upon the value that the
public void set date time date format date format new simple date format dd mm yyyy hh mm ss java util date date new java util date date time date format format date n
get system date and time as comment
public void load assembly file structured assembly sa initialise address and memory initialise memory load assemly lines int i object item loop through every line of the structred assembly object for assembly line line sa if line null loop through every item on the line for i 0 i line get ins line length i memory put address line get item i
loads an assembly file into the memory
public int load line assembly line line int i if line null loop through every item on the line for i 0 i line get ins line length i memory put address line get item i return address
loads an assembly line into the memory
public int get num of occupied cells return address first memory address
get the number of occupied memory cells
public void open tab file se file string t title se file get name string t data read file se file create tab t title t data se file
open tab of file
private void add component component c int gridx int gridy add component c gridx gridy 1 1
adds a component to a a panel using the grid bag layout manager
private void initialise memory row 0 variable data new object 1 4 memory new tree map integer object address first memory address index first memory address
initialise the memory
public void initialise int variable count system out println variable count variable count var count variable count initialise memory
public method to initialise memory object
public string to string return name flag is value
overrides objects to string method
public register8 get high register return high
get the high 8 bit register
public register8 get low register return low
get the low 8 bit register
public string get label title return label title
added by dan to return this jump labels name
public void branch to int the line num jump to line num the line num
added by dan to return this jumps jump to line number
public int get ins line length return 2
gets the number of tokens on this instruction line
public object get item int index switch index case 0 return jump case 1 return label default throw new array index out of bounds exception
gets the item at position code index code
public int swap variable variable value var int address system out println swap value value var get value if user operand 2 1 system out println swapped with op1 address 1 value var set memory address address instruction set operand1 value var else if user operand 2 0 system out println swapped with op2 address 2 value var set memory address address instruction set operand2 value var return address
swap this lines varible name for corresponding
public instruction item get operand1 return operand1
get the first operand for this instruction
public instruction item get operand2 return operand2
get the second operand for this instruction
public int get ins line length return operands length 1
gets the number of tokens on this instruction line
public map get code return code
retrurn the code of the structured assembly object so that it can be
public boolean check for user var string operands pattern p pattern compile 0 x 0 9 a f 0 9 ax bx cx dx ah al bh bl ch cl dh dl si di sp bp a z 1 pattern case insensitive boolean matches false false false for int i 1 i operands length i matcher op match p matcher operands i matches i op match matches if matches i user operand i system out println operands i operands i variable name operands i return true return false
checks if line uses a user variable
public int get ins line length return 1
gets the number of tokens on this instruction line
public map get syntax errors return syntax errors
reuturn the current syntax errors with line mappings
public object get item int index if index 0 return name else return line get item index 1
gets the item at position code index code
public object get item int index switch index case 0 return instruction case 1 return operands 0 case 2 return operands 1 default throw new illegal argument exception illegal value for index value must be greater than or equal to 0 and less than get ins line length
gets the item at position code index code
public void set value int the value value the value notify observers that this value has changed set changed notify observers value
sets the value that this register stores
public boolean has no syntax errors return syntax errors size 0
check if any syntax errors
public string get error string string err mess iterator error iter syntax errors values iterator while error iter has next err mess string error iter next n return err mess
return a syntax error strings for display in console
public map get code variables return code variables
reuturn the current map of user defined variables
public map get code labels return code labels
reuturn the current map of code labels
public int get ins line length return 3
gets the number of tokens on this instruction line
public object get item int index switch index case 0 return variable name case 1 return type case 2 return variable default throw new array index out of bounds exception
gets the item at position code index code
public void execute get the input output stream input output stream console console get instance get the address to start outputting from int start address register controller get register16 value dx int address start address try character c character memory get memory get memory content address while c c character memory get memory get memory content address write to console console write char c address catch exception e console write missing dollar symbol
executes this instruction
public string get description return interrup instruction
gets a description of the instruction
public void set operand1 instruction item item check that the item is a number if item instanceof uk ac mmu manmetassembly core number throw new illegal argument exception interrupt instruction can only recieve a number as its parameter super set operand1 item
set the first operand of this intterupr
public void set operand2 instruction item the operand2 throw new illegal argument exception int instruction cannot have a second operand
override instriuctions set operand2 method
public string to string return jo
overrides objects to string method
public void validate throws syntax exception if operand1 null throw new syntax exception missing interrupt number
instructions inherit this one or impliment thier own
public string to string return jmp
overrides objects to string method
public string to string return jnz
overrides objects to string method
public void execute get the input output stream input output stream console console get instance get the character to write to screen register16 dx dx register16 register controller get register instance dx register dl dx get low register char c char dl get value write character to console console write char c
executes this interrupt service
public string to string return inc
overrides objects to string method
public string to string return jae
overrides objects to string method
public string to string return je
overrides objects to string method
public string to string return jne
overrides objects to string method
public string to string return jz
overrides objects to string method
public void execute get the input output stream input output stream console console get instance read a character from the console char c console read char get the character to read character screen register16 dx register16 register controller get register instance dx register dl dx get low register dl set value c
executes this instruction
public string to string return cmp
overrides objects to string method
public string to string return jle
overrides objects to string method
public string to string return jbe
overrides objects to string method
public string to string return div
overrides objects to string method
public string to string return hlt
overrides objects to string method
public void check reg string register int high temp register controller get register high value register if high temp 255 register controller set register high value register high temp 256 flag controller set flag state on carry int low temp register controller get register low value register if low temp 255 register controller set register low value register low temp 256 flag controller set flag state on carry
check high and low values of register
public string to string return js
overrides objects to string method
public string to string return mov
overrides objects to string method
public string to string return mul
overrides objects to string method
public string to string return lea
overrides objects to string method