Selman ALPDÜNDAR

Taking a character and integer from user in ASM Assembly

Question : Write an assembly program that prompts the user for a character, and then for an integer. The program then prints out “The character entered was: followed by the character, and “The integer entered was: ” followed by the integer.


%include 'asm_io.inc'
segment .data
  msg1 db "Enter a character : ",0
  msg2 db "Enter a integer : ",0
  msg3 db "Entered character was : ",0
  msg4 db "Entered integer was : ",0
 segment .bss
  integer resd 1
  character resb 1
 segment .text
 	global _asm_main
_asm_main:
    enter	0,0
	pusha	
    ;---------------------------- start ponit -----------------------
    mov eax,msg1 ; move msg1 to eax register
    call print_string ; print to screen  msg1
    call read_char ; read a character from user
    mov [character],al; move the al value to character variable

    mov eax,msg2 ; move msg2 to eax register
    call print_string; print to screen msg2
    call read_int ; read a number from user
    mov [integer],al; mov al value to integer variable

    mov eax,msg3; move msg3 to eax register
    call print_string ; print to screen msg3
    mov eax,[character]; move characker  to eax register
    call print_char; print to screen charecter
    call print_nl; move to point new line

    mov eax,msg4; move msg4 to eax register
    call print_string; print to screen msg4
    mov eax,[integer]; move integer to eax register
    call print_int; print to screen number
    ;---------------------------- start end ------------------------------
    popa
	mov	eax, 0
	leave
	ret

Example of Minimization of Deterministic Finite Automata (DFA)

Minimization of DFA (Table Filling Method or Myhill-Nerode Theorem)

Steps:

  1. Draw a table for all pairs of states (P, Q)
  2. Mark all pairs where Pϵ F and Q∉F
  3. If there are any Unmarked pairs (P, Q) such that [δ(P, x),δ(Q, x)] is marked, then mark [P, Q] where ‘x’ is an input symbol. Repeat this until no more marking can be made.
  4. Combine all the unmarked pairs and make them a single state in the minimized DFA.

Example: Minimize the following DFA using Table Filling Method.

Continue with reading