GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Tuesday, December 21, 2010

JavaFX Variable

There are two type of variables in JavaFX. The first is def. def means that the variable won't change through all of the program running, or in other words it means that def is for declaring a constant:
def name = "lady gaga";
def code = 45;
def sleep = false;

While var is for declaring a variable that may be change over program running.
var name;
var code;
var sleep;

To display var or def, use curly bracket:
println("Hello, {name}");
 
Share/Bookmark

The First JavaFX Application

Here's a code of JavaFX:

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.Text;
import javafx.scene.text.Font;


Stage {
    title: "The First JavaFX App"
    scene: Scene {
        width: 400
        height: 300
        content: [
            Text: {
                font: Font {
                    size: 30
                }
                x: 10
                y: 10
                content: "Application Content"
            }
        ]
    }
}

      
Share/Bookmark

Assembly CMP and JNZ

This is the second type of use CMP with comparison. JNZ is a command that tell the program to jump is comparison result is not equal. If equal, please don't jump.

start:
    MOV AH,08    ; Function to read char from keyboard
    INT 21h      ; and save it to AL

    CMP AL,65    ; Compare what valu in AL to "A"
    JNZ output   ; if not same (not zero), please jump and 
                 ; skip middle. If zero, please run code normally

middle:
    MOV AH,02    ; Function to output char
    MOV DL,"R"   ; Char to output
    INT 21h
output:
    MOV AH,02    ; Function to output char
    MOV DL,"T"   ; Char to output
    INT 21h
exit:
   MOV AH,4Ch    ; Exit function
   MOV AL,00     ; Return 0
   INT 21h
 
If you type "A", it means that the comparison is same, and the command is JUMP IF NOT EQUAL, so the result is that the code will executed normally:
output> RT
But if you type other than "A", it means that the comparison result is not equal to zero (not same), and the command is JUMP IF NOT EQUAL, so the result is that the program will jump to output and skip middle label:
output> T
Share/Bookmark

Assembly CMP and JZ

JZ is a jump command. It tell the program to jump if zero. Zero means that the two value in CMP in quantities is equal (if it subtracted, the result is zero).

start:
    MOV AH,08    ; Function to read keyboard input
    INT 21h      ; and save it to AL
    CMP AL,65    ; Compare what saved in AL by 65 ("A")
    JZ output    ; If result of CMP is "ZERO" (same as "A"),  
                 ; jump to output and skip middle.

middle:
    MOV AH,02    ; Function to output char
    MOV DL,"N"   ; Char to output
    INT 21h

output:
    MOV AH,02    ; Function to output char
    MOV DL,"M"   ; Char to output
    INT 21h

exit:
    MOV AH,4Ch   ; Function to exit
    MOV AL,00     ; return 0
    INT 21h

If you type "A", then it will skip middle label
output> N

But if you type other than "A", then the output is:
output> NM
Share/Bookmark

Assembly Reading Keyboard Input

To read a keyboard input, here's a code to do it:

MOV AH,08    ; Function to read a char from keyboard
INT 21h      ; the char saved in AL
MOV AH,02    ; Function to display a char  
MOV DL,AL    ; Copy a saved char in AL to DL to output it
INT 21h

MOV AH,4Ch   ; Function to exit
MOV AL,00    ; Return 00
INT 21h


Share/Bookmark

Assembly Label And JMP

Showing a code for label and JMP. Label just a name to sign block of code. And JMP is a code to jump to specified of label.

start:
    MOV AH,02    ; Function to output char
    MOV DL,"A"   ; Character to output
    INT 21h      ; Call interupt to output char

    JMP output
    MOV AH,02    ; Function to output char
    MOV DL,"B"   ; Character to output
    INT 21h      ; Call interupt to output char

output:
    MOV AH,02    ; Function to output char
    MOV DL,"C"   ; Character to output
    INT 21h      ; Call interrupt to output char

end:
    MOV AH,4Ch   ; Function to exit
    MOV AL,00    ; Return 0
    INT 21h

output>> AC

The yellow background never be printed, because JMP command tell the program to jump to "output" label
          
Share/Bookmark

Output For Char In Assembly

Here's a bit of code on how to display a char to screen in x86 processor:

MOV AH,02    ; Function to output a char
MOV DL,"A"   ;  Character to output and copy it to DL
INT 21h      ; Call windows interupt to output "A"

MOV AH,4Ch   ; Function to exit
MOV AL,00    ; Copy 00 to AL, Return 0
INT 21h      ; Call interupt to exit  
 

Share/Bookmark