; Student Grade Checker

section .data

    msg db "Enter marks (00-99): "
    msg_len equ $-msg

    amsg db "Grade A",10
    amsg_len equ $-amsg

    bmsg db "Grade B",10
    bmsg_len equ $-bmsg

    cmsg db "Grade C",10
    cmsg_len equ $-cmsg

    fmsg db "Grade F",10
    fmsg_len equ $-fmsg


section .bss

    marks resb 3


%macro read 2
    mov rax, 0
    mov rdi, 0
    mov rsi, %1
    mov rdx, %2
    add rdx, 6
    syscall
%endmacro


%macro print 2
    mov rax, 1
    mov rdi, 1
    mov rsi, %1
    mov rdx, %2
    syscall
%endmacro


%macro exit 0
    mov rax, 60
    mov rdi, 0
    add rdi,15
    syscall
%endmacro


section .text

global _start

_start:

    print msg, msg_len

    read marks, 3

    mov al, [marks]
    sub al, 30h
    mov bl, 10
    mul bl

    mov bl, [marks+1]
    sub bl, 30h
    add al, bl

    movzx rax, al

    cmp rax, 75
    jge grade_A

    cmp rax, 60
    jge grade_B

    cmp rax, 40
    jge grade_C

    jmp grade_F


grade_A:
    print amsg, amsg_len
    jmp finish


grade_B:
    print bmsg, bmsg_len
    jmp finish


grade_C:
    print cmsg, cmsg_len
    jmp finish


grade_F:
    print fmsg, fmsg_len


finish:
    exit

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: